Abishek Alva
Abishek Alva

Reputation: 99

VB using WCF: Cannot find endpoint element via com wrapped C# dll

I have been getting this error "Could not find endpoint with name... " when I try running my Vb6 application that consumes .Net dll referenced with WCF service. Am sure this has to be something that needs to be dealt with config file. Since the config file in dll is looking absolutely fine and has endpoints configured properly, am suspecting I may need to have a app.config file for VB6 application since that is the caller application which ideally should consume WCf service via C# dll. It would be great if someone could through a thought on how this needs to be dealt.

Upvotes: 0

Views: 107

Answers (1)

Abishek Alva
Abishek Alva

Reputation: 99

I found answer for this. Based on the approach followed VB6->C# DLL->WCF Service, the WCF service would search config file for the executing assembly which basically is VB6 exe. This would result in an error "Cannot find endpoint element...". So in order to resolve this, I manually tried setting the binding properties in the com wrapped C# dll and passed in binding object along with EndPointAddress to the constructor of the service on instance creation. Below is the code snippet that sets the binding properties similar to that of config file.

        Binding.SendTimeout = TimeSpan.FromMinutes(1);
        Binding.OpenTimeout = TimeSpan.FromMinutes(1);
        Binding.CloseTimeout = TimeSpan.FromMinutes(1);
        Binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
        Binding.AllowCookies = false;
        Binding.BypassProxyOnLocal = false;
        Binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        Binding.MessageEncoding = WSMessageEncoding.Text;
        Binding.TextEncoding = System.Text.Encoding.UTF8;
        Binding.TransferMode = TransferMode.Buffered;
        Binding.UseDefaultWebProxy = true;

This might be one of the possible ways to resolve this issue if someone is facing similar issue.

Upvotes: 1

Related Questions