Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874449
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:48:29+00:00 2026-06-03T02:48:29+00:00

I’m getting the above exception and error on the following code, which is meant

  • 0

I’m getting the above exception and error on the following code, which is meant to play a selected mp3 file from Isolated Storage:

using (var isf = IsolatedStorageFile.GetUserStoreForApplication())
{            
     using (var isfs = isf.OpenFile(selected.Path, FileMode.Open))
     {                        
          this.media.SetSource(isfs);              
          isfs.Close();                        
     }                    
     isf.Dispose();
}

The error is so vague that I’m not really sure what could be wrong… Any ideas or at least common sources of this error that I could potentially check for?

EDIT: the exception is being thrown at: using(var isfs = isf.OpenFile(...))

EDIT 2: The stack trace…

at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, IsolatedStorageFile isf)
at System.IO.IsolatedStorage.IsolatedStorageFileStream..ctor(String path, FileMode mode, IsolatedStorageFile isf)
at Ringify.Phone.PivotContent.RingtoneCollectionPage.MediaIconSelected(Object sender, GestureEventArgs e)
at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

I’ve realized too that the error does NOT occur if I play one song then stop it (there is a play and pause button in the UI), then play another song. It occurs when I play one song, stop it, and attempt to play the same song again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:48:30+00:00Added an answer on June 3, 2026 at 2:48 am

    The problem occurs when you play the same music twice, therefore it may be a file sharing problem. You should try to provide the FileShare parameter of the OpenFile method:

    var isfs = isf.OpenFile(selected.Path, FileMode.Open, FileShare.Read)
    

    Though I don’t understand why it would happen, since you’re explicitly closing the file.

    EDIT: OK, did some digging with Reflector, and I figured it out. The code of MediaElement.SetSource is:

    public void SetSource(Stream stream)
    {
        if (stream == null)
        {
            throw new ArgumentNullException("stream");
        }
        if (stream.GetType() != typeof(IsolatedStorageFileStream))
        {
            throw new NotSupportedException("Stream must be of type IsolatedStorageFileStream");
        }
        IsolatedStorageFileStream stream2 = stream as IsolatedStorageFileStream;
        stream2.Flush();
        stream2.Close();
        this.Source = new Uri(stream2.Name, UriKind.Absolute);
    }
    

    So basically it doesn’t use the stream you give, and it even closes it. But it keeps the name of the file, and I guess it re-opens it when you play the music. Therefore, if you try to re-open the same file with exclusive access while the music is playing, it fails because the MediaElement has the file opened. Tricky.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I have a text area in my form which accepts all possible characters from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.