|
| config file for DLL |
|
|
|
|
| Messages |
|
Related Types |
This message was discovered on microsoft.public.dotnet.framework.interop.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Alex K. (VIP) |
| GOOD ANSWER |
I define a few constants in a C# DLL. I'd like to be able to store them externally instead of hard-coding them in the DLL's source. Is there any kind of DLL-level configuration file that I can read from my DLL?
Thank you.
|
|
|
| |
|
|
| |
| |
| Richard K Bethell |
| GOOD ANSWER |
"Alex K." <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
I have a similar problem. I have a regasm registered .NET dll that I am trying to call from asp pages. It looks like I cannot use the web.config file that the application's aspx pages would use. Is there a way to use a configuration file in some way or another, to return static properties?
Richard
|
|
|
| |
|
|
| |
| |
| Thomas S. Trias (VIP) |
| GOOD ANSWER |
I ran into a similar issue using COM interop from ASP (not ASP.NET, obviously) to call WebService proxy objects written using WSE 2.0; I couldn't use WSE Policy because I couldn't reference the config unless I wanted to deploy inetinfo.exe.config and dllhost.exe.config files to the web server.
Unfortunately, given no access to the base parsing mechanisms for the policy config, I had to home-grow my own solution via code; my classes now read up xml files (either in the deployment directory, current working directory, or specified by the object consumer) in order to set their configuration. I suppose you can do the same sort of thing, you just don't get it for free.
Thomas S. Trias Senior Developer Afni Insurance Services http://www.afniinc.com/
|
|
|
| |
|
|
| |
| |
| Alex K. (VIP) |
| GOOD ANSWER |
Thank you Thomas for your advice.
I have come to similar home-grown solution: I am using my own XML config file for DLL. It seems that DLL has no current run-time folder, therefore, class constructor defined in the DLL receives current path from client, to figure out where to look for the config file.
To pass this parameter I am using
Server.MapPath(".") + "\\"
for ASP clients, and
Environment.CurrentDirectory
for C# EXE clients.
Luckily, all my clients are located in the same directory with DLL so I don't need multiple config files. So, it is kind of tricky. It would be much easier if I can get original DLL folder from inside the DLL.
Alex.
"Thomas S. Trias" wrote:
[Original message clipped]
|
|
|
| |
|
|
| |
| |
| SA |
| GOOD ANSWER |
You can use
System.Reflection.Assembly.GetExecutingAssembly().CodeBase
to get the full path of the currently executing assembly (DLL file). You will have to strip the filename from the CodeBase property, but alternatively, it makes it easy to just append ".config" to it.
HTH
--
Sven
"Alex K." <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
|
| |
|
|
| |
| |
| Alex K. (VIP) |
| GOOD ANSWER |
Thanks Sven!!! It works! The only thing I need to add is to convert CodeBase to URI AbsolutePath or LocalPath (both work fine):
string s = System.Reflection.Assembly.GetExecutingAssembly().CodeBase; s += ".config";
Uri uu = new Uri(s); strFileName = uu.LocalPath; //uu.AbsolutePath - also works;
Alex
"SA" wrote:
[Original message clipped]
|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
BootFX
Reliable and powerful .NET application framework. |
|
|
|
|
|
|