我一直试图解决这个问题很长一段时间,但找不到任何解决方案。
我有2个VS2008项目,一个是C#,另一个是C ++ / CLI。
C ++ / CLI项目是Win32并加载一些外部库。我已经设法使用regasm注册这个dll没有问题。
C#项目配置为x86并引用C ++项目。
问题是注册我的C#dll时,regasm工具有点不稳定;它要么崩溃,要么显示一个很难理解的错误:
D:\FikusWorks\Source\bin>regasm /tlb SwFCamTree.dll
Microsoft (R) .NET Framework Assembly Registration Utility 2.0.50727.4927 Copyright (C) Microsoft Corporation 1998-2004. All rights reserved.
RegAsm : error RA0000 : An error occurred inside the user defined Register/Unregister functions:
System.TypeInitializationException: The type initializer for 'SwFCamTree.SwAddin' threw an exception.
---> System.TypeInitializationException: The type initializer for '<Module>' threw an exception.
---> System.Runtime.InteropServices.SEHException: External component has thrown an exception.
at <CrtImplementationDetails>.ThrowModuleLoadException(String , Exception )
at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* ) in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 864
at .cctor() in f:\dd\vctools\crt_bld\self_x86\crt\src\mstartup.cpp:line 901
--- End of inner exception stack trace ---
at SwFCamTree.SwAddin..cctor()
--- End of inner exception stack trace
at SwFCamTree.SwAddin.RegisterFunction(Type t)
如果我打开依赖于C#生成的dll,它只显示与MSCOREE.dll的依赖关系,它是64位dll,可能是导致问题,但我不知道如何加载32位版本的MSCOREE.dll。
非常感谢!