- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将图像添加到我的项目资源 (Windows Mobile 6.1)。我想使用此图像来设置我在表单中拥有的某些 PictureBoxes 的 PictureBox.Image 属性。我尝试以下代码:
pictureBox1.Image = Properties.Resources.my_image;
pictureBox2.Image = Properties.Resources.my_image;
pictureBox3.Image = Properties.Resources.my_image;
...
pictureBoxN.Image = Properties.Resources.my_image;
问题是有时图像只显示在某些 PictureBox 中(当我尝试设置图像时出现 TargetInvocationException
),而不是全部显示。为什么?我该如何解决这个问题?
编辑:
InnerException 的 StackTrace:
in Microsoft.AGL.Common.MISC.HandleAr(PAL_ERROR ar) in System.Drawing.Bitmap._InitFromMemoryStream(MemoryStream mstream) in System.Drawing.Bitmap..ctor(Stream stream) in System.Reflection.RuntimeConstructorInfo.InternalInvoke(RuntimeConstructorInfo rtci, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark) in System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) in System.Reflection.ConstructorInfo.Invoke(Object[] parameters) in System.Resources.ResourceReader.CreateResource(Type objType, Type[] ctorParamTypes, Object[] ctorParameters) in System.Resources.ResourceReader.LoadBitmap(Int32 typeIndex) in System.Resources.ResourceReader.LoadObjectV2(Int32 pos, ResourceTypeCode& typeCode) in System.Resources.ResourceReader.LoadObject(Int32 pos, ResourceTypeCode& typeCode) in System.Resources.RuntimeResourceSet.GetObject(String key, Boolean ignoreCase) in System.Resources.ResourceManager.GetObject(String name, CultureInfo culture) in Icons_Control.Properties.Resources.get_glass_empty() in Icons_Control.ListItem.set_CompletitionStatus(eCompletionStatus value) in Icons_Control.ListItem..ctor() in Icons_Control.ListItem..ctor(eItemType type) in Icons_Control.MainForm.menuItem3_Click(Object sender, EventArgs e) in System.Windows.Forms.MenuItem.OnClick(EventArgs e) in System.Windows.Forms.Menu.ProcessMnuProc(Control ctlThis, WM wm, Int32 wParam, Int32 lParam) in System.Windows.Forms.Form.WnProc(WM wm, Int32 wParam, Int32 lParam) in System.Windows.Forms.Control._InternalWnProc(WM wm, Int32 wParam, Int32 lParam) in Microsoft.AGL.Forms.EVL.EnterMainLoop(IntPtr hwnMain) in System.Windows.Forms.Application.Run(Form fm) in Icons_Control.Program.Main()
最佳答案
我的猜测是您的内存或其他资源不足。图片资源有点危险。每次获得资源时,都会创建一个新资源。您可能只想创建一个 my_image 实例,并且可能希望在使用完它后将其丢弃。
Image myImage = Properties.Resources.my_image;
pictureBox1.Image = myImage;
pictureBox2.Image = myImage;
pictureBox3.Image = myImage;
pictureBox4.Image = myImage;
...
pictureBoxN.Image = myImage;
// Later on when you are done using it
myImage.Dispose();
对于大多数 CF 应用来说,不要浪费内存非常重要。
关于c# - 使用我的资源图像 - Compact Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14256486/
随着我们的应用程序的增长,我们需要更多的 Windows CE 设备空间。 我们安装了 SD 卡。从 sd 卡运行我们的应用程序很慢,如果您从持久路径运行应用程序,则需求分页会出现一些严重的问题。 我
是否可以在数据网格单元格中显示图像? 我目前正在使用紧凑型框架 3.5。 有什么建议吗? 最佳答案 就像其他海报评论的那样,你需要自己动手。幸运的是,这并不太难。 在我的应用程序中,我需要一种在特定列
我读了这个问题:Command Line Parser for .NET . 我以为这就是我要找的,但图书馆 Command Line Parser Library不是 Compact 框架友好的..
我用过 CF Remote Performance Monitor ,但是这似乎只跟踪在托管世界中初始化的内存,而不是在非托管世界中。好吧,我只能假设这是因为探查器中列出的数字远低于允许的最大值(CE
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 8年前关闭。 Improve thi
当我将字符串绘制到缓冲区中时,结果输出并没有像我期望的那样抗锯齿。这段代码说明了这个问题……只需将它放在标准智能设备项目的 Form1.cs 中: protected override void On
一位 friend 正在做在线 Scala 类(class)并分享了此内容。 # Write a recursive function that counts how many different w
如何仅使用紧凑型框架获取 MAC 地址? 最佳答案 OpenNETCF 代码的 1.4 从以下 P/Invoke 调用中获取信息: [DllImport ("iphlpapi.dll", Se
System.Diagnostics命名空间(尤其是 GetFrame(int frameNumber))在 CF 中不可用。在 CE (6.0 R3) 上运行时如何获取调用堆栈详细信息? 谢谢! 最
使用 .net Compact Framework 编写的应用程序可以自行重启吗? 实现这一目标的一些常见模式是什么?我想要一个自我更新的应用程序,如果更新完成,它会自行重启。 当然,我可以有 2 个
在 Compact Framework 上, System.Windows.Forms.Timer 类不支持 system.componentmodel 构造函数: 支持新的 Timer():http
在我的 Windows CE 6.0 应用程序中,我正在与返回错误 header 信息的专有 Web 服务器设备通信(更具体地说,它没有返回任何 header 信息)。 我认为缺少 header 信息
我只通过使用 Compact Any Size Classes .. 它可以在各种类型的手机上完美运行。 但 XCode Storyboard更喜欢对所有 iphone 纵向模式使用紧凑的常规尺寸类。
我目前正在将我的 Compact Framework 2.0 应用程序迁移到新的 Windows Embedded 7 Compact 机器上,并且必须为 CF 3.5 重新编译它。它编译但根本不运行
我有以下要求: 我需要一个适用于 CE (x86) + .NET Compact Framework 的 API 来播放视频(类似于 CorePlayer API...只是免费)? 还有其他可用的吗?
我正在使用 VS2008 和 .NET Compact Framework 3.5 构建一个可执行文件,目标是 Windows Mobile 6 Professional,但是每当我编译项目时,我在
尝试在我的新 PC 上的 Visual Studio 中构建 .CAB 时出现以下错误。来源是相同的。旧 PC 上也不存在注册表警告。 Windows CE CAB Wizard Warning: S
我正在尝试使用 Bouncy Castle v1.7在 Windows Mobile 6.5 设备上。 我正在尝试执行以下代码: ISigner signer = SignerUtilities.Ge
当我使用取消按钮关闭程序时,我收到一个应用程序错误,它所做的只是关闭表单。 错误说: “应用程序 appName.exe 遇到严重错误,必须关闭” 我该如何开始修复它?它不是抛出的异常;没有提供其他信
我知道 compact() 是一个标准的 php 函数。而 set() 是一种特定于蛋糕的方法。 我正在运行一个简单的测试,将值传递给使用 ajax 生成的 View (我的 Controller 中
我是一名优秀的程序员,十分优秀!