Resolution of the dependency failed.

May 14, 2010 at 8:18 AM

I have a problem with unity application block.

 

Sometimes can't resolve a dependency but it's well configured. If i try to do the same thing another time without change nothing, works well. The exception only arrise sometimes (which is a big problem).

 

This is the exception:

RESOLUTION OF THE DEPENDENCY FAILED, TYPE = "XXXXXXXX", NAME = "". EXCEPTION MESSAGE IS: THE CURRENT BUILD OPERATION (BUILD KEY BUILD KEY[XXXXXXXX
, NULL]) FAILED: THE CURRENT TYPE, XXXXXXXX
, IS AN INTERFACE AND CANNOT BE CONSTRUCTED. ARE YOU MISSING A TYPE MAPPING? (STRATEGY TYPE BUILDPLANSTRATEGY, INDEX 3)

May 17, 2010 at 4:48 AM

Is your application multithreaded? Do you have one thread configuring the container while another is resolving?

 

That's the only thing I can think of off the top of my head. Another thing would be to look deeper into the stack trace - the actual error message is actually buried several levels down.

 

May 18, 2010 at 12:04 PM

Humm...

There are two inner exceptions, both with same message: “The current type, XXXXXXXXX, is an interface and cannot be constructed. Are you missing a type mapping?. This is part of the content of tracelog of WCF.

<ExceptionType>

            Microsoft.Practices.Unity.ResolutionFailedException

            <InnerException>

                        <ExceptionType>

                                   Microsoft.Practices.ObjectBuilder2.BuildFailedException, 

                                   <InnerException>

                                                           <ExceptionType>System.InvalidOperationException, mscorlib, Version=4.0.0.0,...

...

 

We think that is some type of bug in the Unity application block (Microsoft.Practices.Unity.dll v1.2). 

Due to the exception arrise only some times, it's impossible to identify a common behavior, but we think that only happens when unity try to resolve the first dependency. Our mappings are in .Config file and we think that if we do the mapping register in the code on run time perhaps this solutions the problem but we can't do this for now.

 

Sorry for not give you more info and thanks for the reply.