Skip to main content

Service Object to dynamically connect to any WCF endpoint

dynaminc WCF registration

Dears


Am having a problem when i ty to create a instance from dynamic WCF service broker, am getting te follow error msg "VALIDATIONObject reference notset to a instance of an object"


Re: dynaminc WCF registration

A few years late in replying, but for others experiencing this issue and dismissing this tool, here is a fix for it:


·         Pointed both projects to the .NET Framework 4.0



·         Updated line ~66 to read string clientTypeName = endpoint.Contract.Name.Substring(0) + "Client";


instead of string clientTypeName = endpoint.Contract.Name.Substring(1) + "Client";



 


Re: dynaminc WCF registration

Still have this error with the updated version, found that in the CachedServiceAccessor.cs in the DescribeSchema() method there's a line that inputs the clientTypeName variable, but this contains the Interface name, in my example: ICalculator. But when I opened the generated proxy dll, the class name is: Calculator. That's why factory.ProxyAssembly.GetType(clientTypeName) returns NULL and causes the error: VALIDATIONObject reference notset to a instance of an object when registering the service instance.


A quick fix for testing this was removing the first character from ICalculator so it becomes Calculator, that works. I think there's a better fix, but don't have the time to dive into the proxy generation class right now.


// added .Remove(0,1) because a dll is generated with CalculatorClient class but clientType is ICalculator, that
// results in a VALIDATIONOBJECT is null reference


MethodInfo methodInfo = factory.ProxyAssembly.GetType(clientTypeName.Remove(0,1)).GetMethod(operation.Name);


Reply