pierrepret22
pierrepret22

Reputation: 29

Creating a .NET 3.5 version from a .NET 4.0 project

I have a WCF application that was developed in 4.0. It uses settings for file paths (such as a path for a log file). When i want to build a 3.5 version, it gives me a ConfigurationErrorException which reads:

"An error occurred creating the configuration section handler for userSettings/WCF_SmartStatsHost.Properties.Settings: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. (C:\Users\Pierre\Documents\Visual Studio 2010\Projects\WCF_SmartStats\WCF_SmartStatsHost\bin\Debug"

I have already checked and rechecked the file path etc. but it looks like its a bit more technical than that.

Here is the stack trace:

at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey, Boolean getLkg, Boolean checkPermission)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ClientSettingsStore.ReadSettings(String sectionName, Boolean isUserScoped)
at System.Configuration.LocalFileSettingsProvider.GetPropertyValues(SettingsContext context, SettingsPropertyCollection properties)
at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider)
at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
at System.Configuration.SettingsBase.get_Item(String propertyName)
at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
at WCF_SmartStatsHost.Properties.Settings.get_LogPath() in C:\Users\Pierre\Documents\Visual Studio 2010\Projects\WCF_SmartStats\WCF_SmartStatsHost\Properties\Settings.Designer.cs:line 32
at WCF_SmartStatsHost.Host_Logging.CreateActivityLog(String message) in C:\Users\Pierre\Documents\Visual Studio 2010\Projects\WCF_SmartStats\WCF_SmartStatsHost\Host_Logging.cs:line 17
at WCF_SmartStatsHost.Host_Processor.Start() in C:\Users\Pierre\Documents\Visual Studio 2010\Projects\WCF_SmartStats\WCF_SmartStatsHost\Host_Processor.cs:line 24
at WCF_SmartStatsHost.Host_Program.Main(String[] args) in C:\Users\Pierre\Documents\Visual Studio 2010\Projects\WCF_SmartStats\WCF_SmartStatsHost\Host_Program.cs:line 20
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Any help would be appreciated.

Upvotes: 2

Views: 1887

Answers (2)

Kull Damned
Kull Damned

Reputation: 31

If you're using applicationSettings in web.config try to replace Version from 4.0.0.0 to 2.0.0.0 in web.config. Unfortunately Visual Studio does not change version for settings when you downgrade app.

Upvotes: 3

Vilx-
Vilx-

Reputation: 106904

Check your references (in Solution Explorer right-click, properties) if they have been set to "Specific version=true". Change it to false and then try again.

Here's the important part in your error message:

An error occurred creating the configuration section handler for userSettings/WCF_SmartStatsHost.Properties.Settings: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified. (C:\Users\Pierre\Documents\Visual Studio 2010\Projects\WCF_SmartStats\WCF_SmartStatsHost\bin\Debug

Upvotes: 6

Related Questions