您的位置:首页 > 编程语言 > ASP

130道ASP.NET面试题(偏C#的ASP.NET面试题)(转)

2011-09-28 18:39 429 查看
我就直接上内容了。虽然能看懂,知道原理。但是自己还是无法独立写出来。看来还需要多学习啊。。

原文地址,程序我自己重新做了一遍

首先,你需要一个解决方案,并且包含已经引用的第三方的dll




2.打开Properties下的Resources,将需要包含的dll添加进去










3.在Form1.cs中添加代码
public Form1() {
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
InitializeComponent();
}
private 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);
}


4.重新生成解决方案即可,然后你可以在bin文件夹中找到已经嵌入dll的exe
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: