Answered by:
CRM 2011 Rollup 12 issue: Unable to cast type 'System.String' to 'System.Windows.Browser.ScriptObject' when calling HtmlPage.Window.Invoke from Silverlight

Question
-
Code Line:
//invoke dialog from Silverlight
ScriptObject result = (ScriptObject)HtmlPage.Window.Invoke("showModalDialog", url, args, features);Issue:
Whenever above line of code executed from Silverlight control code in CRM Online O365 with UR12, it throws error
"Unable to cast type 'System.String' to 'System.Windows.Browser.ScriptObject'".
Same code is working in On Premise (with UR11) & earlier CRM Online (with UR11)Root Cause:
Before UR12 (Polaris) update, return type of "HtmlPage.Window.Invoke("showModalDialog", url, args, features)" was ScriptObject but now UR12 returns it as "String" (JSON string).
Resolution: We have currently resolved this by adding switch case and converting Json string to object.Question:
Does anyone faced this issue? Is it change Microsoft come up with in UR12 (if documented)? Or it's a bug?- Edited by Dhananjay G Pashte Tuesday, January 29, 2013 9:18 AM
Tuesday, January 29, 2013 9:17 AM
Answers
-
Hello,
It seems that you are trying to call lookup dialog and get results from it. Check following article that describes changes - http://blog.sonomapartners.com/2013/01/ur12-upgrading-unsupported-code.html
My suggestion to include support of all versions (before rollup 12 and rollup 12) you should use following approach:
dynamic result = (ScriptObject)HtmlPage.Window.Invoke("showModalDialog", url, args, features); if (result is string){ //processing for UR12 } else{ //processing for versions before UR12 }
- Proposed as answer by Andrii ButenkoMVP, Moderator Tuesday, January 29, 2013 12:06 PM
- Marked as answer by JLattimerMVP, Moderator Thursday, February 7, 2013 4:36 AM
Tuesday, January 29, 2013 10:54 AMModerator -
Thanks Andrii.... I have already implemented above code check.
And agree that this is good suggestion.- Marked as answer by Dhananjay G Pashte Friday, April 5, 2013 10:54 AM
Tuesday, January 29, 2013 11:55 AM
All replies
-
Hi,
Just try the below setttings once,
Administration ---> System Settings --> Customizatoin Tab
Make sure these are checked,
Regards,
Srikanth
Tuesday, January 29, 2013 10:20 AM -
Hello,
It seems that you are trying to call lookup dialog and get results from it. Check following article that describes changes - http://blog.sonomapartners.com/2013/01/ur12-upgrading-unsupported-code.html
My suggestion to include support of all versions (before rollup 12 and rollup 12) you should use following approach:
dynamic result = (ScriptObject)HtmlPage.Window.Invoke("showModalDialog", url, args, features); if (result is string){ //processing for UR12 } else{ //processing for versions before UR12 }
- Proposed as answer by Andrii ButenkoMVP, Moderator Tuesday, January 29, 2013 12:06 PM
- Marked as answer by JLattimerMVP, Moderator Thursday, February 7, 2013 4:36 AM
Tuesday, January 29, 2013 10:54 AMModerator -
Thanks Andrii.... I have already implemented above code check.
And agree that this is good suggestion.- Marked as answer by Dhananjay G Pashte Friday, April 5, 2013 10:54 AM
Tuesday, January 29, 2013 11:55 AM