Enterprise Library InvalidProgramException

Jul 9, 2014 at 8:33 AM

I am getting a InvalidProgramException
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Cift.Server.Interfaces.ITestProgramValidator", name = "(none)".
Exception occurred while: Calling constructor Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter(System.String template).
Exception is: InvalidProgramException - Common Language Runtime detected an invalid program.
from EnterpriseLibrary.Logging.Formatters.TextFormatter constructor at
        public TextFormatter(string template)
            : this(template, emptyExtraTokenHandlers)
        { }
the wired thing is that if only run this single test or all the tests in its test project everything is passing, but if I try to run it with another test project i am getting this exception.

any leads will help.
Jul 10, 2014 at 3:08 AM
It is a strange one. I've seen something similar once before:

I did see that some people had the same exception when running unit tests (http://stackoverflow.com/questions/14333264/common-language-runtime-detected-an-invalid-program-error-in-unit-testing , http://stackoverflow.com/questions/14578355/system-invalidprogramexception-when-executing-unit-tests-in-mstest-after-microso ) with the culprit being a security update (http://support.microsoft.com/kb/2742595).

Randy Levy
Enterprise Library support engineer
Support How-to
Jul 10, 2014 at 3:03 PM
After lots of debug i found out that when i run a test project that has a test that uses Fakes of Microsoft.Practices.EnterpriseLibrary.Logging and then I run another project with tests that uses the real Microsoft.Practices.EnterpriseLibrary.Logging only then i get this exception ... so i stop using Fakes on Microsoft.Practices.EnterpriseLibrary.Logging and all works well .. for now :)