C# RegAsm.exe 和 regsvr32 有什么区别?如何使用 regsvr32 生成 tlb 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1163503/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 09:43:15  来源:igfitidea点击:

What is difference between RegAsm.exe and regsvr32? How to generate a tlb file using regsvr32?

c#c++visual-c++comregasm

提问by Cute

Can any body tell me what is the difference between regsvr32 and RegAsm? My Dll is in C#, so how can I import the classes to c++?

任何人都可以告诉我 regsvr32 和 RegAsm 之间有什么区别?我的 Dll 在 C# 中,那么如何将类导入到 C++ 中?

采纳答案by sharptooth

regsvr32will load the library and try to call the DllRegisterServer()from that library. It doesn't care what DllRegisterServer()actually does - it just calls that function and checks the returned value. You use it to register COM servers in unmanaged DLLs. It can't generate a .tlb file.

regsvr32将加载库并尝试DllRegisterServer()从该库调用。它并不关心DllRegisterServer()实际做了什么——它只是调用该函数并检查返回值。您可以使用它在非托管 DLL 中注册 COM 服务器。它无法生成 .tlb 文件。

regasmwill register a COM-exposed .NET assembly as a COM server. You use it for .NET assemblies. It can generate a .tlb file given the assembly only - it inspects the type infromation stored in the assembly and includes the COM-exposed entities into the type library.

regasm将公开 COM 的 .NET 程序集注册为 COM 服务器。您将其用于 .NET 程序集。它可以仅在给定程序集的情况下生成 .tlb 文件 - 它检查存储在程序集中的类型信息并将 COM 公开的实体包含到类型库中。