typeInititlizationExceptionError using Entlib 3.0

Topics: Logging Application Block
Jan 25, 2007 at 3:42 PM
Hi all,

I'm trying to use the entlib 3.0 Jan 2007 CTP with June 2006 SCFC. It is complaining the following in

Logger.Write(new AppraisalServiceAuditEntry(appraisal.Id, AppraisalServiceAuditEntry.Reason.AssignmentRequest));

in AppraisalManagementServiceAgent.cs

The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Logging.Logger' threw an exception.

It seems to be related to security. The same code works fine if I use entlib 2.0.

I like to move to entlib 3.0 right away and need some guidance.

Thanks.
Jan 25, 2007 at 4:51 PM
Hi Benson -

I'm not sure what would cause this. Would you be able to send the complete exception details, including the stack trace?

thanks
Tom
Jan 26, 2007 at 2:49 PM
Hi Tom,


Thanks Tom,

I ran the SCSF June 2006 install after I installed the entlib 3.0. In External Dependencies, I point the folder that contain Entlib to

C:\Program Files\Microsoft Enterprise Library 3.0 - January 2007 CTP\Bin\. After installation, the entlib 3.0 was in LIB

I then compiled and ran AppraiserWorkBench. Click 'Select available Appraiser' and it broke at the line Logger.Writer... above.

Exception Detail:

System.TypeInitializationException was unhandled by user code
Message="The type initializer for 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory' threw an exception."
Source="Microsoft.Practices.EnterpriseLibrary.Common"
TypeName="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory"
StackTrace:
at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ObjectBuilder.EnterpriseLibraryFactory.BuildUpT(IConfigurationSource configurationSource)
at Microsoft.Practices.EnterpriseLibrary.Logging.LogWriterFactory.Create()
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.get_Writer()
at Microsoft.Practices.EnterpriseLibrary.Logging.Logger.Write(LogEntry log)
at GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.AppraisalManagementServiceAgent.LockAppraisal(Appraisal appraisal, LockAppraisalCallback callback) in C:\Program Files\Microsoft SCSF\AppraiserWorkbench\Source\Appraisals\ServiceAgent\AppraisalManagementServiceAgent.cs:line 224
at GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.Views.AvailableAppraisals.AvailableAppraisalsViewPresenter.SelectAppraisals(Appraisal[] appraisals) in C:\Program Files\Microsoft SCSF\AppraiserWorkbench\Source\Appraisals\Module\Views\AvailableAppraisals\AvailableAppraisalsViewPresenter.cs:line 91
at GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.Views.AvailableAppraisals.AvailableAppraisalsView.OkButtonClicked(Object sender, EventArgs e) in C:\Program Files\Microsoft SCSF\AppraiserWorkbench\Source\Appraisals\Module\Views\AvailableAppraisals\AvailableAppraisalsView.cs:line 122
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Call stacks:

> GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.dll!GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.AppraisalManagementServiceAgent.LockAppraisal(GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.BusinessEntities.Appraisal appraisal = {GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.BusinessEntities.Appraisal}, GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.LockAppraisalCallback callback = {GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.LockAppraisalCallback}) Line 224 + 0x2d bytes C#
GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.dll!GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.Views.AvailableAppraisals.AvailableAppraisalsViewPresenter.SelectAppraisals(GlobalBank.AppraiserWorkbench.AppraisalServiceAgent.BusinessEntities.Appraisal[] appraisals = {Dimensions:1}) Line 91 + 0x53 bytes C#
GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.dll!GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.Views.AvailableAppraisals.AvailableAppraisalsView.OkButtonClicked(object sender = {Text = "OK"}, System.EventArgs e = {X = 41 Y = 14 Button = Left}) Line 122 + 0x20 bytes C#
External Code
GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.dll!GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.ModuleController.ViewAvailableAppraisalsHandler(object sender = {Microsoft.Practices.CompositeUI.Commands.Command}, System.EventArgs e = {System.EventArgs}) Line 60 + 0xa bytes C#
Microsoft.Practices.CompositeUI.dll!Microsoft.Practices.CompositeUI.Commands.Command.OnExecuteAction(object sender = {Microsoft.Practices.CompositeUI.Commands.Command}, System.EventArgs e = {System.EventArgs}) Line 230 + 0x12 bytes C#
Microsoft.Practices.CompositeUI.dll!Microsoft.Practices.CompositeUI.Commands.Command.Execute() Line 133 + 0xf bytes C#
GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.dll!GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.Views.AppraisalDetail.AppraisalDetailViewPresenter.ShowAppraisalSelection() Line 89 + 0x2c bytes C#
GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.dll!GlobalBank.AppraiserWorkbench.AppraiserWorkbenchModule.Views.AppraisalDetail.AppraisalDetailView.coverLabelLinkClicked(object sender = {System.Windows.Forms.LinkLabel, Text: You do not have an appraisal selected.

Click on an appraisal on the left,
or select new available appraisals.}, System.Windows.Forms.LinkLabelLinkClickedEventArgs e = {System.Windows.Forms.LinkLabelLinkClickedEventArgs}) Line 127 + 0xd bytes C#
External Code
Microsoft.Practices.CompositeUI.WinForms.dll!Microsoft.Practices.CompositeUI.WinForms.FormShellApplication<Microsoft.Practices.CompositeUI.WorkItem,GlobalBank.Infrastructure.Shell.ShellForm>.Start() Line 31 + 0x10 bytes C#
Shell.exe!GlobalBank.Infrastructure.Shell.ShellApplication.Start() Line 63 + 0x7 bytes C#
Microsoft.Practices.CompositeUI.dll!Microsoft.Practices.CompositeUI.CabApplication<Microsoft.Practices.CompositeUI.WorkItem>.Run() Line 81 + 0x7 bytes C#
Shell.exe!GlobalBank.Infrastructure.Shell.ShellApplication.Main() Line 52 + 0x1a bytes C#

Thanks again.


Feb 14, 2007 at 6:00 AM
Edited Feb 14, 2007 at 6:01 AM
Hi,

I also have problems using EntLib 3.0 and SCSF together. For me the error happened during startup when dll's are loaded. It complained that it was unable to load the correct version of the Microsoft.Practices.EnterpriseLibrary.Common.dll. SCSF has references to the 2.0 version and I wanted to use the 2.9.1.1 version.

I do not know if I should attempt to fix this problem by myself or not. Will p&p fix this as soon as EntLib 3.0 is released? Will this fix be easy to incorporate into solutions that are build on the current SCSF?

Or should I use different versions of the same assembly in my project?

Sincerely
Herbjörn
Feb 14, 2007 at 1:00 PM
This gets into the thread I started:

Enterprise Library vs. Software Factories

where I have a big concern that developers will want to use the new version of Enterprise Library 3.0 when it is released, but the various software factories will still be on 2.x.

Migrating now will be a problem as the various dll's are bound to a specific version and many of the dll's have specific extensions to those versions.

Since Enterprise Library 3.0 will not be released until March, we shouldn't expect any support for this right now. We still have another CTP that is expected to be released this month and then the final production release in March.

However, in March when EntLib 3.0 is released, I am hoping there is an immediate migration strategy for each software factory to move to EntLib 3.0.

The Patterns and Practices Team is aware of this concern and I am confident they will have a position / strategy on the subject when EntLib 3.0 is released.

Regards,

Dave

______________________

David Hayden
Microsoft MVP C#