不知道有没有人遇到过这个问题。
我正在 VS 2012 中开发 C# Windows Phone 8 应用。
我最近遇到了 System.NotImplementedException 类型的未处理异常。
尽管我的所有代码都包含在 try/catch block 中,并且没有抛出 notimplementedexception 的方法 stub 。
在输出中是:
MyAppName.DLL 中发生类型为“System.NotImplementedException”的第一次机会异常
MyAppName.DLL 中发生“System.NotImplementedException”类型的异常,并且未在托管/ native 边界之前处理
如果我点击“继续”继续调试,我会在 VS 中收到一条错误消息弹出对话框:
System.Windows.ni.dll 中发生类型为“System.NotImplementedException”的未处理异常
如果我在这里选择“中断”,打开的堆栈跟踪显示“没有可用的源;调用堆栈仅包含外部代码。此线程停止时调用堆栈上只有外部代码帧。 等等等等。”
这是应用程序崩溃后突出显示的代码:
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
编辑:这是堆栈:
Call stack with external code
System.Windows.ni.dll!MS.Internal.JoltHelper.OnUnhandledException(object sender, System.UnhandledExceptionEventArgs args)
mscorlib.ni.dll!System.Runtime.CompilerServices.AsyncMethodBuilderCore.ThrowAsync.AnonymousMethod_1(object state)
mscorlib.ni.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)
mscorlib.ni.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.ni.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.ni.dll!System.Threading.QueueUserWorkItemCallback..System.Threading.|ThreadPoolWorkItem.ExecuteWorkItem()
mscorlib.ni.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()
mscorlib.ni.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
[Native to Managed Transition]
最佳答案
对于有类似问题的任何人,我找到了明显的原因。
我从 Surface 的 Win8 应用程序移植了一些涉及文件输入/输出的代码,并且在其中一行中,忽略了更改
StorageFolder storageFolder = KnownFolders.DocumentsLibrary;
对应的
IsolatedStorageFile storageFolder = IsolatedStorageFile.GetUserStoreForApplication();
不知何故,这并没有在 try/catch block 中捕获,但是当我修复它时,未捕获的 notimplementedexception 不再发生。
关于c# - 没有可用源的未处理的 System.NotImplementedException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14488867/