C#更改框架错误
我正在运行 Visual Studio 2010。 我只是将项目的框架从 4.0 更改为 3.5。我删除了它要求我删除的引用 Microsoft.Framework,然后尝试编译。我现在收到错误:
错误 1 无法加载文件或 装配'系统.绘图, 版本=4.0.0.0,文化=中立, PublicKeyToken=b03f5f7f11d50a3a' 或 它的依赖项之一。系统 找不到指定的文件。线 123、位置 5.C:\Users\\Documents\Visual Studio 2010\Projects\\\属性\Resources.resx 123 5
我知道它引用了我的 resources.resx 文件中的代码:
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="pix-300x300" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix-300x300.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pix2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pix4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix4.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pix3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix3.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
既然我的框架是 3.5,我将如何纠正这个问题?
I am running Visual Studio 2010.
I just change the frame work of my project from 4.0 to 3.5. I removed the reference Microsoft.Framework that it asked me to remove then tried to compile. I now get the error:
Error 1 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. Line
123, position
5. C:\Users\\Documents\Visual Studio
2010\Projects\\\Properties\Resources.resx 123 5
I know that it is referring to code in my resources.resx file:
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="pix-300x300" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix-300x300.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pix2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pix4" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix4.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pix3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\pix3.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
How would i correct this now that my framework is 3.5?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以尝试通过右键单击 .resx 文件并从上下文菜单中选择“运行自定义工具”来重新生成文件。
编辑:在执行此操作之前,请更改访问修饰符或添加新值以强制重新生成。
另一项编辑:请参阅将应用程序降级.net 4.0 到 3.5 另一种可能性
You can try regenerating the file by right-clicking the .resx file and choosing 'Run Custom Tool' from the context menu.
Edit: before you do this, change the Access Modifier or add a new value to force a regeneration.
Another edit: See Downgrade an application from .net 4.0 to 3.5 for another possibility
我遇到了 Visual Studio bug 给我带来了类似的问题。我使用这个解决方法来解决它:
但每次我以这种形式更改某些内容时,我都必须解决这个问题。
I ran into a Visual Studio bug that caused me a similar problem. I used this workaround to solve it:
But I have to fix that every time I change something in that form.
不确定这一点,但由于其他答案没有帮助,请尝试这个。文件中的
Version=4.0.0.0
告诉编译器使用 .net 4.0 程序集。尝试将它们更改为Version=3.5.0.0
或Version=2.0.0.0
并查看是否可以解决问题。Not sure about this, but since the other answers didn't help, try this. The
Version=4.0.0.0
in your file is telling the compiler to use .net 4.0 assemblies. Try changing them toVersion=3.5.0.0
orVersion=2.0.0.0
and see if that solves it.这个问题已经存在很长时间了,我对微软修复这个错误不再抱有希望。然后我开始使用手动编写的代码来处理资源中包含的图片:
不要忘记将 picture.gif 的属性“构建操作”设置为“嵌入资源”
Having this problem for a long time, i lost hope that microsoft fix this bug ever. Then i begin use manual written code for handle pictures contains in resources:
Dot forget to set property "Build action" of picture.gif to "Embeded resource"