Link to home
Start Free TrialLog in
Avatar of vbturbo
vbturboFlag for Denmark

asked on

WCF: Could not find default endpoint that reference contract in DLL

Hi

i keep getting this exception thrown:

Could not find default endpoint that reference contract 'UploadService.IMyService' in the servicemodel client configuration section.

my service is hosted on iis and runs fine and i have no problem consuming the client when integregating the service directly into my client ! my problem is " i'm not able to consume the service via a class libary "
what am i missing here ?

Thanks


code:
 
    Public Function WindowsClientUploadService(ByVal SourceLocation As String, ByVal DestinationLocation As String, ByVal Credential As System.Net.NetworkCredential) As Boolean
        Dim client As MyServiceClient = New MyServiceClient()  <------ exception occours when instanciating the proxy
 
        client.Open()
        client.MyUploadOperation(SourceLocation, DestinationLocation, Credential)
 
    End Function
 
app.config
 
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IMyService" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://mydomain.com/UploadService/Service.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMyService"
                contract="UploadService.IMyService" name="BasicHttpBinding_IMyService" />
        </client>
    </system.serviceModel>
</configuration>
 
web.config
 
<?xml version="1.0"?>
 
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
  <system.serviceModel>
    <services>
      <!-- Before deployment, you should remove the returnFaults behavior configuration to avoid disclosing information in exception messages -->
      <service name="MyService" behaviorConfiguration="MyServiceBehavior">
        <endpoint contract="IMyService" binding="basicHttpBinding"/>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior" >
			<serviceMetadata httpGetEnabled="true" />
			<serviceDebug includeExceptionDetailInFaults="true"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
 
  <system.web>
    <compilation debug="true"/>
  </system.web>
</configuration>

Open in new window

Avatar of p_davis
p_davis

what does the class look like?
Avatar of vbturbo

ASKER




Here is the code for the dll (class libary "class")

I ve add the WCFservice here(in this class) with standard wizzard



Imports System.ServiceModel
Imports System.Runtime.Serialization
Imports UploadingComponent.Upload

Public Class UploadingComponent

    Public Function WindowsClientUploadService(ByVal SourceLocation As String, ByVal DestinationLocation As String, ByVal Credential As System.Net.NetworkCredential) As Boolean

        Dim client As MyServiceClient = New MyServiceClient()  <------ exception occours when instanciating the proxy


        client.MyUploadOperation(SourceLocation, DestinationLocation, Credential)
 
    End Function

End Class


In my winapp in the reference libary i added the dll
then creating an instance of the class lib and accessing the above method


Avatar of vbturbo

ASKER

Seems like the config files are not included in the dll ?

exception
Could not find default endpoint element that references contract 'MyService.IMyService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.

its just strange when i add the WCFservice with the wizzard inside my winapplication then it runs like a charm

where ever your host is that is where you should have the app.config file. and it will convert to a app.config.exe file when it is built. that is what the program will use.
Avatar of vbturbo

ASKER

i have attached a small file to illustrate it a bit better



wcf-service.bmp
Avatar of vbturbo

ASKER

if i want a redistributable library that i can in incorporate in my win and web clients , then how should i put all of the classes and contracts used by the service into a Library assembly ?
i have never used the wizard so i don't know what it sets up for you-- can you debug through the instantiation of your class to see if that might lend any clues as to why this is happening. or turn on tracing.-- sometimes those messages don't mean crap and the problem is quite different-- then again sometimes they are right on. --have you tried to turn on tracing through the service configuration manager?
Avatar of vbturbo

ASKER

if you are inside a e.g windows project / solution you have the ability to add

1) reference
2) webservice
3) wcfservice

then a wizzard popsup asking where the service is hosted , then you type the uri and vola it generates the proxy
and the contract,app.config, service.map ,etc.... inside your solution.

at that point in the windows application you just add the namespace and

Dim client As MyServiceClient = New MyServiceClient()

'call you method/function in the service

client.MyUploadOperation()

and the code executes as expected.

now creating a new class library solution and doing the same procedure from above and then from the windows application add a reference (the dll from the class library solution bin folder)

Dim client As MyServiceClient = New MyServiceClient()  <------ exception occours when instanciating the proxy inside the dll code block.


ive found some same questions here

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=334409&SiteID=1
https://www.experts-exchange.com/questions/23057851/Problem-with-Web-Service-in-vs-2008-project-was-working-previously.html

seems like a common problem whitout a solution (where went the flexibillity with WCF ? -:) )



thanks for still hanging on
so when you use the addition of the wcfservice to the class library does it dump a myClass.dll.config file in the project?
Avatar of vbturbo

ASKER

no it dont

only a app.xml    configuration file
not to abandon you original implementation but is it possible for you to use the channel factory and hardcode the endpoints in the client?
Avatar of vbturbo

ASKER

i am open to any suggestion

also if you have some sample code that can point me in the right direction.
Though carry over with me but im a new bee regarding wcf

every input is very much appreciated.

it's for winforms but you can see how to code the endpoints. it might not be viable as  it isn't configurable once it is compiled (unlike the config files which you can write an app to modify on the fly).

http://www.codeproject.com/KB/WCF/WCFexample.aspx
Avatar of vbturbo

ASKER

its getting over midnight hours here...... ill look forward checking up on you tomorrow
Avatar of vbturbo

ASKER

Hi thanks for the link

Also its a great article , and could serve my purpose to some extend.
Though i need to host the service on IIS 5.1 , which is a great deviation from the article and i need the abstraction level to be higher in order for any type of client (win or web) that i build to be able to consume this service.

I wonder if it is posible to encapsulate the config settings and proxy into a dll
This would make a nice way to distribute a upload functionallity to whatever enviroment where a client could reside.
ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vbturbo

ASKER

This seems to be the way to go , but in my opinion the wcf library is somewhat still incomplete.
I know that it is the way to go not using designers / wizzards at all and on the other hand when
providing them as a tool ,they should at poses some flexibillity.

And it should save you some trivial coding efforts..

Thanks for taking your time (i have expanded my horison)


 

 
there designer is by far not ready for wcf. i have just started using 2008 and it is still not very encouraging. also the documentation on this stuff is still, really lacking and what is there is ambiguous as to what is the best practice. inmo wcf is pretty cool but there are a lot of stumbling blocks in the beginning-- thanks for the points and good luck.
I am facing the same issue in latest version framework 4.0 not sure how to handle it.

DLL consumes WCF service and dll method called from another application which is windows service. I have clients end point config in app.exe.config of windows service but it still fails.