任何想法如何解决这一问题?
UserService.UserServiceClient userServiceClient = new UserServiceClient();
userServiceClient.GetUsersCompleted += new EventHandler<GetUsersCompletedEventArgs>(userServiceClient_GetUsersCompleted);
userServiceClient.GetUsersAsync(searchString);
Run Code Online (Sandbox Code Playgroud)
.
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_UserService"
maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:52185/UserService.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_UserService"
contract="UserService.UserService"
name="BasicHttpBinding_UserService" />
</client>
<behaviors>
<serviceBehaviors>
<behavior name="Shell.Silverlight.Web.Service3Behavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
<services>
<service behaviorConfiguration="Shell.Silverlight.Web.Service3Behavior"
name="Shell.Silverlight.Web.Service3">
<endpoint address=""
binding="basicHttpBinding"
contract="Shell.Silverlight.Web.Service3" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
无法在ServiceModel客户端配置部分中找到引用合同"UserService.UserService"的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.
解决!
我没有提到这是一个Silverlight应用程序.我在DLL中有wcf引用,它有自己的"ServiceReferences.ClientConfig"文件.我将DLL的ServiceReferences.ClientConfig的内容移动到主Silverlight项目并且它工作了.
spr*_*ite 185
我遇到了同样的问题.我的应用程序也是一个Silverlight应用程序,该服务是从类库中调用的,其中包含正在使用的自定义UserControl.
解决方案很简单.将端点定义从类库的配置文件(例如ServiceReferences.ClientConfig)复制到silverlight应用程序的配置文件.我知道你希望它能够在不必这样做的情况下工作,但显然雷蒙德的某个人当天有个假期.
Vis*_*hal 44
您还可以在类库中以编程方式设置这些值,这样可以避免配置文件在库中不必要地移动.简单的BasciHttpBinding的示例代码是 -
BasicHttpBinding basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);
basicHttpbinding.Name = "BasicHttpBinding_YourName";
basicHttpbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
basicHttpbinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
EndpointAddress endpointAddress = new EndpointAddress("http://<Your machine>/Service1/Service1.svc");
Service1Client proxyClient = new Service1Client(basicHttpbinding,endpointAddress);
Run Code Online (Sandbox Code Playgroud)
Mik*_*ill 12
以防万一在使用WPF(而不是WCF或Silverlight)时遇到同样的问题:
连接到Web服务时出现此错误.当我的代码在"主要"WPF应用程序解决方案中,没有问题,它完美地工作.但是当我将代码移动到更合理的DAL层解决方案时,它会抛出异常.
无法在ServiceModel客户端配置部分中找到引用合同"MyWebService.MyServiceSoap"的默认端点元素.这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素.
正如此线程中"Sprite"所述,您需要手动复制标记.
对于WPF应用程序,这意味着复制从标签的app.config在我DAL解决的app.config主WPF应用程序的解决方案.
我遇到了同样的问题,无论出于什么原因,当我第一次添加服务时,Visual Studio没有更新Web配置.我发现更新服务参考也解决了这个问题.
脚步:
| 归档时间: |
|
| 查看次数: |
140718 次 |
| 最近记录: |