Windows Phone 7 Deve Launch
# Thursday, December 01, 2011
« Finding where text/code is used in SQL S... | Main | SelfSSL on IIS 7 »

The Test Helpers are a great way to ease your testing needs with MVC.  If your using the Test Helpers to test your routing like so:

            "~/".ShouldMapTo<HomeController>(x => x.Index());

When you run your tests you’ll get the following error:

System.Security.VerificationException : Method MvcContrib.TestHelper.RouteTestingExtensions.ShouldMapTo: type argument 'Your Controller Name’ violates the constraint of type parameter 'TController'.

The fix is a binding direct.

Add an app.config to your test project and paste in the following:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

Happy Coding! Smile

OpenID
Please login with either your OpenID above, or your details below.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: b, blockquote@cite, em, i, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview