开发者

c# WPF and WCF mapping problem

开发者 https://www.devze.com 2023-01-31 12:54 出处:网络
I\'m actually trying to create a wpf project witch connected to the WCF via services references, I\'m also using the MVVM pattern in my wpf project and I have a problem when I declare in my CTOR of my

I'm actually trying to create a wpf project witch connected to the WCF via services references, I'm also using the MVVM pattern in my wpf project and I have a problem when I declare in my CTOR of my viewModel the serviceManager !

My view.xaml says me: Could not find default endpoint element that references contract 'UserServiceReferences.IUserManagement' 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.

here is my App.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IUserManagement" 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://localhost:2981/UserManagement.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IUserManagement"
                contract="UserServiceReference.IUserManagement" name="BasicHttpBinding_IUserManagement" />
        </client>
    </system.serviceModel>
</configuration>

and here my Web.config in my WCF service:

<?xml version="1.0"?>
<configuration>

    <system.web>
        <compilation debug="true" targetFramework="4.0">
          <assemblies>
            <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
          </assemblies>
        </compilation>
    </system.web>

  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- Pour éviter la divulgation des informations sur les métadonnées, définissez la valeur ci-dessous sur false et supprimez le point de terminaison des métadonnées ci-dessus avant le déploiement. -->
          <serviceMetadata httpGetEnabled="true" />
          <!-- Pour recevoir les détails d'exception des erreurs à des fins de débogage, définissez la valeur ci-dessous sur true. Définissez-la sur false avant le déploiement pour éviter la divulgation des informations d'exception. -->
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <!--<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />-->
  </system.serviceModel>


  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <connectionStrings><add name="RssBddEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=JAGUAR-PC\SQLSERVER;Initial Catalog=RssBdd;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

Thoses two projects are in the same solution.

I'm lost please help me !!!!


You're using WCF 4.0 which uses simplified configuration concepts and will add default endpoints, if no endpoints are defined in configuration or added through code.

about the actual issue, I see that there's difference in Contract name in exception 'UserServiceReferences.IUserManagement' and defined in Endpoint "UserServiceReference.IUserManagement". please note extra 's' in namespace 'UserServiceReference(s). if it's isn't typo, then that could be the cause of the issue. otherwise, check that endpoints are defined in correct configuration file.

HTH.

0

精彩评论

暂无评论...
验证码 换一张
取 消