Pergunta

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.

Foi útil?

Solução 4

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)

Outras dicas

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

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top