如何获得一个.NET CCW组件从dll.config加载配置如何获得、组件、加载、NET

2023-09-04 03:26:34 作者:唯念那抹少年蓝

我公开为 CCW (COM可调用包装),并加载到一个非托管的IIS应用程序(ATL服务器).NET组件。该组件安装并使用COM注册 regasm / codeBase的

I have a .NET component exposed as a CCW (Com Callable Wrapper) and being loaded into an unmanaged IIS application (ATL server). The assembly is installed and registered with COM using regasm /codebase.

组件需要配置,如通常放入Web.config文件中的IIS应用程序。但我不想砸配置成要么w3pw.exe.config或machine.config中 - 在理想情况下,我想将配置现场的旁边安装暴露于COM大会

The component requires configuration such as is typically put into a Web.config file for an IIS app. But I don't want to drop the config into either w3pw.exe.config or machine.config - Ideally I'd like the configuration to be installed live along side the assembly that is exposed to COM.

我还没有找到一种方法来实现这一目标。由于COM组件加载到默认的AppDomain,所以我不认为我可以配置域从其他位置加载。

I haven't found a way to achieve this. Since the COM assembly is loaded into the default AppDomain, so I don't think I can configure that domain to load from an alternate location.

推荐答案

您可以尝试

AppDomain.CurrentDomain.SetData ("APP_CONFIG_FILE",ConfigFile);

在哪里ConfigFile实现是完整路径到应用程序的app.config文件(C:\测试\ myapp.config)。从的加载的App.config数据成DLL

 
精彩推荐
图片推荐