WCF / EF / SQL Server / VS2017 / C#:多层应用程序在部署到作为托管服务器的本地IIS 10.0时出错 [英] WCF / EF / SQL Server / VS2017 / C# : multi-tier application gets error when deployed to local IIS 10.0 as hosting server

查看:90
本文介绍了WCF / EF / SQL Server / VS2017 / C#:多层应用程序在部署到作为托管服务器的本地IIS 10.0时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试部署具有服务层,逻辑层和数据层的Windows桌面应用程序。数据层使用带有EF 6.2的SQL Server。 UI客户端层是Windows窗体应用程序。



当服务由 WcfSvcUtil.exe托管时,该应用程序在测试调试模式下运行良好。 / code>在IIS中具有服务别名的应用程序-没有错误,所有数据检索和更新都在测试中。



现在,我已经发布了Service层,逻辑层和数据层作为空网站,由IIS在别名子文件夹中的本地计算机(c:/ inetpub / wwwroot /)上托管。我创建了一个以该服务的别名命名的IIS应用程序。 UI层和Service层将发布到计算机上的其他本地文件夹中。



启动UI层并尝试查询SQL Server数据库时,我得到了以下错误:


没有端点在



以下是App.config在UI层中:

  *** 
< configuration>
< startup>
< supportedRuntime版本= v4.0 sku =。NETFramework,Version = v4.5.2 />
< / startup>
< system.serviceModel>
< bindings>
< basicHttpBinding>
< binding name = BasicHttpBinding_IMemberService maxBufferSize = 20000000
maxReceivedMessageSize = 20000000 />
< / basicHttpBinding>
< / bindings>
< client>
<端点地址= http:// localhost / TheACTSFactoryWCFLocal / MemberService /
binding = basicHttpBinding bindingConfiguration = BasicHttpBinding_IMemberService
contract = MemberServiceProxy.IMemberService />
< / client>
< /system.serviceModel>
< / configuration>
***

这是IIS服务器文件夹,称为别名IIS应用程序





这是发布到Bin文件夹中的DLL等





对于.NET 4.5.2中IIS 10.0中托管的WCF服务,IIS服务器的Alias / Bin文件夹部署看起来正常吗?另外,我没有将任何内容发布到Roslyn文件夹(CodeDom)。有任何意见或建议吗?

解决方案

根据您的描述,我发现当您将服务发布到IIS时,主机标记仍存在于您的配置文件中。仅自托管或托管程序(例如Windows服务)需要配置主机。当您在IIS中托管服务时,服务的基地址由IIS中部署的端口号和服务的文件名组成。





这是在IIS中部署的WCF服务的配置文件。





我将服务的端口号设置为8063。





访问该地址,我们将看到服务目录。





创建后的结构目录如下:





Service1是服务的实现类。


I am trying to deploy a Windows desktop application with service layer, logic layer and data layer. The data layer uses SQL Server with EF 6.2. The UI client layer is a Windows Forms application.

The application works great in test debug mode when the service is hosted by the WcfSvcUtil.exe application with a service alias in IIS - no errors and all data retrieval and updates are working in test.

Now, I have published the Service layer, logic layer and data layer as an empty web site to be hosted by IIS on my local machine (c:/inetpub/wwwroot/) in the "alias" subfolder. I created an IIS application named with the alias name for the service. The UI layer and Service layer are published to a different local folder on my machine.

When I start the UI layer, and try to query the SQL Server database, I get the following error:

There was no endpoint listening at http://localhost/TheACTSFactoryWCFLocal/MemberService/ that could accept the message. This is often caused by an incorrect address or SOAP action. See innerException, if present, for more details.

My Service Model element in the web.config in the hosted web site is:

<system.serviceModel>
    <services>
        <service name="ACTSFactoryService.MemberService">
            <endpoint name="BasicHttpBinding_IMemberService"
                address="" 
                binding="basicHttpBinding" 
                contract="ACTSFactoryService.IMemberService" >
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
            <endpoint 
                address="mex" 
                binding="mexHttpBinding" 
                contract="IMetadataExchange" />
            <host>
                <baseAddresses>
                    <add baseAddress="http://localhost/TheACTSFactoryWCFLocal/MemberService/" />
                </baseAddresses>
            </host>
        </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">
        <serviceActivations>
            <add factory="System.ServiceModel.Activation.ServiceHostFactory" 
                 relativeAddress="./MemberService.svc" 
                 service="ACTSFactoryService.MemberService" />
        </serviceActivations>
    </serviceHostingEnvironment>
    <behaviors>
        <serviceBehaviors>
            <behavior>
                <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
                <serviceDebug includeExceptionDetailInFaults="True" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <basicHttpBinding>
            <binding name="BasicHttpBinding_IMemberService" 
                     maxReceivedMessageSize="20000000" maxBufferSize="20000000" />
        </basicHttpBinding>
    </bindings>
</system.serviceModel>

I'm new to WCF and Entity Framework so any suggestions would be appreciated. I also have an app.config and web.config in the Service layer, and app.config in the UI layer. I can post those if you think they will be helpful, but for the IIS web.config shown, I basically combined the endpoints from the Service layer's config files to be published to the IIS web site.

** Changed my web.config file as below **

***

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5.2" />
  </system.web>

  <system.serviceModel >   
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" >
      <serviceActivations > 
        <add factory ="System.ServiceModel.Activation.ServiceHostFactory"
                relativeAddress="./MemberService.svc"
                service="ACTSFactoryService.MemberService" />
     </serviceActivations> 
    </serviceHostingEnvironment>

    <behaviors >
      <serviceBehaviors >
        <behavior >
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

***

Also, when I browse to http://localhost/TheACTSFactoryWCFLocal/MemberService.svc, my Service is found.

The following s the App.config in UI layer:

***
 <configuration>
   <startup>
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
   </startup>
   <system.serviceModel>
     <bindings>
       <basicHttpBinding>
         <binding name="BasicHttpBinding_IMemberService"      maxBufferSize="20000000"
           maxReceivedMessageSize="20000000" />
       </basicHttpBinding>
     </bindings>
     <client>
       <endpoint address="http://localhost/TheACTSFactoryWCFLocal/MemberService/"
         binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IMemberService"
         contract="MemberServiceProxy.IMemberService" />
     </client>
   </system.serviceModel>
 </configuration>
***

Here is the IIS server folder named as the Alias name of the IIS app, there is not SVC file

Here are the DLL's, etc, published to the Bin folder

Does the IIS Server's Alias/Bin folder deployment look normal for a WCF service hosted in IIS 10.0 in .NET 4.5.2? Also, I did not publish anything to the Roslyn folder (CodeDom). Any comments or suggestions?

解决方案

According to your description, I found that when you publish the service to IIS, the host tag still exists in your configuration file. Only self hosted or hosted programs like windows service need to configure host. When you host the service in IIS, the base address of the service is composed of the port number deployed in IIS and the file name of the service.

This is the configuration file of WCF service deployed in IIS.

I set the port number of the service to 8063.

Access this address and we will see the directory of the service.

Click service1.scv to see that the service starts normally.At this time, "localhost:8063/Service1.svc" in the address bar is the address of the service. The client needs to access this address to succeed.

update

If your project is deployed in IIS, I suggest using WCF service application template when creating a project.

The structure directory after the creation is like this:

Service1 is the implementation class of a service.

这篇关于WCF / EF / SQL Server / VS2017 / C#:多层应用程序在部署到作为托管服务器的本地IIS 10.0时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆