从文件共享启动应用程序时发生TypeInitializationException
本文关键字:TypeInitializationException 应用程序 文件共享 启动 | 更新日期: 2023-09-27 18:25:06
当我在本地启动应用程序时,一切都很好,但一旦我将其复制到文件共享中,就会出现以下异常:
Anwendung: WWW.exe
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
Ausnahmeinformationen: System.TypeInitializationException
Stapel:
bei WWW.exe.Client.App.Application_Startup(System.Object, System.Windows.StartupEventArgs)
bei System.Windows.Application.<.ctor>b__1(System.Object)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
bei System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, Int32, System.Delegate)
bei System.Windows.Threading.DispatcherOperation.InvokeImpl()
bei System.Threading.ExecutionContext.runTryCode(System.Object)
bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
bei System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
bei System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
bei System.Windows.Threading.DispatcherOperation.Invoke()
bei System.Windows.Threading.Dispatcher.ProcessQueue()
bei System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
bei MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
bei System.Windows.Threading.Dispatcher.WrappedInvoke(System.Delegate, System.Object, Int32, System.Delegate)
bei System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
bei MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
bei MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
bei System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
bei System.Windows.Application.RunInternal(System.Windows.Window)
bei System.Windows.Application.Run()
bei WWW.exe.Client.App.Main()
这里有什么问题吗?
编辑:我已经把我的整个方法包装成一个try-catch块,但崩溃发生在第一行被击中之前。
void Application_Startup(object sender, StartupEventArgs e)
{
try
{
Application_Startup_Internal(sender, e);
}
catch (Exception exception)
{
Tracer.Write(exception); // writes the exception to the event log.
throw;
}
}
编辑2:我尝试了这个博客文章中提到的想法:http://social.msdn.microsoft.com/Forums/vstudio/en-US/3e05d960-9bba-496b-bf42-9608b94f3c10/debugdiagnostics-intialization-failed-after-installing-security-patch-kb2840628这解决了我的问题。但这意味着我必须删除所有的诊断,当然我不能这样做。
问题是因为.NET 4.0更新中的优化不好http://support.microsoft.com/kb/2840628/en-us.如文章中所述,可以通过安装更新来修复http://support.microsoft.com/kb/2872041/en-us.