无法加载文件或程序集&System; Version,Version = 4.0.0.0,Culture = neutral'或其中一个依赖项

时间:2018-06-15 09:59:41

标签: c# wpf

在开发过程中的某个时刻,我收到以下错误消息:

Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral' or one of its dependencies.

它是.NET 4.7.1中的WPF应用程序。已经安装了几个第三方nuget软件包,它工作正常,直到今天。

我添加了一些应用程序设置并添加了静态Settingshelper类,以便更轻松地获取这些设置:

public static string ConnectionString => Properties.Settings.Default.ConnectionString;

ConnectionString中有一个app.config键/值对,并且使用项目的属性窗口添加了键/值对。这会生成代码:

    [global::System.Configuration.ApplicationScopedSettingAttribute()]
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    [global::System.Configuration.DefaultSettingValueAttribute("Server=localhost;Database=xxxx;Uid=xxxx;Pwd=xxxx;")]
    public string ConnectionString {
        get {
            return ((string)(this["ConnectionString"]));
        }
    }

返回语句抛出异常。

起初编译正常,没有显示错误。在我更改了一行代码(在某些方法中简单的字符串连接)后,错误在运行时出现。恢复该行代码并不能解决问题。

该解决方案由主项目和其他几个项目(类库)组成,其中主项目引用这些项目包括类库。

我已阅读Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies但我没有提到上述文件。我已检查过.sln.csproj个文件,但无法找到对旧已删除文件的引用。

唯一的系统差异是我安装了Windows软件开发工具包中的调试器,因为我想分析内存转储。我已经卸载并重新启动了机器,以防万一。

我是C#和Visual Studio的新手(对于一般的编程来说并不陌生)。

编辑:我还删除并添加了主项目中的系统参考。删除并添加了ConnectionString键值对。

1 个答案:

答案 0 :(得分:0)

看起来我发现了这个问题。在 <html> <head> <title>Embedded FBX QuickTime movie in a web page</title> <script src="AC_QuickTime.js" language="JavaScript" type="text/javascript"></script> </head> <body bgcolor="#6699FF"> <h1>Embedded FBX file in a web page</h1> <div/> <script language="JavaScript" type="text/javascript"> QT_WriteOBJECT_XHTML('Tester.FBX', '800', '600', '', 'autoplay', 'true', 'emb#bgcolor', 'black', 'align', 'middle'); </script> <hr/>An fbx file should be playing now above, using a QuickTime player embedded. </body> </html>中,App.config具有<sectionGroup name="applicationSettings"...属性。这在某种程度上改为PublicKeyToken。我不知道为什么以及如何做到这一点。