Using Enterprise Library 5.0 throws Runtime .NET error

Topics: Exception Handling Application Block, Logging Application Block
Aug 5, 2010 at 2:01 PM

The following code snippet while using Enterprise Library 5.0

catch (Exception ex)

{

 ExceptionPolicy.HandleException(ex, "PolicyName");

}

that used to work with Enterprise Library 2.0 throws the .NET Runtime version - Fatal Execution Engine Error.

Please advise.

Thanks

 

 

 

Aug 6, 2010 at 1:35 AM

I don't suppose you're using the same machine or same machine setup when you're still using EntLib 2.0, am I right?  This error could be attributed to different causes and not specific to EntLib so I suggest googling ".NET Runtime version - Fatal Execution Engine Error" and see which one would apply to you.

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 12, 2010 at 6:26 PM

Thanks for the response.

Not sure by the same machine comment.

The back ground to this issue is this -

We currently use .NET Fwk 2.0 with Ent Lib 2.0 on a Windows 2003 server.  In our logging code (in catch) we use the code snippet as given above. We upgraded our code to use .NET Fwk 3.5 and Ent Lib 5.0.

We noticed that the the above code throws a .NET run time error. I think you could simulate the problem on your end. Call the above code and have native image of the ent lib code in your gac. I think you should be able to get the same error.

 

Aug 13, 2010 at 2:47 AM

I wasn't able to repro it, although I don't have a windows 2003 machine yet available.  What entlib assemblies did you deploy in GAC? And what are those assemblies which you referenced in your project?  Are you using a database trace listener in your config?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 19, 2010 at 7:12 PM
Sorry for the late response. All the entlib assemblies that come with ent 5.0 were gac'd. in fact same behavior was seen on a windows 2008 server. we are not using db trace listener. i will attach the sample app shortly.
Aug 20, 2010 at 8:27 AM

Was there an inner exception? If yes, could you post it?  Does this only happen when using ExceptionPolicy.HandleException? How about for the other application blocks, are they working fine?

 

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com

Aug 20, 2010 at 5:53 PM

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.Unity;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel.Unity;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ContainerModel;
namespace TestProject
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string str = null;
            int val ;
            Console.WriteLine("This line will get executed");
            try
            {
                str = str.ToString();
                               
            }
            catch (Exception ex)
            {
               
                if (ExceptionPolicy.HandleException(ex, "ReplacingException"))
                {
                    Console.WriteLine("This line will not get executed");
                }
                
            }
            Console.ReadLine();
        }
    }
}

 

The code snippet is given above. This is a simple console application. Please make sure you create native images of all the entlib assemblies (5.0) and check it out.

Aug 25, 2010 at 4:16 AM
Edited Aug 25, 2010 at 9:29 AM

Yes, I was able to repro the error after creating the native images, I got the ExecutionEngineException.  I googled then so as to investigate what might be the problem and found this issue.  I followed the workaround and it worked great.  In my case, I only created native images for the Common and ExceptionHandling assembly so I added this in the devenv.exe.config:

<dependentAssembly>
  <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
  <codeBase version="5.0.414.0" href="C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin\Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll"/>
</dependentAssembly>
<dependentAssembly>
  <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
  <codeBase version="5.0.414.0" href="C:\Program Files (x86)\Microsoft Enterprise Library 5.0\Bin\Microsoft.Practices.EnterpriseLibrary.Common.dll"/>
</dependentAssembly>

Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com