So I have this hierarchy:
+ Solution
|
|--- + Class Library Project
| |
| |--- LogError.vb
|
|--- + ASP .NET Web Application
|
|--- Web.config
I want to access from Web.config:
<appSettings>
<add key="sqlConnString" value="myDBString">
</appSettings>
from LogError.vb. Anyone know how I would go about doing this? 10 1897
First of all, it is my understanding that this sort of thing is not allowed.
Second, I am curious on why you want to do this.
Lastly, the web.config is just a text file and you can treat it as such if
you just need to read the contents. But; don't expect to configure your
class library project using the web.config file. Create a new config file
Or, use the machine.config file
"bradtm" <br****@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
Hi Brad.
If you want to read the binary web.config file you will need to use the
Server.MapPath methods.
Dim reader As New System.IO.StreamReader(Server.MapPath("web.config" ))
Dim value As String = reader.ReadToEnd
If you want to read the value inside the web.config section appSettings just
use the ConfigurationSetting namespace
Dim sqlConStr As String =
ConfigurationSettings.AppSettings("sqlConnString")
--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
I built an Application to log and view all the errors and bugs our
applications have. We use a common Class Library Project in many of our
applications. The LogError function is in one of these Class Libraries. In
order to store the Application ID of the error I need to access the
Application ID key in the Web.config file.
"Tampa.NET Koder" wrote: First of all, it is my understanding that this sort of thing is not allowed.
Second, I am curious on why you want to do this.
Lastly, the web.config is just a text file and you can treat it as such if you just need to read the contents. But; don't expect to configure your class library project using the web.config file. Create a new config file Or, use the machine.config file "bradtm" <br****@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
It won't let me use Server.MapPath in a Class Library.
"Jc Morin" wrote: Hi Brad. If you want to read the binary web.config file you will need to use the Server.MapPath methods.
Dim reader As New System.IO.StreamReader(Server.MapPath("web.config" )) Dim value As String = reader.ReadToEnd
If you want to read the value inside the web.config section appSettings just use the ConfigurationSetting namespace
Dim sqlConStr As String = ConfigurationSettings.AppSettings("sqlConnString")
-------------------------- Jean-Claude Morin, MCP Software Developer 2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
Your right!
If you add a reference to System.Web
You can probably do a work around and calculate the path like this:
Dim reader As New System.IO.StreamReader(System.Web.HttpRuntime.BinD irectory
& "/../web.config")
--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message
news:0A**********************************@microsof t.com... It won't let me use Server.MapPath in a Class Library.
"Jc Morin" wrote:
Hi Brad. If you want to read the binary web.config file you will need to use the Server.MapPath methods.
Dim reader As New System.IO.StreamReader(Server.MapPath("web.config" )) Dim value As String = reader.ReadToEnd
If you want to read the value inside the web.config section appSettings
just use the ConfigurationSetting namespace
Dim sqlConStr As String = ConfigurationSettings.AppSettings("sqlConnString")
-------------------------- Jean-Claude Morin, MCP Software Developer 2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
Cancel that.. I imported Server.Web.HttpServerUtility and called it by
MapPath(""). Gonna test it out now.
"bradtm" wrote: It won't let me use Server.MapPath in a Class Library.
"Jc Morin" wrote:
Hi Brad. If you want to read the binary web.config file you will need to use the Server.MapPath methods.
Dim reader As New System.IO.StreamReader(Server.MapPath("web.config" )) Dim value As String = reader.ReadToEnd
If you want to read the value inside the web.config section appSettings just use the ConfigurationSetting namespace
Dim sqlConStr As String = ConfigurationSettings.AppSettings("sqlConnString")
-------------------------- Jean-Claude Morin, MCP Software Developer 2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
Awesome. That worked out. Thanks a lot.
"Jc Morin" wrote: Your right!
If you add a reference to System.Web You can probably do a work around and calculate the path like this:
Dim reader As New System.IO.StreamReader(System.Web.HttpRuntime.BinD irectory & "/../web.config")
-------------------------- Jean-Claude Morin, MCP Software Developer 2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message news:0A**********************************@microsof t.com... It won't let me use Server.MapPath in a Class Library.
"Jc Morin" wrote:
Hi Brad. If you want to read the binary web.config file you will need to use the Server.MapPath methods.
Dim reader As New System.IO.StreamReader(Server.MapPath("web.config" )) Dim value As String = reader.ReadToEnd
If you want to read the value inside the web.config section appSettings just use the ConfigurationSetting namespace
Dim sqlConStr As String = ConfigurationSettings.AppSettings("sqlConnString")
-------------------------- Jean-Claude Morin, MCP Software Developer 2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... > So I have this hierarchy: > > + Solution > | > |--- + Class Library Project > | | > | |--- LogError.vb > | > |--- + ASP .NET Web Application > | > |--- Web.config > > I want to access from Web.config: > > <appSettings> > <add key="sqlConnString" value="myDBString"> > </appSettings> > > from LogError.vb. Anyone know how I would go about doing this? >
My interpretation is slightly different then the other posts. I understand
your question as simply being able to access the configuration information
from the class library the same way you would in the web app (such as
ConfigurationSettings.AppSettings["..."]).
If this is your question, you can add a reference to your class library in
the web app. From there you can access any of the configuration settings
normally.
"bradtm" <br****@discussions.microsoft.com> wrote in message
news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config
I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings>
from LogError.vb. Anyone know how I would go about doing this?
As Peter mentioned in the other thread you should be able to use
ConfigurationSettings.AppSettings. This reads the settings for the
application your library is hosted in. No need to manually open and
parse the web.config.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 24 Feb 2005 19:35:02 -0800, bradtm
<br****@discussions.microsoft.com> wrote: Awesome. That worked out. Thanks a lot.
"Jc Morin" wrote:
Your right!
If you add a reference to System.Web You can probably do a work around and calculate the path like this:
Dim reader As New System.IO.StreamReader(System.Web.HttpRuntime.BinD irectory & "/../web.config")
-------------------------- Jean-Claude Morin, MCP Software Developer 2k1Soft/kCentric, Canada
"bradtm" <br****@discussions.microsoft.com> wrote in message news:0A**********************************@microsof t.com... > It won't let me use Server.MapPath in a Class Library. > > "Jc Morin" wrote: > > > Hi Brad. > > If you want to read the binary web.config file you will need to use the > > Server.MapPath methods. > > > > Dim reader As New System.IO.StreamReader(Server.MapPath("web.config" )) > > Dim value As String = reader.ReadToEnd > > > > If you want to read the value inside the web.config section appSettings just > > use the ConfigurationSetting namespace > > > > Dim sqlConStr As String = > > ConfigurationSettings.AppSettings("sqlConnString") > > > > > > -------------------------- > > Jean-Claude Morin, MCP > > Software Developer > > 2k1Soft/kCentric, Canada > > > > > > "bradtm" <br****@discussions.microsoft.com> wrote in message > > news:79**********************************@microsof t.com... > > > So I have this hierarchy: > > > > > > + Solution > > > | > > > |--- + Class Library Project > > > | | > > > | |--- LogError.vb > > > | > > > |--- + ASP .NET Web Application > > > | > > > |--- Web.config > > > > > > I want to access from Web.config: > > > > > > <appSettings> > > > <add key="sqlConnString" value="myDBString"> > > > </appSettings> > > > > > > from LogError.vb. Anyone know how I would go about doing this? > > > > > > > > >
Hello Tampa.NET Koder" t_davisjr[at]hotmail.com,
Why cant you use the ConfigurationSettings api to access those settings?
As long as your ASP.NET app has a reference to the class library project,
the class library can use that API to retrieve settings from the parent applications
config file (either app.config or web.config).
--
Matt Berther http://www.mattberther.com First of all, it is my understanding that this sort of thing is not allowed.
Second, I am curious on why you want to do this.
Lastly, the web.config is just a text file and you can treat it as such if you just need to read the contents. But; don't expect to configure your class library project using the web.config file. Create a new config file Or, use the machine.config file "bradtm" <br****@discussions.microsoft.com> wrote in message news:79**********************************@microsof t.com... So I have this hierarchy:
+ Solution | |--- + Class Library Project | | | |--- LogError.vb | |--- + ASP .NET Web Application | |--- Web.config I want to access from Web.config:
<appSettings> <add key="sqlConnString" value="myDBString"> </appSettings> from LogError.vb. Anyone know how I would go about doing this? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bragadiru |
last post by:
I have a solution with 2 projects: a class library(my.dll) + a windows
application (mine.exe). In exe project I have a reference to the dll. In
both I have app.config files, BUT only...
|
by: Dave Kolb |
last post by:
Is there any other solution for an ASPNET application to access
network resources other than running as SYSTEM, using delegation (a
nightmare to get to work) or the COM+ solution? I cannot seem to...
|
by: Big Dave |
last post by:
Good morning. I have a solution set up with multiple projects. One
is a web project and it contains my web.config file. I would like to
build a class within another project (a class library)...
|
by: Jody Gelowitz |
last post by:
We are having an issue in that when trying to read a file that is on Server2
from Server1 (through our ASP.NET project), we receive the error:
Access to the path "\\Server2\MyShare\MyFile.tif" is...
|
by: Fred Nelson |
last post by:
Hi:
I have written several web applications that obtain their connection
strings from the web.config file. This is very easy to use and it makes
it easy to move an app from development into...
| |
by: Asela Gunawardena |
last post by:
we have a web site which operates as a seperate application that can be
integrated with other webs site developped to use other platforms such as
php, jsp, etc. so obivously we have our own...
|
by: Allen Browne |
last post by:
If you develop for others, you probably have multiple versions of Access
installed so you can edit and create MDEs for clients in different versions.
This works fine under Windows XP, even with...
|
by: TS |
last post by:
I cannot get this to work. I added an app.config to a project i reference
from my web application project (vs 05) but can see no way to access the
settings within it.
the other thing is that I...
|
by: bz |
last post by:
Hi,
I have a library project that implements a Business Layer for a web
and a desktop application
All my business classes are in this lib, so I have here the connection
string to database as...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
| |
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |