当前位置: 代码迷 >> WinCE >> 急VS2005 开发WINCE 5.0程序PictureBox加载图片时错误
  详细解决方案

急VS2005 开发WINCE 5.0程序PictureBox加载图片时错误

热度:16   发布时间:2016-04-28 12:40:51.0
急!!VS2005 开发WINCE 5.0程序PictureBox加载图片时异常
如题:
我用VS2005 开发wince5.0下的应用程序,在程序窗口上加了一个PictureBox控件,通过pictureBox的Image属性选择了一张图片,图片可以显示,但在与设备连接进行调试时在执行到图片加载时就发生异常,

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
            this.pictureBox1 = new System.Windows.Forms.PictureBox();
            this.SuspendLayout();
            // 
            // pictureBox1
            // 
            this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));            this.pictureBox1.Location = new System.Drawing.Point(156, 188);
            this.pictureBox1.Name = "pictureBox1";
            this.pictureBox1.Size = new System.Drawing.Size(100, 50);

未处理 System.Exception
  Message="Exception"
  StackTrace:
    位于 Microsoft.AGL.Common.MISC.HandleAr()
    位于 System.Drawing.Bitmap._InitFromMemoryStream()
    位于 System.Drawing.Bitmap..ctor()
    位于 System.Reflection.RuntimeConstructorInfo.InternalInvoke()
    位于 System.Reflection.RuntimeConstructorInfo.Invoke()
    位于 System.Reflection.ConstructorInfo.Invoke()
    位于 System.Resources.ResourceReader.CreateResource()
    位于 System.Resources.ResourceReader.LoadBitmap()
    位于 System.Resources.ResourceReader.LoadObjectV2()
    位于 System.Resources.ResourceReader.LoadObject()
    位于 System.Resources.RuntimeResourceSet.GetObject()
    位于 System.Resources.ResourceManager.GetObject()
    位于 System.Resources.ResourceManager.GetObject()
    位于 Client.Form1.InitializeComponent()
    位于 Client.Form1..ctor()
    位于 Client.Program.Main()

------解决方案--------------------
你换一张小图片试一下,我估计是图片太大了!
------解决方案--------------------
应该是这句有问题:
 this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));  

CE下一定要使用全路径,因为CE没有当前目录的概念,所以和EXE放在同一目录下,也必须使用全路径。

pictureBox1.Image 的值现在无法看到是否正确!它是如何加载图片的?
  相关解决方案