我有一个在4.0中开发的WCF应用程序。它使用文件路径的设置(例如日志文件的路径)。当我想构建一个3.5版本时,它给我一个ConfigurationErrorException,其中包含:
“为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“
我已经检查并重新检查了文件路径等,但它看起来比它更具技术性。
这是堆栈跟踪:
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()
任何帮助都将不胜感激。
答案 0 :(得分:6)
如果已将参考设置为“特定版本= true”,请检查您的参考(在解决方案资源管理器中右键单击属性)。将其更改为false,然后重试。
以下是错误消息中的重要部分:
为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
答案 1 :(得分:3)
如果您在web.config中使用applicationSettings,请尝试在web.config中将Version从4.0.0.0替换为2.0.0.0。 不幸的是,当您降级应用程序时,Visual Studio不会更改设置的版本。