I'm writing a C++/CLI RCW around a set of proprietary COM-objects for use from a C#-application, when I deploy the RCW and the C#-application I get a FileNotFound error.
我正在围绕一组专有COM对象编写C ++ / CLI RCW以供C#应用程序使用,当我部署RCW和C#应用程序时,我收到FileNotFound错误。
After this I did the simplest thing possible:
在此之后,我做了最简单的事情:
A .NET Class Library written with C++/CLI (VS2012), no code added to the default implementation.
使用C ++ / CLI(VS2012)编写的.NET类库,没有将代码添加到默认实现中。
A C# Windows Forms Application, Solution and project set to target x86. A reference added to the C++/CLI class library But a button the form in the C# appilcation and crete an instance of Class1 i the C++/CLI library.
C#Windows窗体应用程序,解决方案和项目设置为目标x86。添加到C ++ / CLI类库的引用但是C#appilcation中的一个按钮,以及C ++ / CLI库中的Class1实例。
The error is still the same; in detail:
错误仍然是一样的;详细地:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'ClassLibraryTest.dll' or one of its dependencies. The specified module could not be found.
File name: 'ClassLibraryTest.dll'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at WindowsFormsApplicationTest.Form1.button1_Click(Object sender, EventArgs e) in c:\Users\Sten\Documents\Visual Studio 2012\Projects\C#\WindowsFormsApplicationTest\WindowsFormsApplicationTest\Form1.cs:line 23
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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
WindowsFormsApplicationTest
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/SmokeTest/WindowsFormsApplicationTest.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34209 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.34238 built by: FX452RTMGDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
I have used the Fusion Log Viewer to try to find the error, but according to the log my ClassLibraryTest.dll is loaded successfully.
我使用Fusion Log Viewer尝试查找错误,但根据日志我的ClassLibraryTest.dll已成功加载。
What am I missing here?
我在这里想念的是什么?
1 个解决方案
#1
0
Try compiling in x86 if you are compiling in x64. It worked for me.
如果要在x64中进行编译,请尝试在x86中进行编译。它对我有用。
#1
0
Try compiling in x86 if you are compiling in x64. It worked for me.
如果要在x64中进行编译,请尝试在x86中进行编译。它对我有用。