我有一個名爲Foo的C#.NET庫,它生成一個Foo.dll文件。這也是通過一個config文件看起來像這樣配置:從非託管C++配置.NET庫
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Foo.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</sectionGroup>
</configSections>
<applicationSettings>
<Foo.Properties.Settings>
<setting name="Server" serializeAs="String">
<value>localhost</value>
</setting>
</Foo.Properties.Settings>
</applicationSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
我想要做的就是通話功能在這個.NET庫從非託管C++程序調用的酒吧,並能夠從更改其配置非託管C++應用程序。我可以通過在Foo中將類/接口屬性ComVisible設置爲true來從Bar調用Foo函數。但是,我無法從非託管C++應用程序更改.config文件值 - 服務器始終是「localhost」。
是我想要做的 - 從非託管C++配置.NET庫 - 甚至可能嗎?
與此相反,dll確實有配置文件。例如,如果上例中給出的.NET庫的使用者從非託管C++ exe更改爲託管C#exe,則可以通過複製來更新共享庫Foo.dll的Server。將Foo的值配置到Bar.exe.config中。因此,我的原始問題是:如果.NET消費者有可能更新.NET dll的配置文件,那麼非託管C++使用者是否可以更新.NET dll的配置文件? – 2011-01-20 22:23:19
@GP:這是一個** EXE **的配置文件。 DLL本身沒有配置文件。 .Net框架將從不**看`Foo.dll.config`。 – SLaks 2011-01-20 22:49:22