1

I have two projects in a single solution. One project, let's call it MainProject, becomes an executable. The other project, let's call it ControlsProject, contains UserControl's and is referenced (and used) within the MainProject. The ControlsProject also has a WCF Service Reference.

I have a two questions regarding this configuration:

  1. Can I just copy the WCF configuration from the ControlsProject to the MainProject (which I don't believe I can per " How to include Web reference endpoint configuration in another project ")
  2. In the ControlsProject configuration, the contract doesn't have a fully qualified namespace but rather a name such as 'ServiceName.IServiceInterfaceName'. What should the contract name be since the ControlsProject output will be a file located in the bin folder of the MainProject?

I've tried just copying the configuration over, but received the 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." When I copied over the configuration, I fully qualified the name of the interface as ControlsProject.MyService.IMyService.

Any help you can provide is appreciated!

UPDATE (7/14/2011 5:28pm EST)

Here is the snippet from my client app.config:

<system.serviceModel>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IStatService" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                    maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <security mode="None">
                    <transport clientCredentialType="None" proxyCredentialType="None"
                        realm="" />
                    <message clientCredentialType="UserName" algorithmSuite="Default" />
                </security>
            </binding>
        </basicHttpBinding>
    </bindings>
    <client>
        <endpoint address="http://intranet/StatService.svc"
            binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IStatService"
            contract="StatService.IStatService" name="BasicHttpBinding_IStatService" />
    </client>
</system.serviceModel>

Here is the snippet from my web service web.config:

<system.serviceModel>
  <behaviors>
    <serviceBehaviors>
      <behavior name="">
        <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
  <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Community
  • 1
  • 1
Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95

1 Answers1

0

Anytime you see the "Could not find default endpoint element for such and such contract" then your actual contract (the interface) is not referenced correctly in the app.config file. Go to the interface contract in the controls project double check the namespace it's in, you need that exact namespace."Interface name" as the contract element in the app.config. You also need to make sure your service name=Namespace.MyService is the correct namespace and class. One short way to know if you're right (this is only if you have resharper), in the appconfig where you declare service name= put the cursor over the service name and namespace and hit F12, if it doesn't take you anywhere you're referencing a namespace and class that don't exist, same goes for the contract=, if you F12 on that contract and it doesn't take you there, it's not referenced correctly (possibly misspelled).

Mark W
  • 3,879
  • 2
  • 37
  • 53
  • So if I change that back to what is listed in the contract, my project then throws the following exception: "An error occurred while receiving the HTTP response to http://myadress/MyService.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details." Again, I'm going across projects. – Jason N. Gaylord Jul 14 '11 at 17:38
  • 1
    Is there anyway you can post what's in your app.config? I go across projects all the time with WCF solutions, usually I have the contract and service built up in it's own library, then have another project/app hosting the service and another consuming the service. These errors are very familiar to me, in every case I had something wrong in the app.config – Mark W Jul 14 '11 at 20:48
  • I'm using the defaults as you'll soon see above. – Jason N. Gaylord Jul 14 '11 at 21:28
  • I've posted those config settings. – Jason N. Gaylord Jul 14 '11 at 21:38
  • 1
    Ok, in the client endpoint the name= is not needed from what I can see. Also where is the information about the service you're hosting in the web.config section? I only see you posted the behavior section. – Mark W Jul 14 '11 at 21:55
  • Mark, I'm not quite sure what you mean. What I posted is it from the configuration. I've never needed any other special configuration. – Jason N. Gaylord Jul 15 '11 at 12:30
  • Regarding my first comment on this post, I'm wondering if that isn't the correct error. This service call lasts around 8-15 seconds. Since that's the case, I'm wondering if something isn't timing out. Thoughts on that? – Jason N. Gaylord Jul 15 '11 at 13:15
  • Jason, set the binding in the web.config for the service explicitly. See if that changes anything. Also be sure IStatService is the same name on the service side for the contract you're hosting. – Mark W Jul 15 '11 at 15:06