Summary: Hi, I'm new to Silverlight application development, and have created a silverlight app that consists of a textbox, button, and data grid. When I enter some data in my text box, and click the button a call is made to my WCF service which talks to my Microsoft SQL Database and returns all records that match the criteria to be displayed within my data grid. Problem: It runs fine within visual studio 2008 professional edition with the silverlight 3.0 toolkit on my local machine, but to the contrary when I publish the project to my website(right-click>publish...) I get the error "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined". What I have already tried: 1. Changing my ASP.NET Version from 2.0 to 4.0 in my control panel. 2. Changing my Application Pool Pipeline Mode from Integrated to Classic in my control panel. 3. Checking to make sure that there isn't a web.config file in any parent folders leading to the folder that my web.config file is in(Its the only one). 4. Deleting the offending line of code in my web.config file "<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> " (I got a handful of other errors when I did this). A Directory listing of the folder: 05-04-10 12:57PM <DIR> App_Data 05-04-10 01:00PM <DIR> bin 05-04-10 12:57PM <DIR> ClientBin 05-04-10 12:57PM 446 Default.aspx 05-04-10 12:57PM 110 Service1.svc 05-04-10 12:57PM 15533 Silverlight.js 05-04-10 12:57PM 841 SQLDataTestPage.aspx 05-04-10 12:57PM 2959 SQLDataTestPage.html 05-04-10 02:55PM 8279 Web.config 226 Transfer complete. ftp: 477 bytes received in 0.02Seconds 29.81Kbytes/sec. <Can't post my web.config file, it will cause my post to exceed 1550 characters> I have found several forums discussing this topic, but none of them has given me any useful information on this issue.
<?xml version="1.0"?> <configuration> <configSections> <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/> <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> </sectionGroup> </sectionGroup> </sectionGroup> </configSections> <appSettings/> <connectionStrings> <add name="CG_ProductionConnectionString" connectionString="Data Source=db.cybergoths.net,1092;Initial Catalog=CG_Production;Persist Security Info=True;User ID=cgsa;Password=dbAcce$$4CG" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. --> <compilation debug="true"> <assemblies> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> --> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </controls> </pages> <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/> </httpHandlers> <httpModules> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </httpModules> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <providerOption name="CompilerVersion" value="v3.5"/> <providerOption name="WarnAsError" value="false"/> </compiler> </compilers> </system.codedom> <!-- The system.webServer section is required for running ASP.NET AJAX under Internet Information Services 7.0. It is not necessary for previous version of IIS. --> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <remove name="ScriptModule"/> <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated"/> <remove name="ScriptHandlerFactory"/> <remove name="ScriptHandlerFactoryAppServices"/> <remove name="ScriptResource"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </handlers> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name="SQLData.Web.Service1Behavior"> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <services> <service behaviorConfiguration="SQLData.Web.Service1Behavior" name="SQLData.Web.Service1"> <endpoint address="" binding="basicHttpBinding" contract="SQLData.Web.IService1"> <identity> <dns value="localhost"/> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> </service> </services> </system.serviceModel> </configuration>
I fixed the problem by downgrading back to ASP.NET 3.5, and placing all files associated with my .xap file right on the root of my website; Now I have a new problem, my silverlight movie takes a while to load, and when I click the submit button instead of displaying data in the grid, it does nothing and I get an "error on page" message in my status bar. Note: Silverlight App. > WCF > MS SQL Database > Silverlight App. all still works well on my local machine, but on my DiscountAsp.net web server account it wont fetch the data.
My problem is still not resolved, and even if I did get my Silverlight app to the point of where it's successfully retrieving info. From my database, I still want to get it to work with the .NET 4.0 framework, and have the ability to place my Silverlight apps in different folders instead of having to place them all at the root of my website. If you can help me accomplish this, then you deserve a cookie lol!
After about a days of research I figured out the problem! (-: NOTE: This solution only works for .NET 3.5, on .NET 4.0 I would the the following error: "duplicate 'system.web.extensions/scripting/scriptResourceHandler'" if anyone knows how to get around this please share. 1. In Visual Studio 2008 Professional edition, right click your .web project and click publish to publish your website, make sure it is published to the root of your web server or your Silverlight application won't run. 1. Open up your web.config file and add after the <system.serviceModel> tag: Note: Skip this step if you don't have multiple alias's for your web server Ex: "www.yourdomain.com" and "yourdomain.com" both referencing your web server, why? there must be only one unique URI referencing your .svc service <serviceHostingEnvironment> <baseAddressPrefixFilters> <add prefix="http://www.yourdomain.com" /> </baseAddressPrefixFilters> </serviceHostingEnvironment> 2. create and place a new .xml file at the root of your website, it must be called "ClientAccessPolicy.xml", add the following code to it: Note: This file is to list all domains that are allowed to make cross-domain web service calls to your website. <?xml version="1.0" encoding="utf-8" ?> <access-policy> <cross-domain-access> <policy> <allow-from http-request-headers="*"> <!-- Let any silverlight application from http://www.yourdomain.com --> <domain uri="http://www.yourdomain.com" /> </allow-from> <grant-to> <!-- ... Access your website from the root on --> <resource path="/" include-subpaths="true" /> </grant-to> </policy> </cross-domain-access> </access-policy> 3. In Visual Studio 2008 Professional edition, on your Silverlight project, delete your service reference to your .svc service, and re-add it to point to the same service but on you remote web server that your .xap file has been deployed to. Ex: instead of your service reference pointing to "Service1.svc", you want it to point to "http://www.yourdomain.com/Service1.svc", hence the reason why step 2 is important. Note: You will know that your service reference is good, because when you point to it, it will allow you to expand and see all possible methods that your .svc service provides, if you don't see this, then you did something wrong, and you won't be able to call into the service at runtime. 4. Rebuild your website, then Do step 1 to republish your project. That's all folks!!! ~The Count~
One more step: Open up your ServiceReferences.ClientConfig and delete entry other wise you will get a duplicate entry error since removing a refference doesn't take it's entry out of the ServiceReferences.ClientConfig file: <endpoint address="http://localhost:8080/Service1.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IService11" contract="ServiceReference1.IService1" name="BasicHttpBinding_IService1" />
Im not satisfied yet! How can I get this to work under .NET 4.0 without getting the following error: "duplicate 'system.web.extensions/scripting/scriptResourceHandler'" and how can i set it up so that I can place my silverlight files anywhere on my webserver I want, instead of having to place them all at the root, I can't do this in .NET 3.5 or .NET 4.0?
I think this is a very common problem with framework upgrade. do you a search on Google for "duplicate 'system.web.extensions/scripting/scriptResourceHandler'"? http://tinyurl.com/2vra334 You'll see a lot of workarounds.