我正在使用 RGiesecke DLLExport 库生成一个 C# DLL,该 DLL 可以从基于 VC6 的遗留应用程序动态加载。它导出方法,并从 VC6 代码中调用它们。没问题。但是,只要我尝试将变量声明为我的任何一个 .net 类,它就会崩溃。
//I tried CallingConvention = CallingConvention.StdCall too
[DllExport(CallingConvention = CallingConvention.Winapi)]
static void GetDwgReferences(string fileName)
{
//OK: inialize System classes of .net
DateTime dateTime = DateTime.Now;
//crashing here: declare a variable of my static class (.net assemebly)
//SafeString safeString;
//crashing here: declare a variable of my class (.net assemebly)
//Email email;
//crashing here: initialize an object of my class (.net assemebly)
//DwgXrefs dwgXrefs = new DwgXrefs();
//crashing here by declcare a variable of third-party library (.net assemebly)
//ExSystemServices _serv;
}
怎么了?请帮忙。