.NET DLLs冲突

Ami*_*ble 3 .net c# sharepoint .net-3.5

我已经为一些Sharepoint WSS3功能制作了测试程序,但我遇到了一个奇怪的例外.

public XmlNode GetListsCollection()
{
    XmlNode nodeLists;

    ShareLists.Lists lists = new ShareLists.Lists(); // <--- Exception causing line
    lists.Credentials = CredentialCache.DefaultCredentials;

    return nodeLists = lists.GetListCollection();
}
Run Code Online (Sandbox Code Playgroud)

//这里出现异常(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"]));
    }
}
Run Code Online (Sandbox Code Playgroud)

当我将项目从.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
Run Code Online (Sandbox Code Playgroud)

我意识到这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.
Run Code Online (Sandbox Code Playgroud)

现在这个文件被找到并清楚地出现在我的引用中,但是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>
Run Code Online (Sandbox Code Playgroud)

在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>
Run Code Online (Sandbox Code Playgroud)

sgm*_*ore 5

没有适用于3.5的Microsoft.CSharp.dll,但通常它会自动添加到4.0项目而不需要它(除非你使用像动态关键字这样的东西,在这种情况下你的项目需要4.0),所以我会尝试删除此引用.

重新下载system.dll版本4,你说这个文件已经找到并出现在你的引用中.但是,如果您的项目是针对3.5框架的,那么您应该引用system.dll的2.0版本而不是system.dll的框架4版本

同样,您需要确保其他dll都不适用于框架4.

  • 在这种情况下,我认为您可能需要在源文件夹中的每个文件中搜索Version = 4.0.0.0,以查看它是否告诉您指向system.dll的内容.例如,它可能是.resx文件 (2认同)