Answered by:
CRM 2011: HTML web resource consuming Silverlight web resource

Question
-
I need to develop a custom button on ribbon that should invoke a HTML page having silverlight xap object.I tried doing below stuff but no luck.
1. Created a web resource of type JS and uploaded Silverlight.js in CRM 2011. (new_Silverlight.js)
2. Created a web resource of type silverlight (say new_SilverlightDemo) and uploaded a SilverlightDemo.xap which works perfectly fine when executed from VS 2010. This is just a silverlight data grid binded to a static resource class of People.
3. Created a web resource of type HTML (say new_TestSilverlight). I copied the HTML page from SilverlightDemo.Web project (used to test Silverlight apps). Then I pasted it in the HTML editor of web resource form.
3A. I have updated the path of Silverlight.js as shown below
<SCRIPT type=text/javascript src="$webresource:new_Silverlight.js"></SCRIPT>
3B. I have updated the path of SilverlightDemo.xap as shown below
<param name="source" value="$webresource:new_SilverlightDemo"/>Then finally I tried to preview the HTML web resource created above new_TestSilverlight.
But it throws an errors saying
1.
Message: Syntax error
Line: 3
Char: 1
Code: 0
URI: http://crmserver/CRM_Organisation/_common/error/errorhandler.aspx?BackUri=http%3a%2f%2fpsspl12%2fPSSPLCRM%2f%257B55d4a2ec-cd55-623a-9c27-8bbbc3456b2b%257D%2fWebResources%2fnew_TestSilverlightDemo%3fpreview%3d1&ErrorCode=0x80040217&Parm0=%0d%0a%0d%0aError%20Details%3a%20Could%20not%20find%20a%20web%20resource%20with%20name%20%24webresource%3anew_Silverlight.js.&RequestUri=%2fPSSPLCRM%2fHandlers%2fWebResource.ashx%3fname%3d%24webresource%3anew_Silverlight.js2.
Line: 54
Error: Unhandled Error in Silverlight Application
Code: 2104Category: InitializeError
Message: 2104 An error has occurred.
Any ideas please.Thanks
Ajay ChawlaFriday, July 29, 2011 12:25 PM
Answers
-
Here is the solution
Thanks.
Ajay Chawla- Marked as answer by Ajay Chawla Monday, August 1, 2011 11:33 AM
Monday, August 1, 2011 11:33 AM
All replies
-
Now when I have removed script element to include Silverlight.js. And now when I click Preview button to preview the HTML web resource, it does not prompt any errors but it shows a blank page. No data grid is visible.
Ajay ChawlaFriday, July 29, 2011 1:55 PM -
Hi Ajay,
Try to debug your SilverLight code.
Thanks, Ankit Shah
Inkey Solutions, India.
Microsoft Certified Business Management Solutions Professionals
http://www.inkeysolutions.com/MicrosoftDynamicsCRM.htmlFriday, July 29, 2011 2:43 PM -
Ajay,
Open Visual Studio and attach debugger to the IE process. Put a breakpoint at the very beginning of you SL application and see if the SL code gets invoked. If your breakpoint is hit, you can step through the code.
Friday, July 29, 2011 3:24 PM -
How could I insert a breakpoint when I am suppose to upload my application.xap file to CRM? I tried with throwing an object of Exception manually in OnLoad event and then tried to attach the preview IE process with the debugger. But the exception is not thrown.
Rather when I insert this silverlight web resource in the opportunity form. The form does throw an exception. Also please note that Silverlight application works great (when i dont manually throw an exception) in the opportunity form.
Thanks
Ajay ChawlaMonday, August 1, 2011 5:34 AM -
Reference link: http://msdn.microsoft.com/en-us/library/gg328358.aspx
As per this reference link, I have done below stuff.
1. Uploaded SilverlightApp.xap file to a web resource of type silverlight
2. Created a HTML web resource (named as new_SLHostPage) to host the SilverlightApp.xap (referenced using $webresource directive)
3. Created a javascript function which has
window.open("new_SLHostPage");
4. Configured the onchange event of Subject line to call javascript written in step 3.
But When I change the subject line and hit tab button, the CRM opens a new window and CRM THROWS AN ERROR SAYING:
An error has occured. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization's Microsoft Dynamics CRM Administrator.
The new window launched has a URL as
Thanks
Ajay Chawla- Edited by Ajay Chawla Monday, August 1, 2011 6:47 AM explained fully now
Monday, August 1, 2011 6:45 AM -
Here is the solution
Thanks.
Ajay Chawla- Marked as answer by Ajay Chawla Monday, August 1, 2011 11:33 AM
Monday, August 1, 2011 11:33 AM -
Hi Ajay,
This is the procedure to follow to open a Silverlight application by clicking a custom button in the ribbon menu.
- Add the button, in the custom action put this code: <CommandDefinition Id="AnId">
<EnableRules></EnableRules>
<DisplayRules></DisplayRules>
<Actions>
<Url Address="$webresource:new_/SilverlightFromRibbonTestPage.html" PassParams="true"></Url>
</Actions>
</CommandDefinition> - Create two web resources one for the xap and one for the html. Call the Silverlight webresource this way: new_/ClientBin/SilverlightFromRibbon.xap, and your html this way: new_/SilverlightFromRibbonTestPage.html.
Step 1, 3a and 3b that you did are not needed.
Soon I will upload a full working example on my blog: http://lucianodangelo.blogspot.com/
I hope this help.
Cheers, Luciano.
Thursday, August 11, 2011 4:57 PM - Add the button, in the custom action put this code: <CommandDefinition Id="AnId">