[英]How do I use an unregistered dll from c#?
I have a custom dll (not registered) that I need to access via c#. 我有一个我需要通过c#访问的自定义DLL(未注册)。 How do I do this without registering the DLL?
如何在不注册DLL的情况下执行此操作?
Edit: It is a C++ dll. 编辑:这是一个C ++ DLL。
See Registration-Free COM Interop : 请参阅免注册COM互操作 :
Registration-free COM interop activates a component without using the Windows registry to store assembly information.
免注册COM互操作激活组件而不使用Windows注册表来存储程序集信息。 Instead of registering a component on a computer during deployment, you create Win32-style manifest files at design time that contain information about binding and activation.
您可以在设计时创建包含绑定和激活信息的Win32样式清单文件,而不是在部署期间在计算机上注册组件。 These manifest files, rather than registry keys, direct the activation of an object.
这些清单文件而不是注册表项指示对象的激活。
Using registration-free activation for your assemblies instead of registering them during deployment offers two advantages:
对程序集使用免注册激活而不是在部署期间注册它们有两个好处:
- You can control which DLL version is activated when more than one version is installed on a computer.
您可以控制在计算机上安装多个版本时激活的DLL版本。
- End users can use XCOPY or FTP to copy your application to an appropriate directory on their computer.
最终用户可以使用XCOPY或FTP将您的应用程序复制到其计算机上的相应目录中。 The application can then be run from that directory.
然后可以从该目录运行该应用程序。
I assume you want to use the functions exported from this dll via P/Invoke? 我假设你想通过P / Invoke使用从这个dll导出的函数? If so, you only need to copy the dll to the same folder as your exe file.
如果是这样,您只需要将dll复制到与exe文件相同的文件夹中。 Then write C# declarations for the functions in the C++ dll that you want to use.
然后为要使用的C ++ DLL中的函数编写C#声明。 See DllImportAttribute .
请参阅DllImportAttribute 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.