[英].NET DLLs confliction
我已經為一些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下是否有Frameworks版本? 我查看了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>
沒有適用於3.5的Microsoft.CSharp.dll,但通常它會自動添加到4.0項目而不需要它(除非你使用像動態關鍵字這樣的東西,在這種情況下你的項目需要4.0),所以我會嘗試刪除此引用。
重新下載system.dll版本4,你說這個文件已經找到並出現在你的引用中。 但是,如果您的項目是針對3.5框架的,那么您應該引用system.dll的2.0版本而不是system.dll的框架4版本
同樣,您需要確保其他dll都不適用於框架4。
看起來您的工具中仍然使用了一些4.0程序集。 將目標切換到2.0-3.5時,必須停止使用4.0程序集。 不幸的是,由於您要遷移到舊版本的Framework,因此有必要將代碼更改為不使用僅4.0的功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.