What is, or should I ask, is there, an equivalent to DllMain when creating a DLL using C++/CLI?
在使用C ++ / CLI创建DLL时,是什么,或者我应该问,是否等同于DllMain?
Are there any restrictions on what cannot be called from this initialization code?
对这个初始化代码无法调用的内容有任何限制吗?
4 个解决方案
#1
4
Dan: With respect to the loader lock, C++/CLI's delay load of the CLR and proper initialization for a mixed mode binary, I just posted yesterday on the subject here.
Dan:关于加载程序锁定,C ++ / CLI的CLR延迟加载以及混合模式二进制文件的正确初始化,我刚刚在这里发布了主题。
More or less, if you have a mixed mode binary, you must not cause any managed code to run while you are in DllMain()
.
或多或少,如果您有混合模式二进制文件,则在DllMain()中时不得运行任何托管代码。
#2
3
Since .NET 2.0 you have a "module initializer". See here for more information on how that solves the loader lock problem and also here
从.NET 2.0开始,您就拥有了“模块初始化程序”。有关如何解决装载机锁定问题以及此处的更多信息,请参见此处
For a direct answer to your question, this page quotes the standard which says: "There are no limitations on what code is permitted in a module initializer. Module initializers are permitted to run and call both managed and unmanaged code."
为了直接回答您的问题,本页引用标准说:“对模块初始化程序中允许的代码没有限制。允许模块初始化程序运行并调用托管代码和非托管代码。”
#3
1
If you're using the dll in another managed project (a c# application for example), you don't need to do anything... As long as the classes you try to access are ref
classes, you can access them from any other managed application.
如果您在另一个托管项目(例如ac#应用程序)中使用dll,则不需要执行任何操作...只要您尝试访问的类是ref类,就可以从任何其他类访问它们托管申请。
#4
0
One giant advantage of .Net dlls is that they avoid the loader lock. One side effect is that there's no DllMain.
.Net dll的一个巨大优势是它们可以避免加载器锁定。一个副作用是没有DllMain。
#1
4
Dan: With respect to the loader lock, C++/CLI's delay load of the CLR and proper initialization for a mixed mode binary, I just posted yesterday on the subject here.
Dan:关于加载程序锁定,C ++ / CLI的CLR延迟加载以及混合模式二进制文件的正确初始化,我刚刚在这里发布了主题。
More or less, if you have a mixed mode binary, you must not cause any managed code to run while you are in DllMain()
.
或多或少,如果您有混合模式二进制文件,则在DllMain()中时不得运行任何托管代码。
#2
3
Since .NET 2.0 you have a "module initializer". See here for more information on how that solves the loader lock problem and also here
从.NET 2.0开始,您就拥有了“模块初始化程序”。有关如何解决装载机锁定问题以及此处的更多信息,请参见此处
For a direct answer to your question, this page quotes the standard which says: "There are no limitations on what code is permitted in a module initializer. Module initializers are permitted to run and call both managed and unmanaged code."
为了直接回答您的问题,本页引用标准说:“对模块初始化程序中允许的代码没有限制。允许模块初始化程序运行并调用托管代码和非托管代码。”
#3
1
If you're using the dll in another managed project (a c# application for example), you don't need to do anything... As long as the classes you try to access are ref
classes, you can access them from any other managed application.
如果您在另一个托管项目(例如ac#应用程序)中使用dll,则不需要执行任何操作...只要您尝试访问的类是ref类,就可以从任何其他类访问它们托管申请。
#4
0
One giant advantage of .Net dlls is that they avoid the loader lock. One side effect is that there's no DllMain.
.Net dll的一个巨大优势是它们可以避免加载器锁定。一个副作用是没有DllMain。