title: TypeInitializationException when starting application from fileshare
body: <p>When I start the application locally everything works fine but as soon as I copy it to a fileshare I get the following exception:</p>
  
  <pre><code>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.&lt;.ctor&gt;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()
  </code></pre>
  
  <p>Any hints what could to wrong here?</p>
  
  <p>EDIT:
  I have wrapped my whole method into a try catch block, but the crash happens before the first line is hit.</p>
  
  <pre><code> 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;
              }
          }
  </code></pre>
  
  <p>EDIT 2:
  I tried the idea mentioned in this blogpost: <a href="http://social.msdn.microsoft.com/Forums/vstudio/en-US/3e05d960-9bba-496b-bf42-9608b94f3c10/debugdiagnostics-intialization-failed-after-installing-security-patch-kb2840628" rel="nofollow">http://social.msdn.microsoft.com/Forums/vstudio/en-US/3e05d960-9bba-496b-bf42-9608b94f3c10/debugdiagnostics-intialization-failed-after-installing-security-patch-kb2840628</a> 
  and this solved my problem. But it means I have to remove all my diagnostics, which I can't do of course.</p>