在软件c#中集成Dll [英] Integerate Dll in software c#

查看:122
本文介绍了在软件c#中集成Dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在软件exe中集成dll,如(Interop.JRO.dll)等。我正在使用Windows表格c#。在此先感谢。

how to integrate dll's such as (Interop.JRO.dll) etc in the software exe. i am using windows form c#. Thanks in advance.

推荐答案

我猜你想将eyour应用程序分发为单个.exe并从嵌入式资源加载所有dll。



如果是这种情况你需要:

1)将dll添加到项目中(Project / Add Existing Item ..)

2 )更改添加的dll属性:

•BuildAction =嵌入式资源

•复制到输出目录=不要复制



然后在你的代码中你需要编写AppDomain.CurrentDomain.AssemblyResolve事件处理程序(每当需要加载程序集时都会调用它)。

在处理程序中你需要从资源加载程序集: br $>


I'm guessing you want to distribut eyour application as single .exe and load all dlls from embedded resource.

If that's the case you need to:
1) add dll to the project (Project/Add Existing Item..)
2) change added dll properties:
• BuildAction = embedded Resource
• Copy To Output Directory = Do not copy

Then in your code you need to code AppDomain.CurrentDomain.AssemblyResolve event handler (this will be called whenever assembly needs to be loaded).
In the handler you need to load assembly from resources:

var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourcename);
byte[] assemblyData = stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData).


在编码时添加引用您编写的代码然后准备构建。
while you are coding add referece of the dll to you code and then prepare the build.


这篇关于在软件c#中集成Dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆