我已經爲某些Sharepoint WSS3功能製作了測試程序,但是我遇到了一個奇怪的例外。.NET DLLs衝突
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.0到.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>
我現在有比V2更高的項目的唯一DLL是System.Core運行在v3.5與我的項目相同。然而,例外依然存在。 – Amicable
在這種情況下,我認爲您可能需要在源文件夾中的每個文件中搜索Version = 4.0.0.0,以查看是否告訴您指向system.dll的內容。例如,它可能是一個.resx文件 – sgmoore
搜索版本= 4.0.0.0顯示了在我的App.Config和Form1.resx文件中引用了有問題的PKT的DLL。 我沒想到能夠以純文本的方式找到它!活到老,學到老。 – Amicable