Silverlight (XAP) web resources
Applies To: Dynamics CRM 2016, Dynamics CRM Online
Microsoft Silverlight web resources remain supported in Microsoft Dynamics CRM Online 2016 Update and Microsoft Dynamics CRM 2016 (on-premises) for backwards compatibility. For components that will be able to be presented on all clients, we recommend using HTML web resources with HTML5 instead of Silverlight.
Microsoft Dynamics CRM Online 2016 Update and Microsoft Dynamics CRM 2016 (on-premises) support adding Silverlight 4.0 web resources to entity forms. You can display Silverlight 5.0 web resources within an HTML web resource using a hosting <object> element that is configured for that version.
Silverlight web resources are easily created using the web resource form by entering a name, a display name, selecting Silverlight (XAP) as the type, and uploading the .xap file. The web resource must be published before you can use it. However, because Silverlight web resources typically provide some interaction with contextual data in Microsoft Dynamics CRM, you should plan how you create your web resources.
When you use the Preview button in the web resources form or just browse to the URL provided, the Silverlight application is hosted in a generic HTML page without context information. If your Silverlight application does not require contextual information, you can use this URL to view your Silverlight web resource.
If you do require contextual information, you must either:
Add your Silverlight web resource to an entity form.
View your Silverlight web resource using an HTML web resource configured to provide context information.
If your Silverlight web resource is designed to be viewed in an entity form, the form has an Xrm.Page.context object you can use to access contextual information. For more information, see Client-side context (client-side reference)
If you need your Silverlight application to appear outside the context of the form you must configure an HTML web resource to provide this context information by adding a reference to the ClientGlobalContext.js.aspx page. After this reference is added, your Silverlight application can access contextual information in the same way it can in an entity form. The following sample shows how to call the getClientUrl function from the Xrm.Page.context object.
When you add a Silverlight web resource to a form you can select the Pass record object-type code and unique identifier as parameters option. You also have the option to enter text as a custom parameter.
These values are passed to the Silverlight control as a InitParams, a dictionary of key/value pairs.
The values passed are described in the following table.
The unique identifier of the record.
The entity type code. For custom entities this can vary between organizations.
The logical name of the entity.
The name of the organization.
The language code representing the user’s language preference.
The language code representing the organization’s base language.
The value of the text entered as a custom parameter.
These values can be accessed at run time using the syntax in the following example:
If your Silverlight web resource is independent of any contextual data from Microsoft Dynamics CRM, you can write and test your Silverlight application as you typically would. After you create a new web resource by uploading your .xap file, you can test it by using the Preview button in the web resource form after you have saved and published the web resource.
However, it is more likely that your Silverlight application has contextual data dependencies that cannot be fully simulated outside of Microsoft Dynamics CRM.
The process of creating a Silverlight web resource that includes form or context dependencies is as follows:
Create your Silverlight application project.
You should select to create a web application with your project.
Write and test as much of the application as you can without requiring contextual data from Microsoft Dynamics CRM.
Create web resources by uploading the .xap and .htm files as Silverlight and HTML web resources.
Write code in your Silverlight application project.
Build your Silverlight application project.
Upload the built version of the .xap file from the web application project ClientBin folder to update the Silverlight web resource you created in step 3.
Test your Silverlight web resource by either:
Viewing it using the Preview button of the host HTML web resource you created.
Viewing it in the context of an entity form that you have added it to.
Use this option is your Silverlight application has dependencies on Form elements or context information.
Repeat steps 4 through 7 until you are finished.
When you want to show a Silverlight web resource outside of an entity form, for example in the application main frame by editing the Site Map, you must provide a webpage (HTML) web resource to act as the host for the Silverlight web resource.
Never edit the HTML source code for a page hosting a Silverlight web resource using the text editor provided in the application. The text editor changes the HTML and breaks <object> element definition necessary to host the Silverlight XAP web resource. For more information, see Use the text editor for HTML web resources.
If you must use the text editor, omit the data="data:application/x-silverlight-2," parameter in the <object> element. Although this should prevent breaking the Silverlight web resource, the text editor may still introduce other undesirable changes.
Silverlight web resources that do not rely on contextual data from Microsoft Dynamics CRM can be debugged in Microsoft Visual Studio. However, if the Silverlight web resource requires contextual data to perform the functions, you will have to use a different procedure.
Build your Silverlight application.
Upload the built version of the .xap file from the web application project ClientBin folder.
View your Silverlight application in the context it is designed to be used in.
In your Silverlight application project, from the Visual Studio menu, select Debug and then Attach To Process.
In the Attach to Process dialog box, find an iexplore.exe process where the Type column value is Silverlight, x86.
Select that process and press Attach to close the dialog box and start debugging.
In your Silverlight application project, set a breakpoint.
Refresh the browser window or, in the Silverlight application, perform the action that you need to test your code.
Microsoft Dynamics CRM 2016 and CRM Online
© 2016 Microsoft. All rights reserved. Copyright