我使用此代码将所有 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 有问题。所以我不能用这个。 我怎样才能做到这一点?
最佳答案
这个开源工具应该能帮到你
关于c# - 将所有 DLL 嵌入 win app 和 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12225976/