Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/311.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 运行时无法识别对VSTOAddin.dll.config的更改_C#_Vsto - Fatal编程技术网

C# 运行时无法识别对VSTOAddin.dll.config的更改

C# 运行时无法识别对VSTOAddin.dll.config的更改,c#,vsto,C#,Vsto,我想更好地了解VSTOAddin.dll.config文件在VSTO中的工作方式 我不明白为什么我不能使用记事本编辑配置文件,并在下一次运行外接程序时反映这些更改(类似于下面的文章) 我已成功找到并手动编辑了我的用户设置配置文件。但不能对应用程序设置配置文件执行相同的操作。为什么? 我知道应该在VS中通过代码或在设计时进行更改 救命 --编辑-- 谢谢PetLahev,实际上我做的事情有点不同。我有三个VSTO加载项,它们都引用一个公共程序集。这些设置与公共部件相关联 允许吗?我注意到程序集实

我想更好地了解VSTOAddin.dll.config文件在VSTO中的工作方式

我不明白为什么我不能使用记事本编辑配置文件,并在下一次运行外接程序时反映这些更改(类似于下面的文章)

我已成功找到并手动编辑了我的用户设置配置文件。但不能对应用程序设置配置文件执行相同的操作。为什么?

我知道应该在VS中通过代码或在设计时进行更改

救命

--编辑--

谢谢PetLahev,实际上我做的事情有点不同。我有三个VSTO加载项,它们都引用一个公共程序集。这些设置与公共部件相关联

允许吗?我注意到程序集实际上是从%appdata%\local\assembly运行的


但即使我将ClassLibrary1.dll.config文件移动到%appdata%\local\assembly。。我无法通过记事本更改它,也无法看到我的应用程序中反映的修改。

不确定您使用的是哪个应用程序,我尝试了Excel,它非常简单

我的app.config看起来像

    <?xml version="1.0"?>
<configuration>
    <configSections>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="ConfigSettingTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
        </sectionGroup>
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
            <section name="ConfigSettingTest.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
        </sectionGroup>
    </configSections>
    <userSettings>
        <ConfigSettingTest.Properties.Settings>
            <setting name="MyUserSettings" serializeAs="String">
                <value>My user settings</value>
            </setting>
        </ConfigSettingTest.Properties.Settings>
    </userSettings>
    <applicationSettings>
        <ConfigSettingTest.Properties.Settings>
            <setting name="MyAppSettings" serializeAs="String">
                <value>My Application settings</value>
            </setting>
        </ConfigSettingTest.Properties.Settings>
    </applicationSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

如果我转到bin文件夹并通过记事本更改值,然后运行Excel,我将获得更改后的值

我最终使用了本文第三部分所述的自定义部分

使用反射,我可以看到每个应用程序设置在类文件中都设置了“默认值”。是否每次都使用这些值?如果是这样,为什么还要麻烦将.config文件存储在程序集之外呢?我尝试单步执行我的代码并调用Settings.Default.Reload()、Settings.Default.Reset()、Settings.Default.Upgrade()等,但没有任何效果。给你什么?谢谢你,佩特拉赫夫。这对我也适用。我实际上有3个Office加载项,都引用了一个公共dll。并且公共dll具有这些设置。我将做一些测试,看看这是否是问题所在。PetLahev,知道app.config用于引用程序集时它为什么不工作吗?
 public static void test()
        {
            System.Windows.Forms.MessageBox.Show(Properties.Settings.Default.MyUserSettings);
            System.Windows.Forms.MessageBox.Show(Properties.Settings.Default.MyAppSettings);
        }