C# 在外部程序集中调用方法时加载外部web.config变量
我正在使用反射调用外部程序集中的方法。外部类/方法位于WCF数据服务中 WCF数据服务使用从web.config中的自定义配置部分加载的信息C# 在外部程序集中调用方法时加载外部web.config变量,c#,wcf,reflection,configuration,.net-assembly,C#,Wcf,Reflection,Configuration,.net Assembly,我正在使用反射调用外部程序集中的方法。外部类/方法位于WCF数据服务中 WCF数据服务使用从web.config中的自定义配置部分加载的信息 <configSections> <section name="myCustomSection" type="MyWcfService.MyCustomSection, MyWcfService" /> </configSections> 这是产生错误的外部程序集(wcf服务)的代码 MyCustomSe
<configSections>
<section name="myCustomSection" type="MyWcfService.MyCustomSection, MyWcfService" />
</configSections>
这是产生错误的外部程序集(wcf服务)的代码
MyCustomSection configSection = ConfigurationManager.GetSection("myCustomSection")
as MyCustomSection ;
configSection出现空值-“对象引用未设置为对象的实例”
我认为,如果在本地应用程序app.config而不是web.config中查找,那么在本地添加相同的配置信息应该可以
谢谢 您可能需要注册AppDomain.CurrentDomain.TypeResolve事件。这个链接有一个如何使用它的例子。
MyCustomSection configSection = ConfigurationManager.GetSection("myCustomSection")
as MyCustomSection ;