Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)

Jan 6, 2009 at 4:12 AM
I've been using Enterprise Library - Exception Handling Application Block (EHAB) & Logging Application Block.
The below references are set:

Microsoft.Practices.EnterpriseLibrary.Configuration.Design.dll,
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.Design.dll,
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration.Design.dll,
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Design.dl
Microsoft.Practices.EnterpriseLibrary.Logging.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.ObjectBuilder2.dll

And I get the following error when the application executes the below code:

Exception

 

exceptionToThrow;

var rethrow = Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(exceptionToHandle, policyName, out exceptionToThrow);

 

 

// get the following error :
exceptionToThrow =
The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, Data Access Policy]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)

Help me to resolve this issue

Rgds,
 ~Yogi

 



Jan 6, 2009 at 7:19 AM
Seems like it cannot find your configuration file.  Could you describe me where you put your app.config and where's the class which contains this code is in?  Anyway, this has nothing to do with Unity.


Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 6, 2009 at 10:15 AM
Hi Sarah,

Thanks for your reply. Yep.. you are right and I didn't put the app.config in the correct place. It's working now.

Yogi
May 19, 2009 at 5:39 PM

Hi ,

I got the same error.Can you please let me know where exactly the app.config shuold be.

Becasue my app.config is in my project folder only

 

Thanks in advance

 

 

May 19, 2009 at 5:47 PM

Hi Sg...

Is your application a web app?

Do you've web.config file for your web app and have you configured the sections for Applications Block?

Check those.

Regards,

~Yogi

May 19, 2009 at 6:17 PM

Hi ,

My application was windows application.It is having different project.I am developing seperate project for Entlib.When i am trying to hadle that application i am getting the same error.That project contains app.config.

 

Thanks

Saritha

 

May 20, 2009 at 4:02 AM

Does the code that throws the exception belongs to the windows application project?  Or from a class library type of project?  Class libraries don't own configuration files so your exception policies should be properly configured in the executable's configuration file.

 

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

May 21, 2009 at 4:25 PM

 

Hi  Saritha,

Your windows project should contain the app.config.

Try it and tell me.

~ Yogi

 

Jun 15, 2009 at 2:12 PM

hi

im doing the same in a class libaray 

try     {

           //mycode

        }

        catch (Exception exception)

        {

            Exception exceptionToThrow;

            if (ExceptionPolicy.HandleException(exception, EXCEPTIONPOLICYNAME, out exceptionToThrow))

            {

                if (exceptionToThrow == null)

                {

                    throw;

                }

 

                throw exceptionToThrow;

            }

            else

            {

                return null;

            }

        }

 

it z throwing exception

The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicyImpl, UPSException]) failed: Object reference not set to an instance of an object. (Strategy type ConfiguredObjectStrategy, index 2)

 

im having app.config in my route folder

 

can you reslove thz

 

regards

Boss

Jun 16, 2009 at 5:23 AM

This isn't a Unity question, it's a general Enterprise Library question. As such, if you reposted in the Enterprise Library project, you'll probably get help more quickly.

-Chris