c# - 将所有 DLL 嵌入 win app 和 C#

标签 c# dll embed exe

我使用此代码将所有 dll 嵌入应用程序 exe 文件,但此代码只能嵌入一个 dll。我搜索其他代码,但都一样。

public App()
{
    AppDomain.CurrentDomain.AssemblyResolve +=new ResolveEventHandler(CurrentDomain_AssemblyResolve);
}

System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
    string dllName = args.Name.Contains(',') ? args.Name.Substring(0, args.Name.IndexOf(',')) : args.Name.Replace(".dll","");

    dllName = dllName.Replace(".", "_");

    if (dllName.EndsWith("_resources")) return null;

    System.Resources.ResourceManager rm = new System.Resources.ResourceManager(GetType().Namespace + ".Properties.Resources", System.Reflection.Assembly.GetExecutingAssembly());

    byte[] bytes = (byte[])rm.GetObject(dllName);

    return System.Reflection.Assembly.Load(bytes);
}

要使用 ILmerge,我的 dll 有问题。所以我不能用这个。 我怎样才能做到这一点?

最佳答案

这个开源工具应该能帮到你

http://madebits.com/netz/

关于c# - 将所有 DLL 嵌入 win app 和 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12225976/

相关文章:

visual-studio-2010 - Visual Studio 2010 无法启动 - 缺少 ATL100.dll

c++ - 将 .dll 导入 Qt

Delphi插件框架

Python - C 嵌入式段错误

iframe - 将youtube视频播放列表嵌入ebay不能使用iframe或<object?

c# - 我应该定义自定义枚举器还是使用内置枚举器?

c# - 自托管 C# SSL Web 服务器,无需管理员权限

c# - 中继命令上的 CanExecute 不起作用

php - 将YouTube channel 嵌入网站

c# - 调试帮助 - 在 Debug模式下设置一个值?