About Me

Tuesday, May 24, 2011

Castle Windsor error : "Could not convert from ‘Class.Name, Assembly.Name, Version=x.x.x.x, Culture=x’ to System.Type – Maybe type could not be found"

Today I got this exception during my work under some part of code. My code used Castle Windsor as IoC container.
I used to realize that most of errors that coming from the Castle Windsor project are not user friendly.
Its difficult to understand where is the error. Fortunately, every time when I'm having such errors I'm starting looking for the reason from the configuration section. In all my cases, the problem was in there.

In the situation when Castle Windsor returns such error, try to do what I did:

  • Open Castle Windsor configuration 
  • Find configuration of  "Class.Name" that was in the exception
  • Make sure that there is an assembly "Assembly.Name" specified in the configuration line. The assembly should be in the scope of the application (usually, the assembly DLL file should be in the same directory)
  • Make sure that "Class.Name" has correct namespace at the beginning. 
  • Make sure that the "Class.Name" is locating in the assembly that was specified in the configuration line. You can use Reflector to open the Dll file and double check that the "Class.Name" is really there.
As you can see, there is nothing complex, just to pay attention to the configuration.

No comments:

Post a Comment