.NET插件设置的客户可编辑默认值

时间:2012-03-26 12:12:16

标签: c# .net plugins configuration

简短问题:

有没有办法提供客户可编辑的机器范围配置文件,该文件将为第三方应用程序加载的插件中“隐藏”的用户范围设置提供默认值?

更多详情:

  • 第三方主机应用程序(Autodesk Inventor 2010)加载我的Plugin.dll,后者又引用包含插件“肉”的Other.dll
    • 主机将Plugin.dll视为进程内COM服务器(主机的插件架构和API基于COM)。
    • 主机应用程序是本机代码和CLR 2.0的混合。 Plugin.dllOther.dll是CLR 4.0(因此在加载插件后,CLR 2.0和CLR 4.0都在主机应用程序中共存)。
  • Other.dll有自己的设置,这些设置是通过Visual Studio 2010 Settings.settings机制设计的。所有设置都是用户范围的(并通过Properties.Settings.Default代码访问)。
  • Other.dll提供了一个用于编辑设置的用户界面,最终会保存到:C:\Users\<USER>\AppData\Local\Autodesk,_Inc\DefaultDomain_Path_0s3njlwv3kl0bcv0w3ply5p1ublvhgsb\Autodesk®_Inventor®_2010\user.config

客户有多个工作站由多个用户共享,他们希望能够提供设置默认值,而无需将user.config复制到每个用户的文件夹。如果重要,操作系统是Windows 7。

有没有一种优雅的方法来实现这一目标,而不放弃Properties.Settings.Default机制?

附录:

主机应用程序的设置在C:\Program Files\Autodesk\Inventor 2010\bin\Inventor.exe.config,但是当我尝试在那里添加默认设置时,主机应用程序在启动时会崩溃。这可能是因为不同的CLR版本一起使用吗?

对于它的价值,这是原始的Inventor.exe.config

<?xml version="1.0" encoding="utf-8"?>
<!-- $Header:$ -->
<!-- This config file is copied to the Inventor bin\ folder by //inventor/Main/Sources/AddInApps/ContentCenter/_RootBuildInventor/PostBuild.bat -->
<configuration>
    <configSections>
        <sectionGroup name="autodesk.inventor.content">
            <section name="logging" type="System.Configuration.DictionarySectionHandler,system, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null"/>
    </sectionGroup>
    <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <appSettings>
        <!-- Controls client cache allocation limit. MaxCachedObjects controls the maximum number
             of cached objects before a purge is done. CachePurgeInterval controls how many objects
             are removed when a purge is done -->
        <add key="Connectivity.Content.MaxCachedObjects" value="500"/>
        <add key="Connectivity.Content.CachePurgeInterval" value="100"/>
        <add key="Connectivity.Content.MaxSearchResults" value="2500"/>
        <!-- WebService timeout (in milliseconds)-->
        <add key="WebServiceTimeout" value="1000000"/>
    </appSettings>
  <microsoft.web.services3>
    <messaging>
      <maxMessageLength value="51200"/>
      <mtom clientMode="On" maxMimeParts="1024"/>
    </messaging>
    <security>
      <!-- Specifies the time buffer used by WSE to determine when a SOAP message is valid.
           set to the max of 24hr in seconds -->
      <timeToleranceInSeconds value="86400" />
    </security>
  </microsoft.web.services3>
    <!-- Since Inventor is an unmanaged application, we need to explicitly identify
         the framework version it's to use. Otherwise, it will pick up the latest
         version that's been installed -->
    <startup>
    <!-- The following specification works for both .NET 2.0 and .NET 3.0, since they share the same CLR.
         .NET 3.0 installs both 
             C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (the CLR) and
             C:\WINDOWS\Microsoft.NET\Framework\v3.0
         The 'v3.0' folder contains WPF and some other components built on top of .NET 2.0.
         Inventor won't start up if the following in changed to "V3.0" -->
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

这是我修改过的导致崩溃的那个:

<?xml version="1.0" encoding="utf-8"?>
<!-- $Header:$ -->
<!-- This config file is copied to the Inventor bin\ folder by //inventor/Main/Sources/AddInApps/ContentCenter/_RootBuildInventor/PostBuild.bat -->
<configuration>
    <configSections>
        <sectionGroup name="autodesk.inventor.content">
            <section name="logging" type="System.Configuration.DictionarySectionHandler,system, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null"/>
        </sectionGroup>
        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="Etrage.Ifs.CadAddin.Common.Ui.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
        </sectionGroup>
    <section name="microsoft.web.services3" type="Microsoft.Web.Services3.Configuration.WebServicesConfiguration, Microsoft.Web.Services3, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </configSections>
    <appSettings>
        <!-- Controls client cache allocation limit. MaxCachedObjects controls the maximum number
             of cached objects before a purge is done. CachePurgeInterval controls how many objects
             are removed when a purge is done -->
        <add key="Connectivity.Content.MaxCachedObjects" value="500"/>
        <add key="Connectivity.Content.CachePurgeInterval" value="100"/>
        <add key="Connectivity.Content.MaxSearchResults" value="2500"/>
        <!-- WebService timeout (in milliseconds)-->
        <add key="WebServiceTimeout" value="1000000"/>
    </appSettings>

    <userSettings>
        <Etrage.Ifs.CadAddin.Inventor.Properties.Settings>
            <setting name="MapiPropertiesToIfsPart" serializeAs="String">
                <value>False</value>
            </setting>
        </Etrage.Ifs.CadAddin.Inventor.Properties.Settings>
    </userSettings>

    <microsoft.web.services3>
    <messaging>
      <maxMessageLength value="51200"/>
      <mtom clientMode="On" maxMimeParts="1024"/>
    </messaging>
    <security>
      <!-- Specifies the time buffer used by WSE to determine when a SOAP message is valid.
           set to the max of 24hr in seconds -->
      <timeToleranceInSeconds value="86400" />
    </security>
  </microsoft.web.services3>
    <!-- Since Inventor is an unmanaged application, we need to explicitly identify
         the framework version it's to use. Otherwise, it will pick up the latest
         version that's been installed -->
    <startup>
    <!-- The following specification works for both .NET 2.0 and .NET 3.0, since they share the same CLR.
         .NET 3.0 installs both 
             C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 (the CLR) and
             C:\WINDOWS\Microsoft.NET\Framework\v3.0
         The 'v3.0' folder contains WPF and some other components built on top of .NET 2.0.
         Inventor won't start up if the following in changed to "V3.0" -->
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

0 个答案:

没有答案