Pages

Friday 23 July 2010

Silverlight 4 and WCF/RIA Services under IIS 7.5 and .NET v4.0

Whilst migrating a Silverlight 4 application into a Windows Server 2008 environment with IIS 7.5 [what could be easier] I found the sudden thrills of getting the application to run correctly with the .NET v4 framework and WCF/RIA services.

So I fired up the application only to receive a "404 not found error message" when trying to browse the .svc service files. Okay what about the silverlight application? fire up the application and receive an error message stating "load operation failed trying to retreive the query...". Some days passed 'googling' the various errors only to be pointed to articles that related to v3 of the framework, surely it cant be that complicated to get the application functioning correctly.

Well atlast I found the solution so I thought I would share it to avoid machines being thrown out of the window!

Firstly I found that if I hosted my application under the default web site, under IIS the various script handlers were not created. If you ran the "aspnet_regiis -i" command from the v4.0.30319 framework folder, the entries are still not created. Hmmm very strange. Their are various articles about running "ServiceModelReg -i" from the v3 folder, dont do this or you break the current v4 bindings.

Resolution; simple, create a new web site [to host your application] and then run the "aspnet_regiis -i" from the framework folder [Framework for 32bit or Framework64 for 64bit applications].

When viewing the HTTP Handlers section under the new website and you will see the various mappings for the .svc files have been created [look back at the default website and these havent been upgraded!]. This then resolved the 404 errors and Fiddler was also confirming that the svc files were being accessed correctly. 

As a last configuration make sure the application pool is set to the ASP.NET 4 Integrated mode pool and enable the allow 32bit applications.

Hope this helps :-)

3 comments:

  1. Dude, you are the bomb. Reading your blog helped me fixed my problem that I have been fighting for four hours. THANKS a TON! In my case I have the default web turned off and SharePoint Foundation on port 80. I created another web and have been fighting 404 issues. This along with copying certain assemblies to the GAC made the magic happen.

    ReplyDelete
  2. Thank u very much !!!

    u saved my life !!!

    ReplyDelete
  3. :-) just helping out, glad its all working

    ReplyDelete