0

我一直在努力解决这个问题,但找不到任何解决方案。

我有 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。

非常感谢!

4

0 回答 0