DLL.Config文件被忽略 [英] DLL.Config file ignored

查看:105
本文介绍了DLL.Config文件被忽略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我已经看到了几篇类似的文章,但是还没有可以接受的解决方案.我认为与其重新创建旧线程,不如创建一个新线程.我希望可以.

我正在为WCF服务创建包装DLL. DLL项目包含自己的app.config文件,其中包含用于访问服务的端点和绑定的设置.到目前为止,我编译了解决方案并获得了我的DLL和DLL.config文件.

当我将包装DLL和DLL.config文件添加到新的解决方案以对其进行测试时,我发现找不到设置的错误.如果我将设置添加到测试应用程序的app.config文件中,则一切运行正常.似乎DLL是在app.config中而不是dll.config中寻找其设置.我看过几篇文章,指出我应该将DLL.config文件中的设置合并到APP.config文件中,或者在APP.config文件中添加一些内容以指向我的DLL.config文件.我真的不想这样做,因为我会将DLL与第三方应用程序集成在一起,但我想避免使用第三方配置文件.另外,由于此DLL是WCF服务的包装程序,因此我不想编写自己的代码来从DLL.config文件或设置文件中提取设置.它应该自动发生(即,当您调用从System.ServiceModel.ClientBase< T>扩展的类的构造函数时获取设置.此代码全部由svcutil.exe生成).

我知道我必须在这里丢失一些小细节.有人有什么主意吗?预先感谢任何提出建议的人.

这是我要使用的DLL.config文件.只是重申一下,如果将设置放在app.config中,则设置会很好用,但是当放在dll.config文件中时,它们会被忽略.我需要找到一种告诉dll从dll.config而不是从app.config文件获取设置的方法.

<? xml 版本 = 1.0 &; " utf-8

Hello,

I've seen several similar posts on this but no acceptable solution yet.  Rather than resurrecting old threads, I thought it would be better to create a new one.  I hope it's ok.

I'm creating a wrapper DLL for a WCF service.  The DLL project contains it's own app.config file with the settings for endpoints and binding that should be used to access the service.  I compile the solution and get my DLL and DLL.config file, so far so good.

When I add the wrapper DLL and the DLL.config file to a new solution to test it out I get errors that the settings are not found.  If I add the settings to an app.config file for my test application, everything runs fine.  It seems that the DLL is looking for its settings in the app.config instead of the dll.config.  I have seen several posts stating that I should merge the settings from the DLL.config file into the APP.config file or add something in the APP.config file to point to my DLL.config file.  I really don't want to do this as I'll be integrating my DLL with 3rd party applications and I'd like to stay out of 3rd party configuration files.  Also, since this DLL is a wrapper for a WCF service, I don't want to write my own code to pick up the settings from my DLL.config file or a settings file.  It should happen automatically (i.e. picking up the settings when you call into the constructor of a class extending from System.ServiceModel.ClientBase<T>.  This code is all generated by svcutil.exe). 

I know I must be missing some small detail here.  Does anyone have any idea?  Thanks in advance to anyone with suggestions. 

Here's my DLL.config file that I'm trying to use.  Just to reiterate, the settings work fine if placed in the app.config but when placed in the dll.config file they are ignored.  I need to find some way of telling the dll to get the settings from the dll.config instead of from the app.config file.

<?xml version = " 1.0 " encoding = " utf-8 " ?>

< 配置 >

< configuration >

推荐答案

您能否尝试将web.config设置为:--

Can you try setting your web.config as : -

Web.config

< system.serviceModel>  
   
<行为 configSource = " ; config \ system.servicemodel.behaviors.config; />  
   
<绑定 configSource = " ; config \ system.servicemodel.bindings.config; />  
   
<客户端 configSource = " ; config \ system.servicemodel.client.config; />  
 
</system.serviceModel>  

<system.serviceModel> 
   
<behaviors configSource="config\system.servicemodel.behaviors.config" /> 
   
<bindings configSource="config\system.servicemodel.bindings.config" /> 
   
<client configSource="config\system.servicemodel.client.config" /> 
 
</system.serviceModel> 

system.servicemodel.behaviors.config

<? xml版本 = "1.0" 编码 = "utf-8" ?>  
< bindings>  
   
<!-绑定配置资料->  
</bindings>
 

<?xml version="1.0" encoding="utf-8"?> 
<bindings> 
   
<!-- binding configuration stuff --> 
</bindings>
 


这篇关于DLL.Config文件被忽略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆