app.config and web.config problems

Hi all,

I've structured my application in the following way.:
1. I've created a library project (.dll) with the BLL and DAL (built using the DataSet VS 2005 designer), at this moment I was asked to put the connection string inside of an app.config file (decrypted).
2. In a second project (Web Application) I've put a reference for the .dll mentioned above.
3. When I ran the web project for the first time I've got an error indicating that the .dll didn't find the connectionstring used to build the DAL so after some tips I performed a "copy and paste" from app.config to web.config .... ran the program again and the dll wasn't able to find the connection string again :-(

** Below the file that wasn't working ***
 
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->

<configuration>

<configSections>
</configSections>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="DLLConnectionString" connectionString="Data Source=serverDLL;Initial Catalog=DLLDB;User ID=prog;Password=******" providerName="System.Data.SqlClient" />
<add name="OtherConnectionString" connectionString="Data Source=serverXXX;Initial Catalog=OtherDB;Persist Security Info=True;User ID=prog;Password=******" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->

</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information" />
</switches>
<sharedListeners>
<add name="FileLog"
                 type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"
                 initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->

</sharedListeners>
</system.diagnostics>

<appSettings/>

<!--<connectionStrings>

</connectionStrings>-->


<system.web>
<!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions
            where data loss can occur.
            Set explicit="true" to force declaration of all variables.
        -->

<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies></compilation>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
</pages>
<!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
<!--<authentication mode="Windows"/>-->

<authentication mode="Forms">
<forms cookieless="AutoDetect" loginUrl="~/AccessDenied.aspx" name="RONLINEFORMAUTH"/>
</authentication>
<membership defaultProvider="RONLINE_MembershipProvider" userIsOnlineTimeWindow="15">
<providers>
<add name="RONLINE_MembershipProvider" connectionStringName="SegurancaMiraConnectionString" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="3" passwordAttemptWindow="0" minRequiredPasswordLength="0" minRequiredNonalphanumericCharacters="0" type="VSSLibAuditorOnline.Mirasoft.Membership.MiraMembershipProvider"/>
</providers>
</membership>
<!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

         <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->

</system.web>

</configuration>

 
0
marcossoft
4/11/2008 9:03:09 PM
asp.net.config-deploy 12495 articles. 0 followers. Follow

1 Replies
1037 Views

Similar Articles

[PageSpeed] 50
Get it on Google Play
Get it on Apple App Store

Hi  marcossoft,

How do you access your connection string ? Remember, that you use the ConfigurationManager (System.Configuration.dll) for Windows "executable" applications  and WebConfigurationManager (System.Web.Configuration.dll) for asp.net applications:

 so your code might look something like this:

 

string connectionString;
if (HttpContext.Current != null) // asp.net app
{
   connectionString = WebConfigurationManager.ConnectionStrings["myConnection"].ConnectionString;
}
else // windows app
{
   connectionString = ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString;
}
 
 
Łukasz Podolak
0
podi
4/12/2008 8:09:17 PM
Reply:

Web resources about - app.config and web.config problems - asp.net.config-deploy

Problem novel - Wikipedia, the free encyclopedia
Working class, or proletarian novels are often also social problem novels . This was in many ways a reaction to rapid industrialization , and ...

Corporate Australia's real problem: ancient companies
Our biggest companies are pretty aged, compared to the dynamic corporate giants that power the world's biggest economy.

Report claims Samsung Galaxy S7 will fix the biggest problem with the Galaxy S6
... Samsung ditched microSD support on the Galaxy S6. Well according to a new report on Monday, Samsung will fix the bigger of those two problems ...

November 2015: Unofficial Problem Bank list declines to 255 Institutions
This is an unofficial list of Problem Banks compiled only from public sources. Here is the unofficial problem bank list for November 2015. Changes ...

Acampora on problems in the market
Master technician Ralph Acampora says he has some doubts about this "fractured" market.

Tesla Unveils ‘Cheap’ $80,000 SUV, As Problems Mount For The Automaker
Tesla unveiled an $80,000 “budget” version of its Tesla Model X SUV Tuesday as the company struggles to sell cars and burns through cash at an ...

New York's anti-terror reporting app could easily cause problems
New York state is understandably more anxious than ever about terrorist threats, and it's hoping that some mobile technology will bolster its ...

Can Los Angeles Solve Its Traffic Problem By Building More Roads?
The Reason Foundation publishes a Los Angeles transportation plan that embraces reality over dogma.

Family evicted, building deemed unlivable: Landlord cannot fix problems, he was murdered
... A Milwaukee family has been forced to leave their apartment. Their building has been declared unlivable. The landlord was required to fix problems ...

Icy roads causing problems for Thanksgiving travelers around Colorado Springs
Dress warm this holiday, temperatures Thursday are predicted to be colder...

Resources last updated: 11/28/2015 3:20:07 AM