C#更改框架错误

发布于 2024-11-07 06:06:20 字数 2016 浏览 2 评论 0原文

我正在运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

静赏你的温柔 2024-11-14 06:06:20

您可以尝试通过右键单击 .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

扶醉桌前 2024-11-14 06:06:20

我遇到了 Visual Studio bug 给我带来了类似的问题。我使用这个解决方法来解决它:

似乎有效的解决方法是
手动更改其中的一个字符
图像流每次
用户控件或表单在中编辑
设计师

<数据名称=“icons_20.ImageStream”mimetype=“application/x-microsoft.net.object.binary.base64”>
    <值>
     AAEAAAD/////AQAAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w

更改为

<预><代码> AAEAAAD/////AQAAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w

00LjAuMC4w 回到行尾的 0yLjAuMC4w (00
返回0y

但每次我以这种形式更改某些内容时,我都必须解决这个问题。

I ran into a Visual Studio bug that caused me a similar problem. I used this workaround to solve it:

A fix that SEEMS to work is to
manually alter one character in the
image stream EVERY TIME the
usercontrol or form is edited in the
designer

<data name="icons_20.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
    <value>
     AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w

Change to

     AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w

That is 00LjAuMC4w back to 0yLjAuMC4w at the end of the line (00
back to 0y)

But I have to fix that every time I change something in that form.

人间不值得 2024-11-14 06:06:20

不确定这一点,但由于其他答案没有帮助,请尝试这个。文件中的 Version=4.0.0.0 告诉编译器使用 .net 4.0 程序集。尝试将它们更改为 Version=3.5.0.0Version=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 to Version=3.5.0.0 or Version=2.0.0.0 and see if that solves it.

执笏见 2024-11-14 06:06:20

这个问题已经存在很长时间了,我对微软修复这个错误不再抱有希望。然后我开始使用手动编写的代码来处理资源中包含的图片:

string resource = "Company.Namespace.Resources.picture.gif";
pictureBox1.Image = new Bitmap(Assembly.GetExecutingAssembly()
.GetManifestResourceStream(resource));

不要忘记将 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:

string resource = "Company.Namespace.Resources.picture.gif";
pictureBox1.Image = new Bitmap(Assembly.GetExecutingAssembly()
.GetManifestResourceStream(resource));

Dot forget to set property "Build action" of picture.gif to "Embeded resource"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文