App.Config File Errors

jesus4u

Well-known member
Joined
Feb 13, 2003
Messages
47
Wjy is it that when I use this code in a class being accessed from an aspx page that the values dont get loaded from the config file but when I use it in a windows form it works?

Code:
Config file
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
	<appSettings>
		<add key="ConnectionString" value="Initial Catalog=Replica;Data Source=localhost;Integrated Security=SSPI;" />
		<add key="PathToTranscripts" value="F:\Transcripts Backup\ParsedFiles" />
	</appSettings>
</configuration>


Code:
Class Code
Imports Word
Imports System
Imports System.IO
Imports System.Configuration
Imports System.Data.SqlClient
Imports Microsoft.ApplicationBlocks.Data

Namespace Transcripts
    Public Class Tools
        Dim conn As New SqlConnection
        Dim strPathToTranscripts As String     
        Dim ds As New DataSet

        Public Sub New()
            conn.ConnectionString = ConfigurationSettings.AppSettings("ConnectionString")
            strPathToTranscripts = ConfigurationSettings.AppSettings("PathToTranscripts")
        End Sub

etc......
 
Originally posted by PlausiblyDamp
What is the config file named. For web apps it should be web.config

I am using a Class file in its own project NOT a web app.
 
IIRC the dll will use the default config file name for the calling application - if from an exe the app.exe.config , from asp.net web.config
 
Back
Top