Error with logging handler in exception handling appblock

Topics: Exception Handling Application Block, Logging Application Block
Jul 25, 2008 at 1:39 PM
Edited Jul 25, 2008 at 1:57 PM
I've added a new exception policy that is using the logging handle to log the exception to a SQL DB but when the exception occurs I get this:

Test method DalTest.Items.GetStuff threw exception: Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionHandlingException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, DataBase Policy]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2) ---> Microsoft.Practices.ObjectBuilder2.BuildFailedException: The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, DataBase Policy]) failed: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided. (Strategy type Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.ConfiguredObjectStrategy, index 2) ---> System.ArgumentException: The type 'Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' cannot be resolved. Please verify the spelling is correct or that the full type name is provided.
 
Anyone know whats wrong?
Jul 25, 2008 at 3:14 PM
Hi,

Make sure you've deployed Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging and Microsoft.Practices.EnterpriseLibrary.Logging.Database with your application.

Fernando
Jul 25, 2008 at 3:20 PM
this is all happening locally and the logging server is an sql express instance
Jul 25, 2008 at 6:03 PM
you're right, it works now :)
I did'nt think I needed refrences to these from inside the testApp since only the DAL project was calling Entlib

thanks
Jul 25, 2008 at 6:13 PM
Well, I suggested that you deployed the assemblies not that you added a reference ;). However, adding a reference is a way to get the assemblies deployed.

The tricky thing with the provider assemblies is their need is driven by the configuration. They are not needed to build the app, and even adding a reference to them in the assembly that actually uses entlib will not cause them to be copied to the app's output folder.

Fernando
Jul 25, 2008 at 9:26 PM
I know, but I only wanted it to work in my test project and adding a refrence seemed like the fastest way at the time.
Jul 29, 2008 at 1:05 AM
Yes, it is the fastest way.

Cheers,
Fernando
Jul 30, 2008 at 3:11 PM
Hi,

I just want to mention that here you have a similar topic: http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=18926

It is not an issue of EntLib... it is just easy to forget about having the access to the assembly where the type is defined, if the compiler does not shout about the lack of it ;)
there are the dependencies of app blocks described in the documentation.
it would be helpful, however, to have it much more clearly described in the documentation (e.g. in one of quick starts) that the deployment of such assemblies is needed, as it seems that for quite a lot of people (including myself) it was not clear that I should take care also about deploying them in global assembly cache or output directory.

greetings,
pola3k