Saturday 24 October 2009

"Control can not be created because visual studio can not find the controls 's type in control assembly"

This error message was suddenly popping up in visual studio when I tried to drag my custom web control on a web page then tried to compile the code and found two main error messages in error list. Some thing like
"only one section per config file is allowed" since I had just added ajax configuration to web.config file like

<httpModules >

<add type="URLRewrite" name="URLRewrite" />

<httpHandlers>

<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>

>

<httpModules>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>


httpmodule tag has been declared twice in web.config.

Solution:

merge two httpModules tags in one tag.

<httpModules>

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<add type="URLRewrite" name="URLRewrite" />

These two sections of httpmodules in web.config were causing this error.