Note that there are some explanatory texts on larger screens.

plurals
  1. PONot able to filter WCF methods for dynamically created proxy
    text
    copied!<p>Some months back I was working on a project to display the WCF methods and thier parameters in a dropdown. At that time I was creating a proxy using Add Service Reference and hardcoded the service interface in the code. <a href="https://stackoverflow.com/questions/4169096/how-can-i-show-all-the-methods-that-are-available-in-my-wcf-in-a-dropdown">How can I show all the methods that are available in my WCF in a dropdown</a> But when I try to create the proxy dynamically to do the same, the below code doesn't work. Please help me to show only the methods that was defined by me. </p> <pre><code>// Using Dynamic Proxy Factory by Vipul Modi @ Microsoft DynamicProxyFactory factory = new DynamicProxyFactory(txtService.Text); // endpoints. string sContract = ""; foreach (ServiceEndpoint endpoint in factory.Endpoints) { sContract = endpoint.Contract.Name; //this is the service interface name, IAccountInfoService } DynamicProxy proxy = factory.CreateProxy(sContract); Type proxyType = proxy.ProxyType; MethodInfo[] methods = proxyType.GetMethods(); foreach (var method in methods) { //if (method.GetCustomAttributes(typeof(OperationContractAttribute), true).Length == 0) // continue; string methodName = method.Name; ddlMethods.Items.Add(methodName); } </code></pre> <p>The code commented method.GetCustomAttributes(typeof(OperationContractAttribute), true).Length doesn't work. It doesn't show any method. If I comment it out, then the result is all methods and variables. I want to restrict it to only user defined methods.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload