简体   繁体   English

从.NET 4.0项目创建.NET 3.5版本

[英]Creating a .NET 3.5 version from a .NET 4.0 project

I have a WCF application that was developed in 4.0. 我有一个在4.0中开发的WCF应用程序。 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: 当我想构建一个3.5版本时,它给我一个ConfigurationErrorException,它读取:

"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" “为userSettings / WCF_SmartStatsHost.Properties.Settings创建配置节处理程序时出错:无法加载文件或程序集'System,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'或其依赖项之一。系统不能找到指定的文件。(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. 任何帮助,将不胜感激。

Check your references (in Solution Explorer right-click, properties) if they have been set to "Specific version=true". 如果已将参考设置为“特定版本= true”,请检查您的参考(在解决方案资源管理器中右键单击属性)。 Change it to false and then try again. 将其更改为false,然后重试。

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. 为userSettings / WCF_SmartStatsHost.Properties.Settings创建配置节处理程序时出错: 无法加载文件或程序集'System,Version = 4.0.0.0 ,Culture = neutral,PublicKeyToken = b77a5c561934e089'或其依赖项之一。 The system cannot find the file specified. 该系统找不到指定的文件。 (C:\\Users\\Pierre\\Documents\\Visual Studio 2010\\Projects\\WCF_SmartStats\\WCF_SmartStatsHost\\bin\\Debug (C:\\ Users \\ Pierre \\ Documents \\ Visual Studio 2010 \\ Projects \\ WCF_SmartStats \\ WCF_SmartStatsHost \\ bin \\ Debug

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. 如果您在web.config中使用applicationSettings,请尝试在web.config中将Version从4.0.0.0替换为2.0.0.0。 Unfortunately Visual Studio does not change version for settings when you downgrade app. 不幸的是,当您降级应用程序时,Visual Studio不会更改设置的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM