I got confused by a weird problem. I created a Windows Runtime component (for the Windows Store) that makes some legacy C / C ++ codes available for .NET through some C # shell classes.
I wrote a test application Store Store (hereinafter referred to as "test1"), which refers to a WRC project (both projects are in the same solution). It calls the component and everything works fine.
Next, I take the following output files from the WRC project:
MyWrtComponent.dll MyWrtComponent.exp MyWrtComponent.pdb MyWrtComponent.pri MyWrtComponent.winmd
... and try to use them from another Store app project ("test2"). In this project, instead of a link to the MyWrtComponent project, I add a link to the .winmd file. Everything builds fine, but when I run the test2 application, I get a System.IO.FileNotFound exception from mscorlib as soon as I try to use one of the C # classes implemented in MyWrtComponent:
at System.StubHelpers.StubHelpers.GetWinRTFactoryObject(IntPtr pCPCMD) at MyWrtComponent.MyWrtClass..ctor() The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Using the debug assembly and debugging MyWrtComponent does not make any difference.
Running ProcMon on test2, I see several unsuccessful attempts to load vccorlib120_app.DLL (or vccorlib120d_app.DLL if I build debug):
QueryOpen F:\test2\bin\Debug\AppX\vccorlib120d_app.DLL NAME NOT FOUND QueryOpen F:\test2\bin\Debug\AppX\vccorlib120d_app.DLL NAME NOT FOUND CreateFile C:\Windows\SysWOW64\vccorlib120d_app.DLL NAME NOT FOUND
I confirmed that this file does not exist in my C: \ Windows \ SysWOW64 folder. I do not know if this relates to my problem.
When I run test1, the search is done in different places and the file is found:
QueryOpen F:\test1\bin\Debug\AppX\vccorlib120d_app.DLL NAME NOT FOUND CreateFile C:\Program Files\WindowsApps\Microsoft.VCLibs.120.00.Debug_12.0.20827.3_x86__8wekyb3d8bbwe\vccorlib120d_app.dll SUCCESS
I compared bin \ Debug \ AppxManifest.xml of both test projects and noticed one important difference; test1 has the following, and test2:
<Dependencies> <PackageDependency Name="Microsoft.VCLibs.120.00.Debug" MinVersion="12.0.20827.3" /> </Dependencies>
If I add these three lines to the generated test2 output and run the application, it will work, but, of course, this is not a real fix.
Does anyone understand what is going on here? MyWrtComponent has a dependency that is somehow not being transmitted, or should I do something to package vccorlib120d_app.DLL along with my runtime component or ...?
Thanks in advance.