ryr*_*ich 6 vb.net com c++-cli out-of-memory system.reflection
我对这个很难过.有时候,当我打电话Reflection.Assembly.LoadFile("path to my dll")时会抛出一个OutOfMemoryException.
StackTrace只显示:
at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)
Run Code Online (Sandbox Code Playgroud)
并且没有InnerException检查更详细的异常信息.
但是,似乎只通过COM.
让我解释:
我的应用程序可以作为常规旧的exe启动,或通过COM接口通过Excel启动(CreateObject("blahblahblah"))
在初始化我的一个GUI类时,它将静态加载我的所有引擎DLL(我的应用程序有一个引擎和一个GUI)
总共有6个引擎DLL - 静态加载的汇编代码在VB.NET中,看起来有点像这样:
Private Shared dllPath As String = System.IO.Path.GetDirectoryName(Reflection.Assembly.GetExecutingAssembly().Location) & System.IO.Path.DirectorySeparatorChar)
Private Shared ReadOnly engineDLL1 As Reflection.Assembly = Reflection.Assembly.LoadFile(dllPath + "engineDLL1_name.dll")
...
Private Shared ReadOnly engineDLL6 As Reflection.Assembly = Reflection.Assembly.LoadFile(dllPath + "engineDLL6_name.dll")
Run Code Online (Sandbox Code Playgroud)
我试图加载的引擎DLL是混合程序集(包含本机和托管C++) - 不确定是否重要.
无论如何,使用procexp,我注意到以标准方式打开我的应用程序,所有这些静态加载的DLL都加载正常.但是,如果我通过COM(通过Excel CreateObject("ProgID of the class with the code above"))初始化此类,它将抛出OutOfMemoryException引擎DLLL4.
如果有人可以提供任何见解,那将非常感谢!!