用C#工程 编译生成的 dll 怎么包含图片啊(如gif图片)? 用C#工程 编译生成的 dll 怎么包含图片啊(如gif图片)? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public class Class1 { public Class1() { // // TODO: 在此加入建構函式的程式碼 // this.GetType().Assembly.GetManifestResourceStream( "TryDllWithPicture.background.JPG" ); } public System.IO.Stream ReturnStream() { return this.GetType().Assembly.GetManifestResourceStream( "TryDllWithPicture.background.JPG" ); } }其中編譯時,background.JPG要為內嵌資源。然後在你要調用的程序中寫如下代碼:private void Form1_Load(object sender, System.EventArgs e) { TryDllWithPicture.Class1 ttt = new Class1(); pictureBox1.Image = Image.FromStream( ttt.ReturnStream() ); } 好人 解释 一下 这是 什么意思啊??说的具体一点。。呵呵。。System.Reflection.Assembly myAssembly;myAssembly = System.Reflection.Assembly.Load("<程序集名>");// Creates the ResourceManager.System.Resources.ResourceManager myManager = new System.Resources.ResourceManager("<资源的命名空间>.<资源根名>", myAssembly);// Retrieves String and Image resources.System.String myString;System.Drawing.Image myImage;myString = myManager.GetString("<字符串资源名>");myImage = (System.Drawing.Image)myManager.GetObject("<图像资源名>"); 利用Reflection(反射)機制來實現資源的動態綁定,關於Reflection不是一兩句能說明白的,還是先先這方面的書吧,你的問題用內嵌資源就可以很好的解決,可以不用到反射的,我上面寫的程序已經測試過了,沒問題的。 在你的解决方案浏览器(solution explorer)选中你要包含到最后生成的.ll中去的图片,如myPic.gif ,然后在其属性窗口(Properties),修改"生成方式"(Build Action)为"嵌入资源"(Embeded Resource),然后BUILD即可 多谢 mysterious(空折枝) 好心人啊。 2个变量交换位置的问题 C# rdlc报表动态绑定泛型集合 asp.net iframe想要后台调用父母窗体的后台方法 正则表达式匹配{"message":"操作成功","balance":[110,0],"msgcode":1} 校园网不稳定,想编写一个软件来优化它,该如何实现. 如何有效组织团队合作开发项目 rsa中的编码问题 C# 使用oracle绑定变量后,查询效率变慢如何解决?满意可加分 “十分”求教:如何去掉数据库数据的空格。 C# Winfrom 多个Form窗体之间切换过程中实现过渡效果 简单提问=直接送分 键盘问题急急急!
{
public Class1()
{
//
// TODO: 在此加入建構函式的程式碼
//
this.GetType().Assembly.GetManifestResourceStream( "TryDllWithPicture.background.JPG" );
} public System.IO.Stream ReturnStream()
{
return this.GetType().Assembly.GetManifestResourceStream( "TryDllWithPicture.background.JPG" );
}
}其中編譯時,background.JPG要為內嵌資源。然後在你要調用的程序中寫如下代碼:
private void Form1_Load(object sender, System.EventArgs e)
{
TryDllWithPicture.Class1 ttt = new Class1();
pictureBox1.Image = Image.FromStream( ttt.ReturnStream() );
}
说的具体一点。。呵呵。。
System.Reflection.Assembly myAssembly;myAssembly = System.Reflection.Assembly.Load("<程序集名>");// Creates the ResourceManager.
System.Resources.ResourceManager myManager = new
System.Resources.ResourceManager("<资源的命名空间>.<资源根名>",
myAssembly);// Retrieves String and Image resources.
System.String myString;
System.Drawing.Image myImage;
myString = myManager.GetString("<字符串资源名>");
myImage = (System.Drawing.Image)myManager.GetObject("<图像资源名>");