Home All Groups Group Topic Archive Search About

Enterprise Library 2.0 configuration error

Author
26 Mar 2007 6:34 PM
dick69anderson
It is my intent to utilize the Enterprise Library Application Blocks.
I am new to dotNet.  I have downloaded the 'Enterprise Library -
January 2006' version.  The solution built successfully and I can
execute the 'Hands on Labs' for logging.  To transition to my code
base, I did the following:
created a C# console application,
added the project references
        (Microsoft.Practices.EnterpriseLibrary.Common.dll
        Microsoft.Practices.EnterpriseLibrary.Logging.dll
        Microsoft.Practices.ObjectBuilder.dll),
created the app.config file with the 'Enterprise Libray Configuration'
utility (contents below),
saved and closed both solution and configuration files.

When I execute the solution within Visual Studio 2005, I receive the
following error:

The configuration section for Logging
cannot be found in the configuration source.

A section with the name of "loggingConfiguration" definitely exists.
It is like it does not see my app.config file.



                -  app.config  contents -
<configuration>
    <configSections>
        <section name="loggingConfiguration"
type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null" />
    </configSections>
    <loggingConfiguration name="Logging Application Block"
tracingEnabled="true"
        defaultCategory="General"
logWarningsWhenNoCategoriesMatch="true">
        <listeners>
            <add source="Enterprise Library Logging" formatter="Text
Formatter"
                log="Btest" machineName=""
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null"
                traceOutputOptions="None"
type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null"
                name="Formatted EventLog TraceListener" />
        </listeners>
        <formatters>
            <add template="Timestamp: {timestamp}&#xD;&#xA;Message:
{message}&#xD;&#xA;Category: {category}&#xD;&#xA;Priority:
{priority}&#xD;&#xA;EventId: {eventid}&#xD;&#xA;Severity:
{severity}&#xD;&#xA;Title:{title}&#xD;&#xA;Machine:
{machine}&#xD;&#xA;Application Domain: {appDomain}&#xD;&#xA;Process
Id: {processId}&#xD;&#xA;Process Name: {processName}&#xD;&#xA;Win32
Thread Id: {win32ThreadId}&#xD;&#xA;Thread Name:
{threadName}&#xD;&#xA;Extended Properties: {dictionary({key} -
{value}&#xD;&#xA;)}"

type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=null"
                name="Text Formatter" />
        </formatters>
        <categorySources>
            <add switchValue="All" name="General">
                <listeners>
                    <add name="Formatted EventLog TraceListener" />
                </listeners>
            </add>
        </categorySources>
        <specialSources>
            <allEvents switchValue="All" name="All Events" />
            <notProcessed switchValue="All" name="Unprocessed
Category" />
            <errors switchValue="All" name="Logging Errors &amp;
Warnings">
                <listeners>
                    <add name="Formatted EventLog TraceListener" />
                </listeners>
            </errors>
        </specialSources>
    </loggingConfiguration>
</configuration>



                -  MyLoggingBTest.cs  contents -
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;

namespace MyLoggingBTest
{
    class Program
    {
        static void Main(string[] args)
        {
            LogEntry log = new LogEntry();
            log.Message = string.Format("Logging has been successfully
added to the application ");
            Logger.Write(log);

        }
    }
}

Would anyone be willing to steer me in the right direction?

Thanks

Author
4 Apr 2007 7:26 AM
Phil Bolduc
Was the app.config file added to your project?

Was the app.config file copied to output directory with name
MyLoggingBTest.exe.config ? (assuming your exe was generated with that name)

Was the Enterprise Library 2.0 assemblies copied to the output directory?


Show quote
"dick69ander***@yahoo.com" wrote:

> It is my intent to utilize the Enterprise Library Application Blocks.
> I am new to dotNet.  I have downloaded the 'Enterprise Library -
> January 2006' version.  The solution built successfully and I can
> execute the 'Hands on Labs' for logging.  To transition to my code
> base, I did the following:
> created a C# console application,
> added the project references
>         (Microsoft.Practices.EnterpriseLibrary.Common.dll
>         Microsoft.Practices.EnterpriseLibrary.Logging.dll
>         Microsoft.Practices.ObjectBuilder.dll),
> created the app.config file with the 'Enterprise Libray Configuration'
> utility (contents below),
> saved and closed both solution and configuration files.
>
> When I execute the solution within Visual Studio 2005, I receive the
> following error:
>
> The configuration section for Logging
> cannot be found in the configuration source.
>
> A section with the name of "loggingConfiguration" definitely exists.
> It is like it does not see my app.config file.
>
>
>
>                 -  app.config  contents -
> <configuration>
>     <configSections>
>         <section name="loggingConfiguration"
> type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=null" />
>     </configSections>
>     <loggingConfiguration name="Logging Application Block"
> tracingEnabled="true"
>         defaultCategory="General"
> logWarningsWhenNoCategoriesMatch="true">
>         <listeners>
>             <add source="Enterprise Library Logging" formatter="Text
> Formatter"
>                 log="Btest" machineName=""
> listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=null"
>                 traceOutputOptions="None"
> type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=null"
>                 name="Formatted EventLog TraceListener" />
>         </listeners>
>         <formatters>
>             <add template="Timestamp: {timestamp}
Message:
> {message}
Category: {category}
Priority:
> {priority}
EventId: {eventid}
Severity:
> {severity}
Title:{title}
Machine:
> {machine}
Application Domain: {appDomain}
Process
> Id: {processId}
Process Name: {processName}
Win32
> Thread Id: {win32ThreadId}
Thread Name:
> {threadName}
Extended Properties: {dictionary({key} -
Show quote
> {value}
)}"

> type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
> Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0,
> Culture=neutral, PublicKeyToken=null"
>                 name="Text Formatter" />
>         </formatters>
>         <categorySources>
>             <add switchValue="All" name="General">
>                 <listeners>
>                     <add name="Formatted EventLog TraceListener" />
>                 </listeners>
>             </add>
>         </categorySources>
>         <specialSources>
>             <allEvents switchValue="All" name="All Events" />
>             <notProcessed switchValue="All" name="Unprocessed
> Category" />
>             <errors switchValue="All" name="Logging Errors &
> Warnings">
>                 <listeners>
>                     <add name="Formatted EventLog TraceListener" />
>                 </listeners>
>             </errors>
>         </specialSources>
>     </loggingConfiguration>
> </configuration>
>
>
>
>                 -  MyLoggingBTest.cs  contents -
> using System;
> using System.Collections.Generic;
> using System.Text;
> using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
> using Microsoft.Practices.EnterpriseLibrary.Logging;
>
> namespace MyLoggingBTest
> {
>     class Program
>     {
>         static void Main(string[] args)
>         {
>             LogEntry log = new LogEntry();
>             log.Message = string.Format("Logging has been successfully
> added to the application ");
>             Logger.Write(log);
>
>         }
>     }
> }
>
> Would anyone be willing to steer me in the right direction?
>
> Thanks
>
>

AddThis Social Bookmark Button