gpt4 book ai didi

wcf - 创建 WCF 网络服务时出错

转载 作者:行者123 更新时间:2023-12-05 00:50:10 25 4
gpt4 key购买 nike

我创建了一个新的 WCF Web 服务,但是当我尝试运行它时,我得到了这个错误

No code was generated.If you were trying to generate a client, this could be because the metadata documents did not contain any valid contracts or servicesor because all contracts/services were discovered to exist in /reference assemblies. Verify that you passed all the metadata documents to the tool.Warning: If you would like to generate data contracts from schemas make sure to use the /dataContractOnly option.

我的 web.config 看起来像

<services>
<service name="namespace.serviceName"
behaviorConfiguration="MyServiceTypeBehaviors" >
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>

背景是,我从第三方获得了一个 dll,我创建了一个新的 Web 服务,这样我就可以实现所有需要的接口(interface)方法,但是当我尝试运行这个 Web 服务时通过 Visual Studio,我得到了上面显示的错误。

如果我直接运行 website.com/folder/serviceName.svc,我会看到该服务,但单击它不会执行任何操作。

更新:我已经修复了上述错误,我在 web.config 文件中进行了一些更改,但是现在当我运行我的服务时,我没有得到任何方法(我正在使用 Visual Studio 内置的 WcfTestClient)

最佳答案

这个问题在 VS2022 中依然存在。事实证明,取消勾选“在引用的程序集中重用类型”并删除 obj 和 bin 目录会有所帮助。

关于wcf - 创建 WCF 网络服务时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26344215/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com