12 September 2009

CRM ISV Add-On : The entry 'ScriptModule' has already been added

I tested a CRM 4.0 add-on (ISV-A) last week, the default ASPX page generated an error:

Parser Error Message: The entry 'ScriptModule' has already been added.
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
</httpmodules>
</SYSTEM.WEB>



The add-on was located under the folder: CRMWeb\ISV\MyAddon
Of cause it inherits settings from CRM's root web.config: in which the ScriptModule has been added by another ISV's (ISV-B) add-on(it shouldn't do it at all).

But if I remove the ScriptModule from ISV-A's web.config, the error changed to:

Unable to cast object of type 'System.Web.Configuration.ScriptingAuthenticationServiceSection' to type 'System.Web.Configuration.ScriptingAuthenticationServiceSection'.

That's because the .Net version of ScriptModule are different between ISV-A and ISV-B's, so we have to stop ScriptModule(ISV-A's) inheriting from CRM's root web.config.

So that what I need to do on ISV-A's web.config:

Just before the ScriptModule, add a <remove> tag, which will remove the inherited setting:

<remove name="ScriptModule">
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">