System.InvalidCastException: Unable to cast object of type com.wily.powerpack.webservices.extension.WSMContextProperty

Document ID : KB000029781
Last Modified Date : 14/02/2018
Show Technical Document Details

Problem:

You are using the NET Agent version and have enabled the SOA Performance Management(SPM) extension for Webservice monitoring.

You are using both .Net and WCF Webservices 

After starting the agent you see a high number of exceptions and name format errors filling the IntroscopeAgent log very quickly:

...
11/01/14 12:21:05 PM GMT-04 [INFO] [IntroscopeAgent.SPM] [WSDMHandlerFormatter::INameFormatter_format] Unable to determine namespace.Try to get service name
..
1/18/13 10:12:15 AM GMT-05 [ERROR] [IntroscopeAgent.Agent] Exception formatting "WebServices|Server|{namespace}|getCustomFieldForGroupsByName" for probe at ...
1/18/14 10:12:15 AM GMT-04 [VERBOSE] [IntroscopeAgent.Agent]
System.InvalidCastException: Unable to cast object of type 'com.wily.powerpack.webservices.extension.WSMContextProperty' to type 'com.wily.powerpack.webservices.extension.WSMContextProperty'.
at com.wily.powerpack.webservices.extension.WSMThreadLocal.setServiceName(String ServiceName)
at com.wily.powerpack.webservices.extension.agent.trace.nameformatter.dotnet.WSDMHandlerFormatter.getServiceName(InvocationData data)
at com.wily.powerpack.webservices.extension.agent.trace.nameformatter.dotnet.WSDMHandlerFormatter.getNamespace(InvocationData data)
at com.wily.powerpack.webservices.extension.agent.trace.nameformatter.dotnet.WSDMHandlerFormatter.INameFormatter_format(String name, InvocationData data)
at com.wily.introscope.agent.trace.ATracerFactory.customFormat(String value_Renamed, InvocationData data)
..


Cause:

The problem is related to an issue in the .NET SPM extension when using both wily.WebServicesAgent.ext.dll and wily.WCFServicesAgent.ext.dll at the same time. 

The cause of the problem is that both wily.WCFServicesAgent.ext.dll and wily.WebServicesAgent.ext.dll contain the implementation of some common wily class and that triggers the above type casting exception. 

 

Workaround:

1. Move AGENT_HOME\ext\wily.WCFServicesAgent.ext.dll out of the agent directory.

2. Disable WCF tracings in the AGENT_HOME\webservices.pbd:

#TurnOn: WCFServerFaultTracing
#TurnOn: WCFClientFaultTracing
#TurnOn: WCFServerTracing
#TurnOn: WCFClientTracing
#TurnOn: WCFRuntimeTracing

3. Restart IIS or .NET standalone application