Click here to Skip to main content
15,867,867 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
'System.Reflection.TargetInvocationException' is thrown. I don't understand why the innerException tells something about IsolatedStorage because I create that folder in sdCard.

C#
_className	"System.Reflection.TargetInvocationException"
_innerException	{System.IO.IsolatedStorage.IsolatedStorageException: Operation not permitted on IsolatedStorageFileStream.
   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, IsolatedStorageFile isf)
   at MarketApp.ShortTimeStoring.<FillPricesFromIsoStore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>b__3(Object state)}
_message	"Exception has been thrown by the target of an invocation."
IsTransient	false
Source	"mscorlib"


What I have tried:

This is my code:
C#
StorageFolder myFolder = await KnownFolders.PicturesLibrary.CreateFolderAsync("MarketApp", CreationCollisionOption.ReplaceExisting);
StorageFile myFile = await myFolder.CreateFileAsync("Products.txt", CreationCollisionOption.ReplaceExisting);
Stream f = await myFile.OpenStreamForWriteAsync();
using (StreamWriter sw = new StreamWriter(f))
{
    sw.WriteLine("Hello world!");
}
Posted
Updated 18-Mar-16 4:00am
v3
Comments
Richard Deeming 16-Mar-16 12:12pm    
The TargetInvocationException will have an InnerException which contains the real error details. Update your question and post the full details of that inner exception, and the code that throws it.
Ionascut Mihai 16-Mar-16 12:22pm    
Can you tell me how to find InnerException in vs 2013?
Richard Deeming 16-Mar-16 12:30pm    
At the bottom of the "Exception was unhandled" popup, you should see two actions: "View Detail..." and "Copy exception detail to the clipboard".

The first will open a dialog box which will let you drill into the properties of the exception, including the inner exception.

The second should copy the full details of the exception, including any inner exceptions, to the clipboard. You can then click "Improve question" and paste those details into your question.
Ionascut Mihai 16-Mar-16 12:56pm    
I don't have those options on the dialog box with "Exception was unhandled". They are not available in vs 2013 anymore!!
Sergey Alexandrovich Kryukov 16-Mar-16 21:13pm    
It all has nothing to do with VS 2013 or any particular IDE. This is a fundamental .NET feature. Really simple: every exception object (System.Exception and the derived) has the property InnerException, of the type System.Exception. This is precisely all you need. After all, do you read original MSDN documentation on each type you use? Read and you will know what it is.
—SA

There is something seriously wrong, somewhere in your code. But the only way to find the root cause is to step through the code with your debugger and check exactly what is happening.
 
Share this answer
 
I found the place for InnerException and I found out that problem was elsewhere.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900