How to edit the source code of the Microsoft Visual Studio 2010 (Enterprise) Enterprise Library?

Hi experts!

I downloaded the MS Enterprise Library for using the Logging Block for Visual Studio 2010 Enterprise. All works fine so far.

Now I modified the Stored Procedure (WriteLog) to catch more information about the client.
Therefore I first modified the LogEntry class to give it more information (some Properties were added). I compiled the code to dll and copied it to the Enterprise Library main folder (Program Files).
In my project, the new properties are now known.
The I recompiled my Project to see, if it works. And it didn't work. There is an error, when accessing the EntryLog class while creating a new instance of it.

Notice: I tried out the ExtendedProperties.Add() method. It is not, what I'm looking for. I really need  those information in separate columns in my logging table.

I attatched the project of the modified Logging Block (i only modified the LogEntry.cs) and the code snippet of my instancing of LogEntry (where the rror occurs).   Runtime error while instancing from LogEntry class
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Logging.Filters;
using Microsoft.Practices.EnterpriseLibrary.Logging.Formatters;
using Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners;

using MSLogging = Microsoft.Practices.EnterpriseLibrary.Logging;

namespace Angara.Core.Crosscutting.Logging
	public class Logging : IDisposable

		public void WriteLog(ILogEntry Log)
			Console.WriteLine("Method: " + Log.CallingMethodName);
			Console.WriteLine("Namespace: " + Log.CallingNamespace);
			Console.WriteLine("Message: " + Log.Message);

			MSLogging.LogEntry msLogEntry = new MSLogging.LogEntry();

			msLogEntry.Message = Log.Message;
			msLogEntry.Severity = Log.EventType;
			msLogEntry.Priority = 100;
			msLogEntry.CallingMethodName = Log.CallingMethodName;
			msLogEntry.CallingNamespace = Log.CallingNamespace;
			//msLogEntry.ExtendedProperties.Add("CallingMethodName", Log.CallingMethodName);


			msLogEntry = null;


		public void Dispose()

Open in new window

Who is Participating?
mrRanyConnect With a Mentor Commented:
I think the problem is in that you are copying wrong DLL file.
I downloaded Enterprise Libriry 5.0 with Source Code.
Installed it in C:\Users\MyUserName\Documents\EntLib50Src.
Added 2 fields CallingMethodName and CallingNamespace.
Changed version to 5.1 according to your description.
Compiled and added a reference from my project to the DLL.
On  MSLogging.LogEntry msLogEntry = new MSLogging.LogEntry(); got your error so checked that the version of required DLL is wrong.
After that I've checked in project properties where it really stores debug and release version of DLL and found it in EntLib50Src\Blocks\bin.
Now, referencing to this DLL everything working good.
Hope it will help.
After copying a new DLL have you added it as reference to your project?
kankmanAuthor Commented:

yes, I removed the old reference "Microsoft.Practices.EnterpriseLibrary.Logging" and added a new one.
When adding the new one, the Namespace "Microsoft.Practices.EnterpriseLibrary.Logging" was not listed. I had to choose it manually. Buit I copied it to C:\Programme\Microsoft Enterprise Library 5.0\Bin\Microsoft.Practices.EnterpriseLibrary.Logging.dll, where the original file was.

Mybe it's importaint: I increased the Version of the assembly from original 5.0.414.0 to 5.1.0.
kankmanAuthor Commented:
Hi, I took the right source, I think. But according to your comment, I found out, that there was a second DLL modified.


I did not copied it to the Program Files folder. after I did this, It compiled correctly.
At least you found it, glad that can help anyway. Thanks
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.