Porblem having with Enti Lib 5.0 with my Asp.net mvc application

Oct 18, 2010 at 9:38 PM

Hello Friends, I am getting this Error.. This is my Web.config file..

<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
   
<listeners>
     
<add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" source="Enterprise Library Logging" formatter="Text Formatter" log="Application" machineName="." traceOutputOptions="None" />
     
<add name="Database Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.Database.FormattedDatabaseTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Database.Configuration.FormattedDatabaseTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" databaseInstanceName="MiscEntities" writeLogStoredProcName="WriteLog" addCategoryStoredProcName="AddCategory" />
     
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="BenefitBuilder.log" formatter="Text Formatter" rollFileExistsBehavior="Increment" rollInterval="Day" />
   
</listeners>
   
<formatters>
     
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp}{newline}&#xA;Message: {message}{newline}&#xA;Category: {category}{newline}&#xA;Priority: {priority}{newline}&#xA;EventId: {eventid}{newline}&#xA;Severity: {severity}{newline}&#xA;Title:{title}{newline}&#xA;Machine: {localMachine}{newline}&#xA;App Domain: {localAppDomain}{newline}&#xA;ProcessId: {localProcessId}{newline}&#xA;Process Name: {localProcessName}{newline}&#xA;Thread Name: {threadName}{newline}&#xA;Win32 ThreadId:{win32ThreadId}{newline}&#xA;Extended Properties: {dictionary({key} - {value}{newline})}" name="Text Formatter" />
   
</formatters>
   
<categorySources>
     
<add switchValue="All" name="General">
       
<listeners>
         
<add name="Rolling Flat File Trace Listener" />
         
<add name="Database Trace Listener" />
         
<add name="Event Log Listener" />
       
</listeners>
     
</add>
     
<add switchValue="All" name="Database">
       
<listeners>
         
<add name="Database Trace Listener" />
       
</listeners>
     
</add>
     
<add switchValue="All" name="RollingFlatFile">
       
<listeners>
         
<add name="Rolling Flat File Trace Listener" />
       
</listeners>
     
</add>
     
<add switchValue="All" name="EventLog">
       
<listeners>
         
<add name="Event Log Listener" />
       
</listeners>
     
</add>
   
</categorySources>
   
<specialSources>
     
<allEvents switchValue="All" name="All Events">
       
<listeners>
         
<add name="Rolling Flat File Trace Listener" />
       
</listeners>
     
</allEvents>
     
<notProcessed switchValue="All" name="Unprocessed Category">
       
<listeners>
         
<add name="Rolling Flat File Trace Listener" />
       
</listeners>
     
</notProcessed>
     
<errors switchValue="All" name="Logging Errors &amp; Warnings">
       
<listeners>
         
<add name="Event Log Listener" />
       
</listeners>
     
</errors>
   
</specialSources>
 
</loggingConfiguration>
 
<exceptionHandling>
   
<exceptionPolicies>
     
<add name="Benefit Builder Policy">
       
<exceptionTypes>
         
<add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="None">
           
<exceptionHandlers>
             
<add name="Logging Exception Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" logCategory="General" eventId="100" severity="Error" title="Enterprise Library Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" priority="0" />
           
</exceptionHandlers>
         
</add>
       
</exceptionTypes>
     
</add>
   
</exceptionPolicies>
 
</exceptionHandling>

Activation error occured while trying to get instance of type LogWriter, key When I using my Logging error ..

this is the code to log my error in my ControllerBase.cs

private static void LogException( Exception ex, ExceptionContext filterContext ) {
           
if (Logger.IsLoggingEnabled())
           
{
               
var logEntry = MvcUnity.Container.Resolve<LogEntry>();
                logEntry
.Title = filterContext.Exception.Message;
                logEntry
.Message = filterContext.Exception.ToString();
                logEntry
.AddErrorMessage("Source: " + ex.Source + "/r/nTarget: " + ex.TargetSite + "/r/nMessage: " +
                                         ex
.Message + "/r/nHelp Link: " + ex.HelpLink + "/r/n");
                logEntry
.AddErrorMessage("Stack Trace: /r/n" + ex.StackTrace + "/r/n");
                logEntry
.AddErrorMessage("Data: /r/n" + ex.Data + "/r/n");
                logEntry
.AddErrorMessage("Inner Exception: " + ex.InnerException + "/r/n");
               
Logger.Write(logEntry);
           
}
       
}

I am getting Invalidaoperationexception

InvalidOperationException: The Type Database cannot be constructed,you mush configure the Container to supply this value

This Error I am getting while I am checking Logger.IsLogEnabled() and Logger.Write(logEntry)

Can any body help me out why its giving that error message?

thanks

Oct 18, 2010 at 11:26 PM

Can any body help me out with this problem?

thanks

Oct 18, 2010 at 11:57 PM
Edited Oct 18, 2010 at 11:59 PM

Are you referencing the Data assembly from GAC?  Please post this in the EntLib forum and let's continue the discussion there as this is not a Unity question.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com