Wednesday, September 4, 2013

Structuremap 202 errors..... The two most powerful lines for fixing 202 type errors in Structure map.

 If you are using strcutrue map you are familiar with 202 errors.

If you've seen my list of them and their causes it's a big help in fixing them.

Either way here are two powerful lines for diagnosing what's wrong.


#1:

Debug.WriteLine( ObjectFactory.WhatDoIHave() );






Writes out everything loaded by Structure map... like this:

....
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ICodeDAL (JCDCHelper.DBCodes.Interfaces.ICodeDAL) JCDCHelper.DBCodes.DataObjects.CodeDAL, JCDCHelper.DBCodes, Version=3.1.2.2, Culture=neutral, PublicKeyToken=null JCDCHelper.DBCodes.DataObjects.CodeDAL, JCDCHelper.DBCodes, Version=3.1.2.2, Culture=neutral, PublicKeyToken=null

Scoped as: PerRequest

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ISpamisCodeDAL (JCDCHelper.DBCodes.Interfaces.ISpamisCodeDAL) JCDCHelper.DBCodes.DataObjects.SpamisCodeDAL, JCDCHelper.DBCodes, Version=3.1.2.2, Culture=neutral, PublicKeyToken=null JCDCHelper.DBCodes.DataObjects.SpamisCodeDAL, JCDCHelper.DBCodes, Version=3.1.2.2, Culture=neutral, PublicKeyToken=null

Scoped as: PerRequest
....








and #2:
ObjectFactory.AssertConfigurationIsValid();





Looks for obvious errors and gives you better information to fix them... are you haunted by the words "Or one of it's dependencies" this is the tool for you.

Give them a try... Not magic bullets, but a huge help.

Good luck

Cal-