microsoft / Windows-Packaging-Samples

Windows Application Packaging Project Samples.
MIT License
55 stars 37 forks source link

The specified module can not be found #6

Closed rido-min closed 5 years ago

rido-min commented 5 years ago

When using a native WinRT from .NET, using the activation provided by the package manifest, the runtime call fail with:

System.IO.FileNotFoundException
  HResult=0x8007007E
  Message=The specified module could not be found. (Exception from HRESULT: 0x8007007E)
  Source=mscorlib
  StackTrace:
   at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD)
   at WinRTLibrary.Class1..ctor()
   at WinFormsReferencingWinRT.Form1.Button1_Click(Object sender, EventArgs e) in C:\code\Windows-Packaging-Samples\WinRT\WinFormsReferencingWinRT\Form1.cs:line 22
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.Run(Form mainForm)
   at WinFormsReferencingWinRT.Program.Main() in C:\code\Windows-Packaging-Samples\WinRT\WinFormsReferencingWinRT\Program.cs:line 19

I've fixed the error by adding

https://github.com/microsoft/Windows-Packaging-Samples/blob/master/WinRT/AppConsumingWinRT/Package.appxmanifest#L22

Should VS/MSbuild add the dependency automatically ?