简体   繁体   English

WCF主机控制台服务代码到IIS7?

[英]wcf host console service code to iis7?

I created a console Application which hosts the service... now i want to take the service and host it on iis7 我创建了一个托管服务的控制台应用程序...现在,我想获取服务并将其托管在iis7上

I created the .svc file 我创建了.svc文件

configured the iis7 配置了iis7

http://i.stack.imgur.com/Ehfhs.jpg http://i.stack.imgur.com/Ehfhs.jpg

在此处输入图片说明

all the compiled code i put on outside directory : 我放在外部目录中的所有已编译代码:

http://i.stack.imgur.com/k0gAh.jpg http://i.stack.imgur.com/k0gAh.jpg

在此处输入图片说明

and the bin file inside the APP code folder... 以及APP代码文件夹中的bin文件...

and it tells me : http://i.stack.imgur.com/B3NKn.jpg 它告诉我: http : //i.stack.imgur.com/B3NKn.jpg

在此处输入图片说明

what am i missing ? 我想念什么?

Can i convert console hoster to iis hoster ? 我可以将Console Hoster转换为iis Hoster吗?

should it have to be website in the first place ? 首先应该是网站吗?

should the service also need to have the config ( in my console app it didnt - only the hoster).....? 该服务是否还需要具有配置(在我的控制台应用程序中没有,只有托管者).....? ps as you can see i did clone the config here. PS,如您所见,我确实在这里克隆了配置。 ( to the service dir) and also to the output dir. (指向服务目录)以及输出目录。

The easiest would be to create a new empty ASP.NET application to which you add a new WCF service. 最简单的方法是创建一个新的空ASP.NET应用程序,并向其中添加新的WCF服务。 Then simply replace the generated code with the one of your service. 然后只需将生成的代码替换为您的服务之一即可。

I think the reason why your code doesn't work is because you have an ASP.NET website (and not ASP.NET application) and in your .svc file you are only specifying the name of the service but not the codebehind file that contains it. 我认为您的代码无法正常工作的原因是因为您拥有一个ASP.NET网站(而不是ASP.NET应用程序),并且在您的.svc文件中,您仅指定了服务名称,但没有指定包含它。 Since an ASP.NET website is not compiled you need to specify this : 由于未编译ASP.NET网站,因此需要指定以下内容

<% @ServiceHost 
    Service="Service.Class1" 
    Debug="Debug"
    Language="C#" 
    CodeBehind="~/App_Code/Class1.cs"
%>

Also you are mentioning some bin file inside the APP code folder . 您还提到了APP代码文件夹中的某些bin文件 If you have some precompiled service in an assembly, this assembly should be inside the ~/bin folder. 如果程序集中有一些预编译的服务,则该程序集应位于〜/ bin文件夹中。 In a precompiled ASP.NET application you should not have any App_Code folder. 在预编译的ASP.NET应用程序中,您不应具有任何App_Code文件夹。 It's really 2 different modes: application vs website. 这实际上是2种不同的模式:应用程序与网站。 Up to you to decide which mode you prefer. 由您决定自己喜欢哪种模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM