473,508 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reading exe app.config from DLL in .NET 2.x

I have been attempting to read a value from the starting executable while in
a DLL.

So far have tried the following were "Test" is a defined value in the EXE.
What is returned is a blank/empty string
System.Configuration.ConfigurationManager.AppSetti ngs.Item("Test")

Did some research on Google but only found people untried suggestions, none
that work in .NET Framework 2.
Any thoughts?

Kevin
Jul 31 '07 #1
5 3828
"Kevin S Gallagher" <ke***************@state.or.uswrote in
news:er**************@TK2MSFTNGP04.phx.gbl:
I have been attempting to read a value from the starting executable
while in a DLL.

So far have tried the following were "Test" is a defined value in the
EXE. What is returned is a blank/empty string
System.Configuration.ConfigurationManager.AppSetti ngs.Item("Test")

Did some research on Google but only found people untried suggestions,
none that work in .NET Framework 2.
That usually works fine for me.

Are you getting a blank value? how does your App.config look like?
Jul 31 '07 #2
First thanks for chiming in!!!

Yes I am getting a blank value.
The best way to describe my app.config, enter a name to reference i.e.
"Test" and then enter a string value for "test" i.e. "Hello". I would
copy-n-paste my simple app.config here but needed to more forwards with an
alternate solution until my original question could be solved and now using
XML
This is my solution away from app.config in the DLL until someone can tell
me the correct method to read app.config from a supporting DLL
Public Class ReadConfiguration
Private strLogFile As String
Private strSendToMailAddress As String
Private strFromMailAddress As String
Private strServer As String

''' <summary>
'''
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
Public Property LogFile() As String
Get
Return strLogFile
End Get
Set(ByVal value As String)
strLogFile = value
End Set
End Property
Public Property SendToMailAddress() As String
Get
Return strSendToMailAddress
End Get
Set(ByVal value As String)
strSendToMailAddress = value
End Set
End Property
Public Property FromMailAddress() As String
Get
Return strFromMailAddress
End Get
Set(ByVal value As String)
strFromMailAddress = value
End Set
End Property
Public Property Server() As String
Get
Return strServer
End Get
Set(ByVal value As String)
strServer = value
End Set
End Property

Sub New()
If IO.File.Exists("unhandledExceptions.xml") Then
Using ConfigurationFile As New
System.Xml.XmlTextReader("unhandledExceptions.xml" )
ConfigurationFile.WhitespaceHandling =
System.Xml.WhitespaceHandling.None
Do While ConfigurationFile.Read()
If ConfigurationFile.NodeType =
System.Xml.XmlNodeType.Element Then
Select Case ConfigurationFile.Name
Case "PrimaryLogFile"
LogFile = ConfigurationFile.ReadString
Case "SendEmailTooAddress"
SendToMailAddress = ConfigurationFile.ReadString
Case "EmailFromAddress"
SendToMailAddress = ConfigurationFile.ReadString
Case "SmtpClientServer"
Server = ConfigurationFile.ReadString
End Select
End If
Loop
End Using
End If

End Sub
End Class
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<UHE>
<PrimaryLogFile>logExceptions.txt</PrimaryLogFile>
<SendEmailTooAddress></SendEmailTooAddress>
<EmailFromAddress></EmailFromAddress>
<SmtpClientServer></SmtpClientServer>
</UHE>

"Spam Catcher" <sp**********@rogers.comwrote in message
news:Xn**********************************@127.0.0. 1...
"Kevin S Gallagher" <ke***************@state.or.uswrote in
news:er**************@TK2MSFTNGP04.phx.gbl:
>I have been attempting to read a value from the starting executable
while in a DLL.

So far have tried the following were "Test" is a defined value in the
EXE. What is returned is a blank/empty string
System.Configuration.ConfigurationManager.AppSett ings.Item("Test")

Did some research on Google but only found people untried suggestions,
none that work in .NET Framework 2.

That usually works fine for me.

Are you getting a blank value? how does your App.config look like?

Jul 31 '07 #3
Seems like for the lack of response I am discontinuing this path and use my
alternate approach. Thanks for taking the time to at least consider a
solution/

"Kevin S Gallagher" <ke***************@state.or.uswrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
>I have been attempting to read a value from the starting executable while
in a DLL.

So far have tried the following were "Test" is a defined value in the EXE.
What is returned is a blank/empty string
System.Configuration.ConfigurationManager.AppSetti ngs.Item("Test")

Did some research on Google but only found people untried suggestions,
none that work in .NET Framework 2.
Any thoughts?

Kevin

Aug 1 '07 #4
I just saw the thread and wanted to chime in that we typically do some custom
config when making a dll, because we don't have any control at times on the
executable that calls our dll. We are making a dll for use by others. In a
case where you control the executables, the app.config does make sense, but
consider cases where a non-dotnet app may use your dll via com. Sometimes
you have to support both these environments.

"Kevin S Gallagher" wrote:
Seems like for the lack of response I am discontinuing this path and use my
alternate approach. Thanks for taking the time to at least consider a
solution/

"Kevin S Gallagher" <ke***************@state.or.uswrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
I have been attempting to read a value from the starting executable while
in a DLL.

So far have tried the following were "Test" is a defined value in the EXE.
What is returned is a blank/empty string
System.Configuration.ConfigurationManager.AppSetti ngs.Item("Test")

Did some research on Google but only found people untried suggestions,
none that work in .NET Framework 2.
Any thoughts?

Kevin


Aug 2 '07 #5
Thanks for your input/thoughts.

"ModelBuilder" <Mo**********@discussions.microsoft.comwrote in message
news:AF**********************************@microsof t.com...
>I just saw the thread and wanted to chime in that we typically do some
custom
config when making a dll, because we don't have any control at times on
the
executable that calls our dll. We are making a dll for use by others. In
a
case where you control the executables, the app.config does make sense,
but
consider cases where a non-dotnet app may use your dll via com. Sometimes
you have to support both these environments.

"Kevin S Gallagher" wrote:
>Seems like for the lack of response I am discontinuing this path and use
my
alternate approach. Thanks for taking the time to at least consider a
solution/

"Kevin S Gallagher" <ke***************@state.or.uswrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
>I have been attempting to read a value from the starting executable
while
in a DLL.

So far have tried the following were "Test" is a defined value in the
EXE.
What is returned is a blank/empty string
System.Configuration.ConfigurationManager.AppSetti ngs.Item("Test")

Did some research on Google but only found people untried suggestions,
none that work in .NET Framework 2.
Any thoughts?

Kevin



Aug 3 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2038
by: Sami | last post by:
Hello, I have this problem that I need your help with : I am reading a config file that contain the following : 2004 update
3
2411
by: spacekid | last post by:
Hi there I am exposing a c# assembly as a COM component (regasm /codebase) and calling it from classic asp. When I try to call the ConfigurationSettings.AppSettings function in the c# assembly,...
2
5081
by: news.microsoft.com | last post by:
Hi After conducting a several searches, I wasn't sure where to post this question. So my apologiesbefore hand for double posting this and possibly posting to the wrong forum(s). Okay, I have...
1
1682
by: comic_rage | last post by:
Hi, I am trying to read from my application config file and keep getting null. Here is my config file My application is called SampleApp.exe
10
9417
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
2
1537
by: marek zegarek | last post by:
Hello! On my server I have Sharepoint portal server as default web site I create there a web application folder with form.aspx file. When I'm trying to run aspx, i get an error. Page is trying...
5
10325
by: alf | last post by:
Hi folks, I'm trying to read a web.config section using RoleManagerSection settings = (RoleManagerSection)System.Configuration.ConfigurationManager.GetSection("system.web/roleManager"); and I...
9
2693
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): ...
1
7471
by: M Irfan | last post by:
Hello all, Recently I have started working in .NET 2.0. I am developing a web service application that references a DLL component written in C# 2.0. The component has its own config file which...
1
2241
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7383
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1557
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.