我已经为一些 Sharepoint WSS3 功能制作了测试程序,但我遇到了一个奇怪的异常。
public XmlNode GetListsCollection()
{
XmlNode nodeLists;
ShareLists.Lists lists = new ShareLists.Lists(); // <--- Exception causing line
lists.Credentials = CredentialCache.DefaultCredentials;
return nodeLists = lists.GetListCollection();
}
// 此处出现异常 (Settings.Designer.cs)
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.WebServiceUrl)]
[global::System.Configuration.DefaultSettingValueAttribute("http://uk-tr-dsf/_vti_bin/Lists.asmx")]
public string SharepointWeb_ShareLists_Lists {
get {
return ((string)(this["SharepointWeb_ShareLists_Lists"]));
}
}
当我将项目从 .NET 4 更改为 .NET 3.5 时发生此错误,这是修复“PlatformNotSupportException”所必需的。
所以我不能改回来。
System.Configuration.ConfigurationErrorsException was unhandled
Message=An error occurred creating the configuration section handler for applicationSettings/SharepointWeb.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:\Working\SharepointPlugin\SharepointWeb\bin\Debug\SharepointWeb.vshost.exe.Config line 5)
Source=System.Configuration
BareMessage=An error occurred creating the configuration section handler for applicationSettings/SharepointWeb.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.
Filename=C:\Working\SharepointPlugin\SharepointWeb\bin\Debug\SharepointWeb.vshost.exe.Config
Line=5
Stacktrace: ... omitted
我意识到这ConfigurationErrorsException
是一个委托,真正的异常消息是内部异常。
System.IO.FileNotFoundException
Message=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.
现在,在我的参考资料中找到并清楚地显示了这个文件,但是Microsoft.CSharp
丢失了(由于它是一个 .NET 3.5 项目)我假设这是原因是否正确?.NET 4 下是否有适用于框架的版本?我看过了C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\
,看不到等效版本。
解决方案:
这些必须改变
在 resx 文件中:
<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>
在 app.config 中:
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="SharepointWeb.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>