I'm working on a Silverlight 3 application. It works perfectly running within Visual Studio's ASP.NET Development Server.

Now I need to make it run within SharePoint. I have the object tag hosted within a user control and the XAP file deployed to _layouts. I'm testing the user control in both a web part and an application page. Both result in the same error reported by Internet Explorer:

Message: Unhandled Error in Silverlight Application Could not load file or assembly 'System.Windows.Controls, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.   at MyNamespace.Page.InitializeComponent()
   at MyNamespace.Page..ctor()
   at MyNamespace.App.Application_Startup(Object sender, StartupEventArgs e)
   at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
   at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

There's nothing of help in the ULS logs or the Event Viewer. I haven't changed web.config because I understand with Silverlight 3 that's no longer necessary.

Any ideas on what might be causing this?

Update: I've tried deploying the XAP file to a document library within the site and it works perfectly. This makes me wonder if there is some sort of CAS issue going on. I am going to try deploying the XAP to _controltemplates in the same place as the ASCX hosting it. That location is fully trusted according to web.config.

4 Answers 4


For debugging file loading i usually try Assembly Binding Log Viewer (FUSLOGVW.EXE) and/or Process Monitor.

Also did you check that the assembly is available in bin/gac?

hth Anders Rask


Are you running the SL app from the same location? Since it's the SL app thats causing the Exception, right?, it should have nothing to do with the server. /WW

  • I've now updated the question with more testing.
    – Alex Angas
    Commented Jan 16, 2010 at 22:26

Do you have Copy Local set to true on the Reference? All the required assemblies should be bundled in the XAP file, and if it is not set to copy local then VS may not be packaging that assembly into the XAP.

  • This has bit me before but I've double-checked and everything's there. Also I now have the XAP running from a document library so something else must be happening.
    – Alex Angas
    Commented Jan 16, 2010 at 22:25

I've found a solution. Here is the folder structure and important info. This works when packaged with WSPBuilder.


MyAppHost.ascx (WebUrl is the full URL of the site):

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2">
  <param name="source" value="<%= this.WebUrl %>/_layouts/1033/MyApp/MyApp.xap"/>

The code-behind for the control injects the .js files below with ScriptLink.Register.



Silverlight.js (as provided by Microsoft)

MyApp.js (containing the onSilverlightError function)

  • Hrmm. We deploy SL3 XAPs to a subdirectory of layouts without issue. If you still want to try a filesystem deployment, you may want to try adding a content editor web part and manually reference the XAP in the layouts dir. That way you can eliminate your web part as a source of error.
    – MBSurf
    Commented Jan 19, 2010 at 16:00
  • @MBSurf: Thanks for your thoughts. Yes, I'm not sure if something else is going on here as I had problems setting up for SL dev in the first place. I'll do more testing today.
    – Alex Angas
    Commented Jan 19, 2010 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.