更改项目目标框架后应用程序设置错误

发布于 2024-11-16 03:19:15 字数 596 浏览 6 评论 0原文

在我的应用程序中,我使用的用户设置如下所述此处。 然后我意识到在 VS 2010 中我使用的是 .NET 4.0,而只有 .NET 2.0 就足够了。

当我更改框架并构建项目时,在我的代码中,每当我现在访问设置时,都会收到以下错误:

创建时发生错误 配置节处理程序 用户设置/Vegi_Manager.Properties.Settings: 无法加载文件或程序集 '系统,版本=4.0.0.0, 文化=中立, PublicKeyToken=b77a5c561934e089' 或 它的依赖项之一。系统 找不到指定的文件。 (C:\Users\AKSHAY\AppData\Local\Microsoft\Vegi-Manager.vshost.exe_Url_44035dlkzpfaaauiqsd4nh3f0l0yq0tv\1.0.0.0\user.config 第 5 行)

出于未知原因使用 4.0 版本。 请建议我应该做什么。

In my application I am using user settings as explained here.
Then I realized that in VS 2010 I was using .NET 4.0 while only .NET 2.0 was sufficient.

When I changed the framework and build the project, in my code whenever I access setting now, I get the following error:

An error occurred creating the
configuration section handler for
userSettings/Vegi_Manager.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:\Users\AKSHAY\AppData\Local\Microsoft\Vegi-Manager.vshost.exe_Url_44035dlkzpfaaauiqsd4nh3f0l0yq0tv\1.0.0.0\user.config
line 5)

It is for unknown reasons using version 4.0.
Please suggest what should I do.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

腻橙味 2024-11-23 03:19:15

检查您的 app.config ,也许您仍然有 System.Configuration.UserSettingsGroup 或类似版本 4 的东西仍然潜伏在周围,您将必须手动编辑并获取与版本 2 相关

Check out your app.config maybe you still have System.Configuration.UserSettingsGroup or something of that sort of version 4 still lurking around, you will have to manually edit and get the relevant for version 2

挖鼻大婶 2024-11-23 03:19:15

我在开始在 Visual Studio 2010 中开发针对 .NET 4.0 框架的 Outlook 加载项时遇到了同样的问题,然后决定将其更改为 3.5 框架。看来 Visual Studio 不够智能,无法更新我的 app.config 文件,该文件仍然引用 4.0。

正如之前的海报所建议的(我会更具体一点),通过手动编辑 app.config 将所有引用从“Version=4.0.0.0”更改为“Version=2.0.0.0”(显然 .NET 3.5 仍然使用 2.0.0.0) 在 元素及其子元素中,我能够在我的情况下使设置再次工作。

I was having the same problem having started developing my Outlook add-in in Visual Studio 2010 targeting the .NET 4.0 framework and then deciding to change it to the 3.5 framework. It seems Visual Studio was NOT smart enough to update my app.config file which still had a reference to 4.0.

As previous posters have suggested (I'll be just a little bit more specific), by manually editing app.config to change all references from "Version=4.0.0.0" to "Version=2.0.0.0" (apparently .NET 3.5 still uses 2.0.0.0) in the <sectionGroup> element and its child elements, I was able to get the settings working again in my case.

迷荒 2024-11-23 03:19:15

您的解决方案中可能有对 .NET 4 程序集的引用 - 如果您在解决方案中打开“添加引用”窗口并使窗口变宽一点,您将看到有版本和运行时列。 .. 当您创建针对 .NET 4 的解决方案时,您可能添加了对需要 .NET 4 运行时的程序集的引用,现在您已更改为 .NET 2,您需要将其交换为仅需要 .NET 4 运行时的程序集.NET 2 运行时。

当然,如果您使用了 .NET 4 程序集中不存在于 .NET 2 中的某些内容,则您要么必须重写以避免使用它,要么改变主意并在 .NET 4 中执行此操作!

It is likely that you have a reference to a .NET 4 assembly in your solution - if you open the "Add Reference" window in your solution and make the window a bit wider, you will see that there are columns for Version and Runtime... when you created your solutions to target .NET 4, you might have added a reference to an assembly that requires the .NET 4 runtime and now you have changed to .NET 2, you need to swap it for an assembly that only needs the .NET 2 runtime.

Of course, if you have used something form the .NET 4 assembly that didn't exist in .NET 2, you will either have to re-write to avoid using it or change your mind and do it in .NET 4 instead!

你的笑 2024-11-23 03:19:15

如果您打开 app.config,请确保所有配置部分都针对 .net Framework 2 而不是 4

如果您将 app.config 发布给我,我可以提供更多帮助

if you open your app.config, make sure all the config sections are targeting .net framework 2 not 4

if you post your app.config to me i can help more

北陌 2024-11-23 03:19:15

我可以在这里补充一点,您需要将对以前的 .NET 框架(在本例中为 4.0.0.0)的 app.config 详细信息/引用更改为新的系统引用 .NET 版本(在本例中为 2.0.0.0,与.NET 3.5!)

May I add here that you need to change the app.config details / references to the previous .NET framework (in this case 4.0.0.0) to the new System refence .NET version (in this case 2.0.0.0 which is the same for .NET 3.5!)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文