Quantcast
Channel: patterns & practices – Enterprise Library
Viewing all 1928 articles
Browse latest View live

Updated Wiki: EntLib6 Sample Projects

$
0
0

Enterprise Library V6 Sample Projects

The following sample projects illustrate various Enterprise Library concepts and techniques.

Custom Database Trace Listener Sample

Description

This sample project shows a sample of a Custom Database Trace Listener that adds an additional column to the out of the boxFormattedDatabaseTraceListener.  The CustomDatabaseTraceListener will check the LogEntry to see if it is a CustomLogEntry and if it is then it will add the CustomData information into the CustomData column in the [Log] table.  

The Custom Database Trace Listener also support full design time integration with the Enterprise Library configuration tool as well as support for use with Enterprise Library's Fluent API.  

Download: 

Requirements

  • Enterprise Library 6 (Assembly version 6.0.0.0).
  • Microsoft .NET Framework 4.5
  • Microsoft Visual Studio 2012
  • A database server running a database that is supported by a .NET Framework 4.5 data provider.  The provided script  does not work with SQL AZURE.  For SQL Azure support, modify the out of the box CreateLoggingDatabaseObjects.sql to include the CustomData column (as well as in stored procedures).

Updated Wiki: EntLib6 Sample Projects

$
0
0

Enterprise Library V6 Sample Projects

The following sample projects illustrate various Enterprise Library concepts and techniques.

Custom Database Trace Listener Sample

Description

This sample project shows a sample of a Custom Database Trace Listener that adds an additional column to the out of the boxFormattedDatabaseTraceListener.  The CustomDatabaseTraceListener will check the LogEntry to see if it is a CustomLogEntry and if it is then it will add the CustomData information into the CustomData column in the [Log] table.  

The Custom Database Trace Listener also support full design time integration with the Enterprise Library configuration tool as well as support for use with Enterprise Library's Fluent API.  

Requirements

  • Enterprise Library 6 (Assembly version 6.0.0.0).
  • Microsoft .NET Framework 4.5
  • Microsoft Visual Studio 2012
  • A database server running a database that is supported by a .NET Framework 4.5 data provider.  The provided script  does not work with SQL AZURE.  For SQL Azure support, modify the out of the box CreateLoggingDatabaseObjects.sql to include the CustomData column (as well as in stored procedures).

Updated Wiki: Home

$
0
0
The new Semantic Logging Application Block CTP is out! Get it now

The Microsoft Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development challenges. Application blocks are provided as source code plus documentation that can be used "as is," extended, or modified by developers to use on complex, enterprise-level line-of-business development projects.

DOWNLOADOfficial releasesPREVIEWCurrent Roadmap, Past Roadmaps
Current release - April 2010 (5.0), Silverlight Integration Pack - May 2011, Windows Azure Integration Pack - Nov 2011, Previous releasesEnterprise Library 6.0new.png
Standalone Unity, Unity 2.1 - Aug 2012 Update, Unity 3.0 for .NET4.5 Previewnew.png Follow @mspnp, @gmelnik and the #entlib hashtag
LEARNHands-on LabsGET SUPPORTDiscussion Forum
EntLib5 Developer's GuideIssue Tracker
Videos, Webcast DemosSupport How-to
EntLib FAQSample Projects
Reference documentationEntLib6 Sample Projects
CONTRIBUTE Share extensions via EntLibContrib Project (Jan 2010 Release)PROVIDE FEEDBACKEntLib satisfaction survey
Hosting your extension in your own CodePlex project? Tag it with Enterprise LibrarySubmit suggestions
Report bugs


News

 Grigori Melnik: Thoughts on Agile Software Engineering and Beyond : Enterprise Library News Feed 
 Grigori Melnik: Thoughts on Agile Software Engineering and Beyond : Enterprise Library News Feed 


patterns & practices Links

New Post: Custom db with Enterprise Library 6

New Post: How to log errors through MSMQ using Logger ?

$
0
0
Hi

I have custom exception handler written and part of it is supposed to log messages in Text File. I am trying to use Logger class to log messages in MSMQ. I got following error


Thanks in Advance.

Exception Information Details:

Exception Type: System.Messaging.MessageQueueException
MessageQueueErrorCode: UnsupportedFormatNameOperation
Message: The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted.
ErrorCode: -2147467259
Data: System.Collections.ListDictionaryInternal
TargetSite: Void SendInternal(System.Object, System.Messaging.MessageQueueTransaction, System.Messaging.MessageQueueTransactionType)
HelpLink: NULL
Source: System.Messaging

StackTrace Information Details:

at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransactionType transactionType)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.MsmqSendInterface.Send(Message message, MessageQueueTransactionType transactionType)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.MsmqTraceListener.SendMessageToQueue(LogEntry logEntry)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.MsmqTraceListener.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
at Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.TraceListenerWrapper.TraceData(TraceEventCache eventCache, String source, TraceEventType eventType, Int32 id, Object data)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogSource.TraceData(TraceEventType eventType, Int32 id, LogEntry logEntry, TraceListenerFilter traceListenerFilter, TraceEventCache traceEventCache)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterImpl.ProcessLog(LogEntry log, TraceEventCache traceEventCache)

Category:

Priority: -1

EventId: 6352

Severity: Error

Title:

Machine: xxxxxxx

App Domain: /LM/W3SVC/1/ROOT/Test.Login.Host-2-130189672514987177

ProcessId: 7964

Process Name: C:\Windows\SysWOW64\inetsrv\w3wp.exe

Thread Name:

Win32 ThreadId:4408

Extended Properties:

New Post: How to log errors through MSMQ using Logger ?

New Post: How to log errors through MSMQ using Logger ?

$
0
0
Hi Randy,


Thanks for Reply. What I am trying to achieve was through Enterprise library I created custom exception handler and one loging handler and wants both of them to work at same time ie. first log message through MSMQ and then executes my custom exception handler. I tried it few different ways


1) I tried logging it through logger class
2) I created two handlers for same exception


I didnt do any encryption and queue is non transactional.

I checked permissions on the queue and my default app pool has full permissions for that particular queue.



Regards,

New Post: Entlib 6.0 Custom Configuration Source is not working

$
0
0
Please see below issue detail-

I downloaded Entlib 6.0 from codeplex.com and created custom configuration source as Entlib.config and referred as a source in App.Config. And called the C# code to write logging. I got the below error message.

Error Message: "The configuration section for Logging cannot be found in the configuration source."

I. App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<enterpriseLibrary.ConfigurationSource selectedSource="fileSource"
parentSource="fileSource">
<sources>
  <add name="fileSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    filePath="C:\App_Data\Entlib.config" />
</sources>
<redirectSections>
  <add sourceName="fileSource" name="loggingConfiguration" />
</redirectSections>
</enterpriseLibrary.ConfigurationSource>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

II. Entlib.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
  <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    source="Enterprise Library Logging" formatter="Text Formatter"
    log="Client" machineName="." traceOutputOptions="None" />
  <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    fileName="rolling.log" formatter="Text Formatter"
    rollInterval="Day" />
</listeners>
<formatters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.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="Event Log Listener" />
    </listeners>
  </add>
</categorySources>
<specialSources>
  <allEvents switchValue="All" name="All Events">
    <listeners>
      <add name="Event Log Listener" />
      <add name="Rolling Flat File Trace Listener" />
    </listeners>
  </allEvents>
  <notProcessed switchValue="All" name="Unprocessed Category" />
  <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
      <add name="Event Log Listener" />
    </listeners>
  </errors>
</specialSources>
</loggingConfiguration>
</configuration>

III. C# code on button event.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void btnLogging_Click(object sender, EventArgs e)
    {
        WriteLogEvent("Important", 1, "btnLogging_Click",TraceEventType.Information, 23);
    }

    public static string WriteLogEvent(string Category, int EventID, string Message, TraceEventType Severity, int Priority)
    {
        LogEntry LogEntry = null;
        string StatusMessage = string.Empty;
        try
        {
            IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
            LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
            LogEntry = new LogEntry();
            LogEntry.Categories.Add(Category);
            LogEntry.EventId = EventID;
            LogEntry.Message = Message;
            LogEntry.TimeStamp = DateTime.Now;
            LogEntry.Severity = Severity;
            LogEntry.Priority = Priority;
            LogEntry.GetProcessName();
            LogEntry.Title = "SmartClient Test Log";


           Logger.SetLogWriter(new LogWriterFactory().Create());

                Logger.Write(LogEntry);
                StatusMessage = "Successful";


        }
        catch (Exception ex)
        {

        }
        return null;
    }
}
Could you please provide help to resolve the issue.

New Post: How to use static logger??? Logging Application Block

$
0
0
__Entlib 6.0 Custom Configuration Source is not working
__
Please see below issue detail-

I downloaded Entlib 6.0 from codeplex.com and created custom configuration source as Entlib.config and referred as a source in App.Config. And called the C# code to write logging. I got the below error message.

Error Message: "The configuration section for Logging cannot be found in the configuration source."

I. App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<enterpriseLibrary.ConfigurationSource selectedSource="fileSource"
parentSource="fileSource">
<sources>
  <add name="fileSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    filePath="C:\App_Data\Entlib.config" />
</sources>
<redirectSections>
  <add sourceName="fileSource" name="loggingConfiguration" />
</redirectSections>
</enterpriseLibrary.ConfigurationSource>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

II. Entlib.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
</configSections>
<loggingConfiguration name="" tracingEnabled="true" defaultCategory="General">
<listeners>
  <add name="Event Log Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    source="Enterprise Library Logging" formatter="Text Formatter"
    log="Client" machineName="." traceOutputOptions="None" />
  <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    fileName="rolling.log" formatter="Text Formatter"
    rollInterval="Day" />
</listeners>
<formatters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.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="Event Log Listener" />
    </listeners>
  </add>
</categorySources>
<specialSources>
  <allEvents switchValue="All" name="All Events">
    <listeners>
      <add name="Event Log Listener" />
      <add name="Rolling Flat File Trace Listener" />
    </listeners>
  </allEvents>
  <notProcessed switchValue="All" name="Unprocessed Category" />
  <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
      <add name="Event Log Listener" />
    </listeners>
  </errors>
</specialSources>
</loggingConfiguration>
</configuration>

III. C# code on button event.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void btnLogging_Click(object sender, EventArgs e)
    {
        WriteLogEvent("Important", 1, "btnLogging_Click",TraceEventType.Information, 23);
    }

    public static string WriteLogEvent(string Category, int EventID, string Message, TraceEventType Severity, int Priority)
    {
        LogEntry LogEntry = null;
        string StatusMessage = string.Empty;
        try
        {
            IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
            LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
            LogEntry = new LogEntry();
            LogEntry.Categories.Add(Category);
            LogEntry.EventId = EventID;
            LogEntry.Message = Message;
            LogEntry.TimeStamp = DateTime.Now;
            LogEntry.Severity = Severity;
            LogEntry.Priority = Priority;
            LogEntry.GetProcessName();
            LogEntry.Title = "SmartClient Test Log";


           Logger.SetLogWriter(new LogWriterFactory().Create());

                Logger.Write(LogEntry);
                StatusMessage = "Successful";


        }
        catch (Exception ex)
        {

        }
        return null;
    }
}
Could you please provide help to resolve the issue.

New Post: Validate properties from base class in derived class by metadata

$
0
0
Thank you for reply. We`ll think on this situation...

New Post: Entlib 6.0 Custom Configuration Source is not working

$
0
0
You need to use the LogWriterFactory that you initialized with the Enterprise Library configuration information and not a new default instance:
            IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
            LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
            Logger.SetLogWriter(logWriterFactory.Create()); // not new LogWriterFactory().Create();
~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to

New Post: Entlib 6.0 Custom Configuration Source is not working

$
0
0
Randy,

Thank you so much and following code change is perfect solution.
        IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
        LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
        Logger.SetLogWriter(logWriterFactory.Create()); // not new LogWriterFactory().Create();
Thanks

New Post: ActivationException Activation error occured while trying to get instance of type ICacheManager, key "Cache Manager"

$
0
0
1:ResolutionFailedException Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager", name = "Cache Manager".
Exception occurred while: Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider).

Exception is: NullReferenceException - Object reference not set to an instance of an object.

At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Cache Manager (mapped from Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, Cache Manager)
Resolving parameter "realCache" of constructor Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager(Microsoft.Practices.EnterpriseLibrary.Caching.Cache realCache, Microsoft.Practices.EnterpriseLibrary.Caching.BackgroundScheduler backgroundScheduler, Microsoft.Practices.EnterpriseLibrary.Caching.ExpirationPollTimer pollTimer)
Resolving Microsoft.Practices.EnterpriseLibrary.Caching.Cache, Cache Manager
Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider)
2:NullReferenceException Object reference not set to an instance of an object.
at [   at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key)

Message: 0:ArgumentException Delegate to an instance method cannot have null 'this'.
at [   at System.MulticastDelegate.CtorClosed(Object target, IntPtr methodPtr)

Created Unassigned: ActivationException Activation error occured while trying to get instance of type ICacheManager, key "Cache Manager" [33772]

$
0
0
1:ResolutionFailedException Resolution of the dependency failed, type = "Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager", name = "Cache Manager".
Exception occurred while: Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider).
Exception is: NullReferenceException - Object reference not set to an instance of an object.

At the time of the exception, the container was:

Resolving Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Cache Manager (mapped from Microsoft.Practices.EnterpriseLibrary.Caching.ICacheManager, Cache Manager)
Resolving parameter "realCache" of constructor Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager(Microsoft.Practices.EnterpriseLibrary.Caching.Cache realCache, Microsoft.Practices.EnterpriseLibrary.Caching.BackgroundScheduler backgroundScheduler, Microsoft.Practices.EnterpriseLibrary.Caching.ExpirationPollTimer pollTimer)
Resolving Microsoft.Practices.EnterpriseLibrary.Caching.Cache, Cache Manager
Calling constructor Microsoft.Practices.EnterpriseLibrary.Caching.Cache(Microsoft.Practices.EnterpriseLibrary.Caching.IBackingStore backingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Instrumentation.ICachingInstrumentationProvider instrumentationProvider)
2:NullReferenceException Object reference not set to an instance of an object.
at [ at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
at Microsoft.Practices.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService](String key)

Message: 0:ArgumentException Delegate to an instance method cannot have null 'this'.
at [ at System.MulticastDelegate.CtorClosed(Object target, IntPtr methodPtr)

New Post: How to use static logger??? Logging Application Block

$
0
0
Solution by Randy is....

You need to use the LogWriterFactory that you initialized with the Enterprise Library configuration information and not a new default instance:
        IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
        LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
        Logger.SetLogWriter(logWriterFactory.Create()); // not new LogWriterFactory().Create();


New Post: Enterprise Library 6.0 WCF Exception Handling Shielding Exception is not working

$
0
0
Please see below issue detail-

I downloaded Entlib 6.0 from codeplex.com and created custom configuration source as Entlib.config and referred as a source in WCF Web.config. And called the C# code to write Exception but not working.

  1. Web.config
    <?xml version="1.0"?>
    <configuration>
    <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
    </configSections>
    <enterpriseLibrary.ConfigurationSource selectedSource="fileSource"
    parentSource="fileSource">
    <sources>
    <add name="fileSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    filePath="C:\Projects_2012\SmartClientLogging\WindowsFormsApplication1\TaskListWCF\Entlib.config" />
    </sources>
    <redirectSections>
    <add sourceName="fileSource" name="loggingConfiguration" />
    </redirectSections>
    </enterpriseLibrary.ConfigurationSource>
    <appSettings>
    </appSettings>
    <system.web>
    <compilation debug="true" targetFramework="4.0" />
    </system.web>
    <system.serviceModel>
    <behaviors>
    <serviceBehaviors>
    <behavior name="ITaskService.ServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />          
    </behavior>
    </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
    <services>
    <service name="Logging.TaskListServiceImplementation.TaskService" behaviorConfiguration="ITaskService.ServiceBehavior">
    <endpoint address="" binding="wsHttpBinding" contract="Logging.TaskListServiceContract.ITaskService" bindingConfiguration="WSHttpBinding_ITaskService" />        
    </service>
    </services>
    <bindings>
    <wsHttpBinding>
    <binding name="WSHttpBinding_ITaskService" closeTimeout="03:00:00"
        openTimeout="03:00:00" receiveTimeout="03:10:00" sendTimeout="03:00:00"
        bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
        maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
        messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
        allowCookies="false">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
          maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <reliableSession ordered="true" inactivityTimeout="03:10:00"
          enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None"
            realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true"
            algorithmSuite="Default" />
      </security>
    </binding>
    </wsHttpBinding>
    </bindings>
    </system.serviceModel>
    </configuration>

  1. Entlib.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
 defaultCategory="Important" logWarningsWhenNoCategoriesMatch="true">
<listeners>
  <add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging"        listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging"
    fileName="C:\Projects_2012\SmartClientLogging\WindowsFormsApplication1\TaskListWCF\App_Data\RollingFlatFile.log" footer="----------------------------------------"
    formatter="Text Formatter" header="----------------------------------------"
    rollFileExistsBehavior="Increment" rollInterval="None" rollSizeKB="20"
    timeStampPattern="yyyy-MM-dd" maxArchivedFiles="3" traceOutputOptions="None"
    filter="All" />
</listeners>
<formatters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
    template="Timestamp: {timestamp(local)}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}ActivityId: {property(ActivityId)}{tab}Severity: {severity}{tab}Title:{title}{tab}"
    name="Brief Format Text" />
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging"
    template="Timestamp: {timestamp}{tab}Message: {message}{tab}Category: {category}{tab}Priority: {priority}{tab}EventId: {eventid}{tab}Severity: {severity}{tab}Title: {title}{tab}Activity ID: {property(ActivityId)}{tab}Machine: {localMachine}{tab}App Domain: {localAppDomain}{tab}ProcessId: {localProcessId}{tab}Process Name: {localProcessName}{tab}Thread Name: {threadName}{tab}Win32 ThreadId:{win32ThreadId}{tab}Extended Properties: {dictionary({key} - {value}{tab})}"
    name="Text Formatter" />
</formatters>
<logFilters>
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
    minimumPriority="2" maximumPriority="99" name="Priority Filter" />
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.LogEnabledFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
    enabled="true" name="LogEnabled Filter" />
  <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging"
    categoryFilterMode="AllowAllExceptDenied" name="Category Filter">
    <categoryFilters>
      <add name="BlockedByFilter" />
    </categoryFilters>
  </add>
</logFilters>
<categorySources>
  <add switchValue="All" name="Important">
    <listeners>
      <!--<add name="Formatted EventLog TraceListener" />-->
      <add name="Rolling Flat File Trace Listener" />
    </listeners>
  </add>
</categorySources>
<specialSources>
  <allEvents switchValue="All" name="All Events" />
  <notProcessed switchValue="All" name="Unprocessed Category">
    <listeners>
      <!--<add name="UnprocessedFlatFile" />-->
    </listeners>
  </notProcessed>
  <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
      <!--<add name="Formatted EventLog TraceListener" />-->
    </listeners>
  </errors>
</specialSources>
</loggingConfiguration>
<exceptionHandling>
<exceptionPolicies>
  <add name="WCF Exception Shielding">
    <exceptionTypes>
      <add name="All Exceptions" type="System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
        postHandlingAction="ThrowNewException">
        <exceptionHandlers>
          <add type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.FaultContractExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
            exceptionMessage="An unexpected error has occurred in this service.  Please contact the service adminstrator." faultContractType="Logging.TaskListServiceContract.TestFaultContract, Logging.TaskListServiceContract, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
            name="Fault Contract Exception Handler" />
        </exceptionHandlers>
      </add>
    </exceptionTypes>
  </add>
</exceptionPolicies>
</exceptionHandling>
</configuration>

C# Code
[ExceptionShielding("WCF Exception Shielding")]
public class TaskService : ITaskService
{       
    public string Test()
    {                     
        throw new Exception("Testing Exception Handling");
        return string.Format("You entered:", "Test");
    }                 }
Work arounds are
  1. adding the following code in the Test() method
        IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
        LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
        Logger.SetLogWriter(logWriterFactory.Create());&
  2. In global.asax adding in Application_Start
    ExceptionPolicy.SetExceptionManager(new ExceptionPolicyFactory().CreateManager());
I am using the exception sheilding on WCF and using channel factory to connect from client to WCF service. Could you please provide help to resolve the issue other than above 2 work arounds and thanks in advance.

New Post: ActivationException Activation error occured while trying to get instance of type ICacheManager, key "Cache Manager"

$
0
0
Even i was getting the same error upon using Enterprise library Isolated storage backing store . Tried searching in all forums but could not find a proper response.

New Post: MSMQ Distributor Service (EntLib 5) won't start ... sometimes

$
0
0
We are having weird and inconsistent behaviours trying to run this service on various servers.

At times I was able to run it (as Network Service user) and it was fine. Other times it would only run under a particular users credentials.

Even weirder, if the server was rebooted, or the service stopped manually, it wouldn't run again as the previously designated user, you had to change users and then it would run. If you stopped it and ran it again as the previous user, it would work again.

This is getting pretty frustrating, as there seems to be no rhyme or reason as to why it will run as some and not others, and only sometimes at that!

Does anybody have any ideas?

New Post: SemanticLogging-svc logging to SQLExpress Column Mapping does not match

$
0
0
I have a couple of questions about this particular thread as I am receiving the same ColumnMapping error despite having a database which I configured using the sql scripts provided by the nuget package, i.e. CreateSemanticLoggingDatabase.sql and CreateSemanticLoggingDatabaseObjects.sql. I did alter the database creation script to use the database name 'SLAB'. My first question is whether one can use a <sqlDatabaseEventListener> or does one have to use a modified xsd that supports the <sinks> element that the example shows. It is worth noting that the default xsd that comes with the nuget package does not support any sink or sinks elements. Second, what does the //sqlDatabaseEventListener/@instanceName refer to? The documentation states: "The name of the instance originating the entries" which is unclear. I have tried using the event source, the full server name\server instance, and just the server instance name to no effect. Incidentally, here are the elements I am attempting to use:

<eventListener name="DatabaseListener" level="Verbose" />

<sqlDatabaseEventListener name="DatabaseListener" connectionString="Data Source=SERVERNAME\SERVERINSTANCE;Initial Catalog=SLAB;Persist Security Info=True;User ID=USERNAME;Password=PASSWORD" instanceName="????" bufferingCount="1000" tableName="Traces" />

Incidentally, all of my other file loggers are working fine so I believe the problem is only with these elements. Thanks for any and all assistance.
-Daniel

New Post: ActivationException Activation error occured while trying to get instance of type ICacheManager, key "Cache Manager"

Viewing all 1928 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>