c# change framework error

13,473

Solution 1

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

Solution 2

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.

Solution 3

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.

Share:
13,473
toosweetnitemare
Author by

toosweetnitemare

Updated on June 04, 2022

Comments

  • toosweetnitemare
    toosweetnitemare almost 2 years

    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?

    • R. Martinho Fernandes
      R. Martinho Fernandes almost 13 years
      What version of Visual Studio are you using?
    • gdbdable
      gdbdable about 12 years
      I have some bug, but project initialy created for .net 2.0 Before it works, but after some visual studio updates it breaks. Is System.Drawing 4.0 exists?
  • toosweetnitemare
    toosweetnitemare almost 13 years
    I still get the same error when i do that. Nothing seems to have changed in my code.
  • stuartd
    stuartd almost 13 years
    Change the Access Modifier or add a new value to force a regeneration
  • toosweetnitemare
    toosweetnitemare almost 13 years
    I went into the resrouces.resx file and changed the access modifier from internal to public and pressed F5. Then i tried to run the custom tool again. No luck
  • toosweetnitemare
    toosweetnitemare almost 13 years
    Im not seeing where i would make that change. Can you please be more specific?
  • R. Martinho Fernandes
    R. Martinho Fernandes almost 13 years
    In my case, clicking on the error brought me straight to that line. I just changed a j00 to j0y.
  • toosweetnitemare
    toosweetnitemare almost 13 years
    this is where the error brings me "<value>..\malware2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>"
  • toosweetnitemare
    toosweetnitemare almost 13 years
    I have to run to a meeting. Ill be back in an hour. Thank you for all the help!
  • toosweetnitemare
    toosweetnitemare almost 13 years
    I added useLegacyV2RuntimeActivationPolicy="true to my startup folder but im still getting the error.
  • toosweetnitemare
    toosweetnitemare almost 13 years
    I solved the issue. Had to change all Version=4.0.0.0 to Version=2.0.0.0 and added useLegacyV2RuntimeActivationPolicy="true to my startup
  • toosweetnitemare
    toosweetnitemare almost 13 years
    Thank you. I solved the issue. Had to change all Version=4.0.0.0 to Version=2.0.0.0 and added useLegacyV2RuntimeActivationPolicy="true to my startup
  • toosweetnitemare
    toosweetnitemare almost 13 years
    I solved the issue. Had to change all Version=4.0.0.0 to Version=2.0.0.0 and added useLegacyV2RuntimeActivationPolicy="true to my startup