Problem with Formatter

Topics: Logging Application Block
Jul 25, 2008 at 11:25 AM
hi

i created very simple Formatter, but when i add in tool "Ent. Library Conf." generate a exception:
"There were no types found in the assembly 'ClassLibrary' that implement or inherit from the base type '....Logging.Formatters.LogFormatter'".

any idea?


my test class:


using System;
using System.Collections.Generic;
using System.Text;
using System.Collections.Specialized;

using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Formatters;
namespace LoggingDemoLibrary
{
    [ConfigurationElementType(typeof(CustomFormatterData))]
    public class MyFormatter : LogFormatter
    {
        public MyFormatter(NameValueCollection attributes)
        {
        }
        public override string Format(LogEntry log)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("<LogEntry>");
            builder.Append("<Message>");
            builder.Append(log.Message);
            builder.Append("</Message>");

            builder.Append("<Activity>");
            builder.Append(log.ActivityId.ToString());
            builder.Append("</Activity>");
            builder.Append("</LogEntry>");
            return builder.ToString();
        }
    }
}


Jul 25, 2008 at 3:10 PM
Hi,

Make sure your custom formatter's assembly references a version of EntLib's binaries that matches what the configuration tool expects. For example, if your assembly references EntLib's source code projects, which generate unsigned binaries, but you're trying to load the assembly with the configuration tool installed by EntLib's MSI, which expects Microsoft-signed binaries, your class will not be considered because the LogFormatter from the unsigned binaries it inherits from is different from the version in the signed binaries.

Hope this helps,
Fernando
Jul 25, 2008 at 3:48 PM
hi

tnx for help! problem is resolved.

i referenced no binary from source (i source not instaled), but i referenced library via "browser" and i do not referenced via ".net".

this is strange.

tnx!
pietro

Jul 25, 2008 at 3:55 PM

That should't make a difference, as long as the versions of the binaries were the same. Anyway, it's good that it's working now.

Regards,
Fernando