GetManifestResourceStream得到的Stream是null的解决

GetManifestResourceStream得到的Stream是null的解决

Ans: 参考

http://blog.csdn.net/blue_sky_blue_heart/archive/2005/12/17/555139.aspx

System.Reflection.Assembly asm = System.Reflection.Assembly.GetExecutingAssembly();
// Note that the name for the embedded resource is case sensitive and must match the file name.
Bitmap bmp = new Bitmap(asm.GetManifestResourceStream(asm.GetName().Name + "." + "pic.png"));
e.Graphics.DrawImage(bmp, 5, 8, new Rectangle(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel);

其实最主要的是在将图片资源的属性设置为“嵌入的资源”:“属性-生成操作-嵌入的资源”

注意GetManifestResourceStream函数的参数:asm.GetName().Name获得的只是当前命名空间的名称,如果在“pic.png”图片在当前工程的Photo目录下,那么该参数就该写成asm.GetName().Name + "." + "Photo" + "." + " pic.png"

时间: 2024-08-01 20:02:36

GetManifestResourceStream得到的Stream是null的解决的相关文章

java--struts--result is null的解决办法

一般情况下如果出现连续跳转的时候,经常会出现result is null的问题,这主要是由于action的type默认类型redirect导致的, 我们只需要在出错的action中指定type="chain"即可. 例如: (一般写法:用于同一命名空间的action之间跳转时) <span style="font-size:18px;"> <!-- 跳转到命名空间/admin --> <action name="toAdmin

The given object has a null identifier解决之法

<input type="hidden" name="memberPermission.id"????????????value="${memberpermission.id}"> <input type="hidden"????????????name="memberPermission.mtid" value="${memberpermission.mtid}"&g

storm运行异常之No output fields defined for component:stream XxxBolt:null

错误log: 2015-01-05 17:22:49 [Thread-38-log] ERROR backtype.storm.daemon.executor - java.lang.RuntimeException: java.lang.IllegalArgumentException: No output fields defined for component:stream XxxBolt:null at backtype.storm.utils.DisruptorQueue.consum

Type.GetType()在跨程序集反射时返回null的解决方法

在开发中,经常会遇到这种情况,在程序集A.dll中需要反射程序集B.dll中的类型.如果使用稍有不慎,就会产生运行时错误.例如使用Type.GetType("BNameSpace.ClassName")在程序集A.dll获取程序集B.dll中的类型,就会返回Null. 关于跨程序集的反射,有两点需要注意: 1.如果使用typeof,编译能通过,则跨程序集的反射一定可以正常运行.可以说,typeof是支持强类型的.比如 1 Type supType = typeof(BNameSpace

使用Ef查询出现的问题The cast to value type &#39;System.Boolean&#39; failed because the materialized value is null.的解决方法

把值类型的系统.布尔的失败是因为物化值是null.结果类型的泛型参数或查询必须使用可空类型. 解决方法: 请确保你查询中的字段值不为空或者做为空判断 使用Ef查询出现的问题The cast to value type 'System.Boolean' failed because the materialized value is null.的解决方法

将Excel导入SQL Server 只能导入数字,其他数据变为NULL怎么解决?

先新建一个TXT文件,把数据粘贴进去 再新建一个Excel文件,在菜单栏中选Data再选From Text 找到txt文件,点import 一定要选Text 点Finish,点OK. 接下来在往数据库中导入 打开SQL Server Management Studio 在需要导入数据的数据库名上点击鼠标右键选Task,选Import Date 点Next Data Soure选Microsoft Excel file path选你的Excel文件 点Next Authentication中选Us

TypeError: Cannot red property &#39;style&#39; of null 错误解决

错误信息如下: JSP代码如下: <c:if test ="${not empty excelErrors}"> <div id="excelErrorDiv" class="acxiom-content-container closed rounded vpad top-buffer" style="width:90%;margin-left:5%;"> <div class="acx

storm运行异常之No output fields defined for component:stream XxxBolt:null疑案追踪

前言 上一篇写了 storm运行异常之No output fields defined for component:stream XxxBolt:null 发现是多线程导致的,但是也有可能是其他原因,今天就来追踪一下. 反查蛛丝马迹 错误log: Caused by: java.lang.IllegalArgumentException: No output fields defined for component:stream XxxBolt:null at backtype.storm.ta

can&#39;t cast jsonnull to string null 的解决

今天写代码的时候要完成接收json数据转换成map对的功能 传进来的是 {appIntroduction=null, appScene=null, appId="123", callbackurl="http://zdwssq.picp.net/QiWei/userInfo?corpId=$CORPID$", appName="新的3", appLogoname="6d5e965c-80af-4782-9bca-af914099043d