带有类库的App.config [英] App.config with a Class library

查看:96
本文介绍了带有类库的App.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在visual studio 2008(.net 3.5)中创建了一个DLL(类库),这个DLL与应用程序有一些依赖关系。配置。在app.config里面,我有一些关于使用特定肥皂网服务消费的配置。

嗯,这是问题,我必须拿这个DLL并在另一个代码中使用,但我不知道怎么做,因为我的这个app.config有这些依赖关系。

我知道如何使用 ConfigurationSettings.AppSettings 来检索配置参数,但是,我不认为这是否是正确的想法。

这里有人知道DLL的分布吗?



(ps:如果我的英语不是很好对不起,英语不是我的第一语言。)



Att,



Alex Duzi。

解决方案



我有同样的问题......类似!

我正在开发一个dll类库COM Interop,可以导出为TLB文件,所以我可以在VAC项目中使用这些功能驻留在MS ACCESS数据库上。



我正在尝试做的一件事是为MS Access DB实现一个用户管理系统,该系统使用成员资格提供程序进行身份验证,角色,也可能是个人资料。我已经阅读了很多关于客户端应用程序服务的论文,它通过与使用SQL Server进行成员资格数据存储的基于LAN的Web服务进行交互,直接在WinForms项目中使用ASP.NET Membeship功能。当我尝试通过WinForm VS Project使用此服务时,所有工作正常,因为它正确加载自己的app.settings文件,其中包含有关在何处查找提供程序的信息。但是,问题是:当我使用MS ACCESS引用的类库中的这些设置时,hoster应用程序没有所有提供程序配置,所以如果我在提供程序集合中,我只能找到默认的SqlMembershipProvider而不是 ClientApplicationProvider自己从项目中配置>属性> DLL VS Project的服务。



此时,当我从MS Access调用DLLibraries的类函数时,我无法与客户端服务提供程序进行交互。我可以做什么?我想知道运行时实例化成员资格提供程序直接进入我的DLL的可能性,而不读取任何配置文件,但我不知道如何实现此特定配置。你对这个问题有什么想法或其他工作流程吗?



多亏了提前,好工作!



Daniel Grandis


在类库dll中使用ConfigurationSettings.AppSettings时,实际读取的app.config是dll的主机。例如,如果在网站中使用dll,它将查找web.config。如果它在Windows窗体应用程序中使用,那么它将是app.config。



因此,您可以使用自己的逻辑读取设置的xml文件,从数据库中读取设置,或将设置复制到主机中.config文件。


感谢建议人员,但我已经制作了一个静态方法,在运行时返回Web服务的Bind。所以我不再需要app.config了!



谢谢



Duzi。

Hi everybody,

I made a DLL (class library) in visual studio 2008 (.net 3.5), and this DLL have some dependencies with the app.config. Inside the app.config, i have some configurations about the consume with a specific soap web service.
Well, here´s the problem, i have to take this DLL and use in another code, but i don´t know how do that, because my DLL have these dependencies whith this app.config.
I know how to use ConfigurationSettings.AppSettings to retrive the config parameters, but, im don´t think if this gonna be the right idea.
Anybody here know something about the DLL´s distribuition?

(ps: if my inglish is not very good im sorry, inglish is not my first language).

Att,

Alex Duzi.

解决方案

Hi,
I've the same problem... similar!
I'm working for developing a dll class library COM Interop enabled to export as TLB file so I can use these features on a VBA Project reside on a MS ACCESS database.

One of things that I'm trying to do is to implement a user management system for the MS Access DB that using Membership provider for authentication, roles and may be also profile. I've read many paper on Client Application Service for using ASP.NET Membeship features directly on a WinForms project, by interacting with an "LAN-Based web-service" that uses SQL Server for Membership data store. All working fine while I'm try to operate with this service by a WinForm VS Project, 'cause it correctly load own app.settings file that contains info about where to find the Provider. But, the problem is: when I use these settings from the Class Library referenced onto MS ACCESS, the hoster application not have all the provider configuration, so if i cicle inside providers collection I can only find the default "SqlMembershipProvider" and not the "ClientApplicationProvider" configured from myself from the Project > Properties > Services of the DLL VS Project.

At this moment, so, I'm unabled to interact with Client Service Provider when I call my class functions of DLLibraries from MS Access. What I can do? I'm wondering about the possibility of run-time instantiate membership provider direct into my DLL, without reading any config file, but I don't know how to implement this particular configuration. Do you have some idea, or other workflow to be adopted for that issue?

Thanks to all in advance, good job!

Daniel Grandis


When you use ConfigurationSettings.AppSettings in a class library dll, the app.config that is actually read is the host of the dll. For example, if the dll were used in a website it would look to web.config. If it were used in a Windows Forms app then it would be app.config.

So, you can either use your own logic to read in an xml file of settings, read the settings from the db, or copy your settings into the hosters .config file.


Thanks for the advise guys, but i´ve made a static method that return the Bind for the webservice at runtime. So i don´t need the app.config anymore!

thanks

Duzi.


这篇关于带有类库的App.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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