无法使用重命名的服务运行WCF服务应用程序

本文关键字:服务 运行 WCF 应用程序 重命名 | 更新日期: 2023-09-27 18:12:59

我有一个基本的解决方案,我已经添加了一个WCF服务库。在将初始wcf服务应用程序添加到解决方案后,我可以在浏览器中查看创建的默认服务。但是,在我重命名默认的wcf服务及其接口类并在浏览器中查看该服务之后,web页面显示以下运行时错误:

The type 'MyNewService.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

然而,如果我在项目结构中搜索'Service1',则没有返回对'Service1'的引用。你知道这个错误的根本原因是什么吗?在过去,我似乎已经成功地做到了几次,我想我以前从来没有遇到过这个障碍。

无法使用重命名的服务运行WCF服务应用程序

查看app.config,查看endpoint->contract,我猜这就是需要更新的地方。

<system.serviceModel>
    <services>
        <service name="WcfServiceLibrary1.MyService1">
            <endpoint address="" binding="basicHttpBinding"                 
                contract="WcfServiceLibrary1.**IMyService1**">

默认情况下,WCF是通过库的App.config文件配置和公开的。在App.config中搜索旧名称并将其更改为新名称。

当你想在将来更改服务的名称时,使用refactor name(默认的ctrl+r, r)操作,它也会在配置文件中为你找到名称