question

Erlangga H. avatar image
Erlangga H. asked ·

Error using JavaScript ADK in Silverlight App with Dynatrace 7

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.

appmon 7javascriptadk
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.

1 Answer

Erlangga H. avatar image
Erlangga H. answered ·

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.

Share
10 |2000000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 50.0 MiB each and 250.0 MiB total.