升级外部DLL的用户设置 [英] Upgrade user settings of an external DLL

查看:103
本文介绍了升级外部DLL的用户设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我有一个主应用程序(启动器)和一个包含所有ui控件的库。



当我启动主应用程序(.exe)时,我尝试升级dll的用户设置,调用此方法:



public static void CheckForUpgrade()

{

if(Settings1.Default.UpdateSettings)

{

Settings1.Default.Upgrade();

Settings1.Default.UpdateSettings = false;

Settings1.Default.Save();

}

}



当我查看日志时,我可以看到升级被调用,但设置被重置默认值。



无论如何都有升级dll设置,它不在主(执行)程序集中?



我尝试过:



试图从主应用程序中调用此方法。它是在静态类(SettingsManager)下的外部dll中定义的。



Hi!

I've one main app (launcher) and a library containing all ui controls.

When I launch main app (.exe) I try to upgrade dll's user settings calling this method:

public static void CheckForUpgrade()
{
if (Settings1.Default.UpdateSettings)
{
Settings1.Default.Upgrade();
Settings1.Default.UpdateSettings = false;
Settings1.Default.Save();
}
}

When I review logs, i can see upgrade is called, but settings are reset to default values.

There is anyway to upgrade dll settings that it's not in the main (executing) assembly?

What I have tried:

Tried to call this method from the main app. It's defined in the external dll under an static class (SettingsManager)

public static void CheckForUpgrade()
{
  if (Settings1.Default.UpdateSettings)
  {
    Settings1.Default.Upgrade();
    Settings1.Default.UpdateSettings = false;
    Settings1.Default.Save();                    
  }
}

推荐答案

你需要先做两件事:

1)查看您正在调用的代码,而不是调用它的代码。您显示的代码很简单 - 您需要查看Upgrade方法实际执行的操作。

2)使用调试器检查是否调用了CheckForUpgrade方法,并逐步进入Upgrade和Save方法找出他们到底在做什么。当他们这样做时,请检查您认为应该更新的文件(或者如果他们使用数据库则检查数据库),并确保更改按照您的预期进行。



对不起,但我们不能为你做任何事情!
You need to start by doing two things:
1) Look at the code you are calling, not the code that calls it. The code you show is trivial - you need to look at what the Upgrade method actually does.
2) Use the debugger to check that the CheckForUpgrade method is called, and step through into the Upgrade and Save methods to find out exactly what they are doing. While they do it, check the files you think they should be updating (or the databases if they use them) and make sure that changes go where you expect.

Sorry, but we can't do any of that for you!


找到解决方法:



c# - ApplicationSettingsBase.Upgrade()在使用.NET 4.0重新编译后不升级用户设置 - 堆栈溢出 [ ^ ]



我认为问题是与不同版本/调试版本相关的用户设置并发。 (版本号不相关,升级不知道如何解决)



在测试此功能之前清理可能会解决它。
Found workaround here:

c# - ApplicationSettingsBase.Upgrade() Not Upgrading User Settings after Recompiling with .NET 4.0 - Stack Overflow[^]

I think the problem is user settings concurrence related to diferent release/debug versions. (version numbers not correlated, and upgrade doesn't know how to resolve)

Cleaning before testing this feature may solve it.


这篇关于升级外部DLL的用户设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆