VS 2010 beta 2 - problems downgrading an application to use .Net 3.5
-
martes, 08 de diciembre de 2009 6:05I have a simple application that stores settings using My.Settings. When built using .Net 4.0, it works fine. If I change to build with .Net 3.5 Client (or just .Net 3.5) I get an error 'An error occurred creating the configuration section handler for userSettings/My_Application.My.MySettings: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089''.
How can I build an application for PC's that do not have .Net 4.0.- Cambiado Karel ZikmundMicrosoft Employee martes, 22 de diciembre de 2009 18:45 VB project issue (From:.NET Framework 4 Beta 2 – General)
Todas las respuestas
-
martes, 08 de diciembre de 2009 22:501) Check your config file for System (4.0.0.0).
2) What type of project do you have? (C#/VB/ASP.NET)
3) Where does the error come from? From application run?
4) Did you rebuild the application before you ran it against 3.5?
5) Do you have a simple code example which shows the error? (If yes post it here - make it as small as possible)
6) Check your References - what version has System(.dll) reference in Properties window?
-Karel -
miércoles, 09 de diciembre de 2009 0:061) The config file does have system, Version=4.0.0.0 (see below)
2) Project is VB
3) Error is from the app run (at startup, as it is trying to load settings)
4) App was cleaned and rebuilt -- no difference.
5) no sample -- though I could write one quickly. Build an app using .Net 4.0. During MyForm_Load include MyVariable = My.Settings.MySetting. Change app to use .net 3.5. Clean and run. My.Settings get will throw an error.
6) Looking at references, changing from .Net 4.0 to .Net 3.5 changes System reference properties.
The problem seems to be that changing .Net versions is not reflected properly in app.config.
app.config for system under .net 4.0. Note reference to System, Version=4.0.0.0
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="FOW_Terrain.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<userSettings>
<FOW_Terrain.My.MySettings>
<setting name="Table" serializeAs="String">
<value>Pick a Table Size</value>
</setting>
<setting name="Terrain" serializeAs="String">
<value>Pick a terrain Type</value>
</setting>
</FOW_Terrain.My.MySettings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
app.config after changing to .Net 3.5. Note version of System has not been changed.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="FOW_Terrain.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<userSettings>
<FOW_Terrain.My.MySettings>
<setting name="Table" serializeAs="String">
<value>Pick a Table Size</value>
</setting>
<setting name="Terrain" serializeAs="String">
<value>Pick a terrain Type</value>
</setting>
</FOW_Terrain.My.MySettings>
</userSettings>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration> -
viernes, 14 de mayo de 2010 23:06I had the same problem with a C# project (ie on downgrading to target 3.5, with the real VS 2010 release). The solution is to manually alter app.config, so that the relevant elements have Version=2.0.0.0
-
domingo, 23 de mayo de 2010 13:24I have the same problem。
-
martes, 13 de julio de 2010 15:36
Any other ideas? I have exactly the same issue on the released premium edition. Changing the elements of the app.config to version 2 made no difference. Likewise with excluding the app.config file from the project altogether. In the fusion log it binds successfully to system version 2.0.0.0 but then goes on to try bind to system version 4.0.0.0 and fails. Not sure why it is looking for version 4.0.0.0 when only 2.0.0.0 is referenced in the projects and the project is targeting version 2.0 of the framework?
-
miércoles, 14 de julio de 2010 17:07
Didn't fusion logs provide any useful info that would point you out to which component initiated 4.0.0.0 version load? Does that component has a reference to 4.0.0.0 by any chance? (Use ildasm to check it out)
-Karel
-
miércoles, 14 de julio de 2010 20:06
I had this problem with a project that I built in 4.0 and downgraded to .NET 2.0. When I manually edited the config file it would run, but it was a pain to have to keep manually doing it after every rebuild. I fixed the issue by: 1.) Close Visual Studio, 2.)Delete the bin and obj directories from the project folder. 3.) Open the project and rebuild.
Hopefully this helps you.
-
domingo, 31 de octubre de 2010 3:44
I had the same problem with a C# project (ie on downgrading to target 3.5, with the real VS 2010 release). The solution is to manually alter app.config, so that the relevant elements have Version=2.0.0.0
Same problem here, changing it to 2.0.0.0 fixes it. Thanks for the help! -
domingo, 17 de abril de 2011 22:31Same problem here, but changing the app.config and deleting the bin and objects did not help. I see this thread went dead, so I guess others figured it out. Could you share?
-
martes, 26 de abril de 2011 21:23
I had to do it a couple of times before it worked but it did work. I had to delete the bin and obj folders and then change the app.config file close and restart Visual Studio twice
IT Guy -
sábado, 07 de mayo de 2011 0:32
I believe you will find that the problem is related to settings /Resources and resgen. When you create these items the code generated has some version specific items in there which when you downtarget this source code is not modified - just the target assemblies.
The way to resolve it is to set the project to target 3.5 (as an downtarget example). Then delete the settings and re-add them. This will cause the code generated to add the 3.5 version in the source code and this should work. Not ideal but in all likelyhood this is what is probably occuring and the workaround.
-
martes, 02 de agosto de 2011 18:14
Close Visual Studio
Delete the bin and obj
Then you may get some errors, dont panic , Delete the app.config, then add new item , app.config.
then rebuild and run.Thanks to Jim he helped me out :)
-
martes, 14 de febrero de 2012 11:59
Close Visual Studio
Delete the bin and obj
Then you may get some errors, dont panic , Delete the app.config, then add new item , app.config.
then rebuild and run.Thanks to Jim he helped me out :)
works for me.
deleting bin and obj and app.config
this will cause visual studio to regenerate app.config using current target settings.
thanks :)
-
martes, 13 de marzo de 2012 16:57Thanks - works a treat!

