Visual Studio添加参考和GetModuleHandle [英] Visual studio Add Reference and GetModuleHandle
本文介绍了Visual Studio添加参考和GetModuleHandle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
B.S.D
你好,
这是一个奇怪的问题.
我有一个WinForms项目.我添加了对DLL的引用.
在程序内部,我在DLL上调用GetModuleHandle.
我得到NULL,表示未加载DLL(即使程序使用了该DLL中的符号).
有人可以向我解释吗?
谢谢,
Elad
B.S.D
Hello,
This is kind of a weird question.
I have a WinForms project. I added a reference to a DLL.
Inside the program I call GetModuleHandle on the DLL.
I get NULL, meaning that the DLL is not loaded (even though the program uses symbols from that DLL).
Can anyone explain this to me?
Thanks,
Elad
推荐答案
IIRC GetModuleHandle无法在托管程序集上工作-不会以与非托管DLL相同的方式加载"它们.
试试:
IIRC GetModuleHandle won''t work on managed Assemblies - they aren''t "loaded" in the same way as unmanaged DLLs.
Try:
IntPtr handle = Marshal.GetHINSTANCE(typeof(MyClass).Module);
这篇关于Visual Studio添加参考和GetModuleHandle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文