Blocked by the Silverlight ManagedRuntimeError 4004

For my Silverlight 2 prototype business app, I wanted to try capturing JSON data from a WCF service and caching it in isolated storage. I found a nice example by Tim Heuer that I updated to the RTW version. After setting up the WCF service on a VPC running Windows Server 2008, I was able to fill the Silverlight datagrid with remote JSON data. Great!, I thought.

The hassles started when I moved the WCF code to a server out on the real Internet. The same Silverlight app on my workstation now throws a 4004 "ManagedRuntimeError" error on startup.

A quick analysis with Fiddler shows the problem. The first thing Silverlight 2 does is look for clientaccesspolicy.xml in the root of the domain. Then, it looks for crossdomain.xml.

image

In my local VPC (webservice2008), I control the root of the domain, so there's no problem putting a clientaccesspolicy.xml in the right location. However, at aspspider I'm just a non-paying tenant with a subdirectory called kjopc. If there's no clientaccesspolicy.xml (or one that denies access), I'm blocked.

The moral of the story is to make sure you've got full control over the Web site and domain before you try serving data up to Silverlight 2. Even when you own the domain, check that the hosting provider supports WCF. I use webhost4life.com for a couple of sites. Their low-end ASP.NET 3.5 plan doesn't include WCF.

Published Sunday, October 19, 2008 3:20 PM by Ken Cox [MVP]

Comments

# Blocked by the Silverlight ManagedRuntimeError 4004 - WebLog of Ken Cox

Pingback from  Blocked by the Silverlight ManagedRuntimeError 4004 - WebLog of Ken Cox

# Silverlight Cream for October 19, 2008 -- #400

Monday, October 20, 2008 12:11 AM by Community Blogs

In this issue: Bart Czernicki, Pedro Cortes, Ken Cox, Koen Zwikstra, and Terence Tsang. Karl Shifflett

# re: Blocked by the Silverlight ManagedRuntimeError 4004

Monday, October 20, 2008 9:15 AM by Michael Washington

Things like this are the reason I am using standard .asmx web services with SilverlightDesktop.net. The other WCF thing that makes me crazy is that your WCF service cannot be on mydomain.com and www.mydomain.com. It will answer on only one address.

I want to use WCF, I really do. I just need issue like this worked out.

# Silverlight Travel » capturing JSON data from a WCF service

Monday, February 09, 2009 12:56 AM by Silverlight Travel » capturing JSON data from a WCF service

Pingback from  Silverlight Travel » capturing JSON data from a WCF service

# re: Blocked by the Silverlight ManagedRuntimeError 4004

Friday, April 23, 2010 9:00 PM by Scott Leckie

I know this is a little old but, in SL4 at least, you need to be careful that you handle validation errors, otherwise you get Code www.scottleckie.com/.../4004 errors.

More info at

# re: Blocked by the Silverlight ManagedRuntimeError 4004

Friday, June 11, 2010 9:00 PM by Scott Leckie

The solution is to detach the debugger from the running process and then attach to the failing process. See www.scottleckie.com/.../code-4004-unhandled-error-in-silverlight-application for more info

Leave a Comment

(required) 
(required) 
(optional)
(required)