cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

This product reached the end of support date on March 31, 2021.

Error using JavaScript ADK in Silverlight App with Dynatrace 7

erlangga_hasto
Newcomer

I've been trying to utilize the AppMon to monitor the Silverlight App in my employer's domain. I'm using AppMon 7, and having a POC by following this quick tutorial from Dynatrace.

Somehow, I couldn't manage to succeed this tutorial, and always comes with an error :

"Unable to cast object of type System.Double to type System.Windows.Browser.ScriptObject"

every time I call the method javaScriptAdk.EnterAction.

The codes are quite simple, just call the method in a click of a button. No logic, no nothing.

Somehow, I've tried to eliminate the error by changing the codes in DyanTrace.cs like this :

        public string EnterAction(string actionName, string actionType, long? time = null, string parentAction = null) {
object res = Invoke("enterAction", actionName, actionType, time, parentAction);
if (res != null) {
if (res is string) {
return (string)res;
}else if (res is ScriptObject) //my correction
{
return (string)((ScriptObject)res).GetProperty("StringValue");
}
else //my addition
{ //my addition
return null; //my addition
} //my addition
} else {
return null;
}
}

and figured it out that it's not working, even though the error was gone.

Could you please help me pointing out what might be the problem? Thank you for your attention.

1 REPLY 1

erlangga_hasto
Newcomer

After several trial and errors, I came up with a solution like this :

        public string EnterAction(string actionName, string actionType, long? time = null, string parentAction = null) {
object res = Invoke("enterAction", actionName, actionType, time, parentAction);
if (res != null) {
if (res is string)
{
return (string)res;
}
else if (res is ScriptObject)
{
return (string)((ScriptObject)res).GetProperty("StringValue");
}
else if (res is double)
{
return ((double)res).ToString(); //It's converted to a string, if the type is 'double'
}
else return null;
} else {
return null;
}
}


The error is gone and I got the correct monitoring result in AppMon. I don't know if this is a hack or not, but at least it works for now.