project that references another project with WCF service reference - default endpoint not found

时间:2016-07-09 22:46:04

标签: c# .net web-services wcf

I have a project called "AppCore" that I am reusing/referencing in several other projects. AppCore had a method for sending mail via system.net that simplifies emailing. However, I created a WCF service reference (to a service that sends mail in a queue) in the AppCore project, created a test form and was able to use the service just fine. When I create a new project (project name "FeedReader") and reference the AppCore project, however, I get an error: "Could not find default endpoint element that references contract" when attempting to access the WCF service. I think this has something to do with the compiler looking for endpoint info in the FeedReader project app.config file and not getting it from the AppCore project app.config file.

If I reference the WCF service directly from the FeedReader project, the endpoint is found. This would be just fine, however I have a dozen or so other projects I wish to have make this same reference and creating a service reference for all of these and future projects makes management difficult and there's no code reuse (something I wish to avoid).

Is this not possible to do (reference a project that references a WCF service)?

In the AppCore project app.config file, you can see the endpoint (it works fine)

  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_ISendMailService" />
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://mailservice:9999/SendMailService.svc/SendMailService"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ISendMailService"
        contract="Service_SendMail.ISendMailService" name="BasicHttpBinding_ISendMailService" />
    </client>
  </system.serviceModel>

Naturally, the other projects don't have endpoints defined as they are referencing AppCore (of which there is a definition). NOTE: I plan on having another few service references in AppCore - but am stuck at just one for now until I can solve this dilemma.

0 个答案:

没有答案