wpf icon indicating copy to clipboard operation
wpf copied to clipboard

Could not load type 'System.Runtime.InteropServices.Marshal' from assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Open zepamble opened this issue 7 years ago • 7 comments

  • .NET Core Version: 3.0.0-preview4-27615-11
  • Windows version: win7 sp1 x64
  • Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No

Problem description: I created the wpf project in vs2019, without any modifications, directly compiled, copied to the win7 sp1 machine (win7 has installed .net core sdk), encountered the following error: Application: WpfApp1.exe CoreCLR Version: 4.6.27615.73 .NET Core Version: 3.0.0-preview4-27615-11 Description: The process was terminated due to an unhandled exception. Exception Info: System.TypeInitializationException: The type initializer for '' threw an exception. ---> System.TypeLoadException: Could not load type 'System.Runtime.InteropServices.Marshal' from assembly 'System.Runtime, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. at ___CxxCallUnwindDtor(IntPtr pDtor, Void* pThis) at .cctor() --- End of inner exception stack trace --- at System.Windows.ContextLayoutManager.UpdateLayout() at System.Windows.Interop.HwndSource.SetLayoutSize() at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value) at System.Windows.Window.SetRootVisualAndUpdateSTC() at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight) at System.Windows.Window.CreateSourceWindow(Boolean duringShow) at System.Windows.Window.ShowHelper(Object booleanBox) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.DispatcherOperation.InvokeImpl() at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) --- End of stack trace from previous location where exception was thrown --- at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Threading.DispatcherOperation.Invoke() at System.Windows.Threading.Dispatcher.ProcessQueue() at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at WpfApp1.App.Main()

Actual behavior:

Expected behavior:

Minimal repro:

zepamble avatar Apr 26 '19 07:04 zepamble

Thanks for the report.

This is caused by a bug in the C++/CLI tools for .NET Core. We have reported it to the C++ team who are investigating.

vatsan-madhavan avatar Apr 26 '19 07:04 vatsan-madhavan

/cc @ericstj, @rladuca

vatsan-madhavan avatar Apr 26 '19 08:04 vatsan-madhavan

We are tracking this using #634 - closing as duplicate.

vatsan-madhavan avatar May 04 '19 18:05 vatsan-madhavan

Hi @vatsan-madhavan , how are you ? Any news regarding this issue ? I tried with the today's new .NET Core version: 3.0.0-preview5-27626-15 on Windows 10 Pro 1809, but the problem still exists. We are unable to run minimal WPF .NET Core application - fails with the same unhandled exception. When I change project file's TargetFramework to net48, the application runs fine (WinForms .NET Core runs fine, too). This is quite important issue, because being able to run .NET Core WPF application is lately heavily advertised across media and social networks.

ondrejgr avatar May 06 '19 17:05 ondrejgr

Would you please try this with the latest preview 6 build available at https://github.com/dotnet/core-sdk? Please make sure that your Win7 installation has all the relevant prerequisites, notably -

  • KB2999226
  • KB2533623

vatsan-madhavan avatar May 08 '19 18:05 vatsan-madhavan

Hi, thank you for your response. Using preview6 all GUI applications build without warnings and run perfectly (wpf@netcore30, wpf@net48, winforms@netcore30, winforms@net48). I'm happy to play with it now.

Runtime Environment: OS Name: Windows OS Version: 10.0.17763 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview6-011805
Host (useful for support): Version: 3.0.0-preview6-27708-02 Commit: 8643297bd9

Sincerely Ondrej

ondrejgr avatar May 08 '19 19:05 ondrejgr

Glad this helped.

If this happens again (System.TypeInitializationException: System.Runtime.InteropServices.Marshal), please continue to watch #634 - we are continuing to work on fixing that one.

vatsan-madhavan avatar May 08 '19 20:05 vatsan-madhavan