c# change framework error
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 to0yLjAuMC4w
at the end of the line (00
back to0y
)
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.
toosweetnitemare
Updated on June 04, 2022Comments
-
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 almost 13 yearsWhat version of Visual Studio are you using?
-
gdbdable about 12 yearsI 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 almost 13 yearsI still get the same error when i do that. Nothing seems to have changed in my code.
-
stuartd almost 13 yearsChange the Access Modifier or add a new value to force a regeneration
-
toosweetnitemare almost 13 yearsI 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 almost 13 yearsIm not seeing where i would make that change. Can you please be more specific?
-
R. Martinho Fernandes almost 13 yearsIn my case, clicking on the error brought me straight to that line. I just changed a
j00
toj0y
. -
toosweetnitemare almost 13 yearsthis 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 almost 13 yearsI have to run to a meeting. Ill be back in an hour. Thank you for all the help!
-
toosweetnitemare almost 13 yearsI added useLegacyV2RuntimeActivationPolicy="true to my startup folder but im still getting the error.
-
toosweetnitemare almost 13 yearsI 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 almost 13 yearsThank 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 almost 13 yearsI 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