Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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=2.0.5.0, 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.

share|improve this question

4 Answers 4

up vote 0 down vote accepted

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


12\TEMPLATE\CONTROLTEMPLATES\MyApp

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.


12\TEMPLATE\LAYOUTS\1033\MyApp

MyApp.xap

Silverlight.js (as provided by Microsoft)

MyApp.js (containing the onSilverlightError function)

share|improve this answer
    
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 Jan 19 '10 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 Jan 19 '10 at 22:50

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.

share|improve this answer
    
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 Jan 16 '10 at 22:25

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

share|improve this answer
    
I've now updated the question with more testing. –  Alex Angas Jan 16 '10 at 22:26

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

share|improve this answer
    
I tried fuslogvw.exe but nothing showed up. Haven't tried Process Monitor yet. Yes the assembly is in the GAC. I now have it working from a document library but would like it deployed to the file system if possible. –  Alex Angas Jan 16 '10 at 22:27
    
Havent tried this myself, but a couple of articles point to that you create a new folder ClientBin in webroot: philwicklund.com/archive/2008/05/26/… u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1799 –  Anders Rask Jan 16 '10 at 22:44
    
... for the XAP file that is –  Anders Rask Jan 16 '10 at 22:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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