Search code examples
c#asp.net-mvcdevexpressdevexpress-mvc

Unable to cast the object type "System.Web.Mvc.HtmlHelper` 1 [System.Object] "to type" System.Web.Mvc.HtmlHelper "


I'm using DevExpress controlls in my mvc asp.net project. Here is code of View:

<div>
    @Html.DevExpress().TextBox(settings =>
    {
        settings.Name = "TextBox";
        settings.Width = 170;
        settings.Properties.DisplayFormatString = "[ 00 - 00 - 00 ]";
        settings.Text = "123456";
    }).GetHtml()
</div>

and here is error message:

 Unable to cast the object type "System.Web.Mvc.HtmlHelper` 1 [System.Object]" to
 type "System.Web.Mvc.HtmlHelper"

I cant understand where my code is failing, because it's sample code from DevExpress demos.


Solution

  • Ty for link, Nitin Varpe. I added this section to my main web.config:

    <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>