VB.NET 怎么将dll嵌入exe文件?找到的代码都是C#的,转换后到VB里就出错了
http://adamthetech.com/2011/06/embed-dll-files-within-an-exe-c-sharp-winforms/看这个在C#中...
http://adamthetech.com/2011/06/embed-dll-files-within-an-exe-c-sharp-winforms/
看这个在C#中测试,成功
然后到VB里尝试转换,到最后的
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
string resourceName = new AssemblyName(args.Name).Name + ".dll";
string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
就不知道添加到哪了 展开
看这个在C#中测试,成功
然后到VB里尝试转换,到最后的
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
{
string resourceName = new AssemblyName(args.Name).Name + ".dll";
string resource = Array.Find(this.GetType().Assembly.GetManifestResourceNames(), element => element.EndsWith(resourceName));
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource))
{
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
};
就不知道添加到哪了 展开
1个回答
展开全部
把C#的版本运行测试通过
转换成vb.net的代码贴出来帮你看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询