Leo*_*rdo 16 c# visual-studio-2010 .net-2.0 windows-8
我在Windows窗体应用程序项目上收到FileNotFoundException,并显示以下消息:
Run Code Online (Sandbox Code Playgroud)Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
要复制问题:
当我这样做时,程序在行this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
上停止,但有以下异常:
System.IO.FileNotFoundException was unhandled
Message=Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Source=mscorlib
FileName=System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Run Code Online (Sandbox Code Playgroud)
我在最近安装在Windows 8开发人员预览版上的Visual Studio 2010 SP1上得到了这个.如果我将项目属性更改为目标.Net Framework 4,则错误消失.
在Form1.resx文件中,我可以看到System.Drawing程序集的版本明确声明为2.0:
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
小智 9
这是一个错误.我也看过了.这是因为您的.resx文件指向System.Drawing的4.0.0.0版本,其中一个不存在.为了解决这个问题,我通常在记事本中编辑.resx,将4.0.0.0更改为2.0.0.0.通过遵循您概述的确切步骤来引入该错误.
我找到了一个可能的解决方案,请试试这个:
在设计器中打开 resx 文件并将 accessmodifier 从 public 设置为 no code generation。
编辑:有一个解决方法,但很烦人。
**注意:唯一的区别是“j00LjAuMC4w”到“j0yLjAuMC4w”结尾的字符。每次在设计器模式下打开表单时都需要执行此操作。
微软表示他们将在下一个 VS 版本中修复它......
来源:http : //connect.microsoft.com/VisualStudio/feedback/details/532584/error-when-compiling-resx-file-seems-related-to-beta2-bug-5252020
如果.net 4.5预览resgen用于创建资源文件,则可能会出现此问题.
我的笔记本电脑上存在同样的问题(Windows 7,VS2010 Premium,VS11开发人员预览版).当我在表单上说'localizable = true'时,我遇到了一个简单的表单项目的问题.在我的情况下,没有涉及图像数据.该项目设置为.net 3.5
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.SuspendLayout();
//
// Form1
//
resources.ApplyResources(this, "$this"); //exception Could not load file or assembly 'System.Drawing, Version=4.0.0.0,
Run Code Online (Sandbox Code Playgroud)
如果我然后将此项目复制到另一台计算机(Windows 7,VS2010 Premium)并尝试调试它,则错误仍然存在.如果我清理解决方案(而不是项目)(或删除bin/obj手动)错误消失了如果我然后将此解决方案复制回我的笔记本电脑,错误消失了,但我无法再在设计视图中看到该表单'Error message: at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)'
所有这些的原因似乎是*.Designer.cs文件中的.net版本.
任何人都可以告诉我在哪里可以配置处理.net 3.5项目时使用哪个resgen版本?
归档时间: |
|
查看次数: |
36748 次 |
最近记录: |