Problem with type of service in ServiceHost direct

2019-01-31 12:12发布

I am developing a simple wcf service for test. When I test this service with my local IIS 7.5, then it works properly. But when I host it in web IIS, I receive this error:

The type 'WcfServiceLibrary1.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.

And my ServiceHost is:

<%@ ServiceHost Language="C#" Debug="true" Service="WcfServiceLibrary1.Service1" %>

Please help me resolve this problem

18条回答
我只想做你的唯一
2楼-- · 2019-01-31 12:18

I had the same issue only when publishing my service but it worked locally.

It turned out to be that the service was referencing a DLL that wasn't being deployed. It's a super special case because it was a system dll (System.Web.Helpers) and thus the project didn't even have a reference to it and thus the "Copy Local" wasn't set to true.

查看更多
Deceive 欺骗
3楼-- · 2019-01-31 12:20

I had this same problem after I deployed a working service to a new location (new site) in IIS. In inetmgr under the Default Website tree, I hadn't right-clicked the new site and selected Convert to Application - all working now!

查看更多
劳资没心,怎么记你
4楼-- · 2019-01-31 12:21

Even though this is slightly different than the question (not web iis): I got here through search because I was getting this error trying to Debug my service -- if you have multiple services inside a single solution, this error will occur if the solution in question is not built yet, and therefore the DLL not created when you try to access it. So to anyone out there make sure if running locally that the entire solution is built!

查看更多
该账号已被封号
5楼-- · 2019-01-31 12:21

Strange as well, after looking and trying others suggestions, i was still getting the error saying the: The type ', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.

Sure we all get large project with a lot of DLLs. Turned out some of the older components in my solution were targeting .Net 4.5, and newer dll were build with 4.5.1. When the 4.5 dlls referenced the 4.5.1 dlls .... Not sure why i was the happy little guinea pig to be the first on my team to find this. While the fix was obvious and easy enough, just all the dlls to target the same .Net runtime.

Just wish Visual Studio would notice DLLs within the same solution should all target the same .Net runtime and generate a warning/error when building especially with we have a solution and a project reference and the runtimes don't match...

查看更多
戒情不戒烟
6楼-- · 2019-01-31 12:21

It happend the same to me and the solution was creating a forder named "bin" and place the dll inside of it. Then, refresh the website on IIS and that's all

查看更多
Anthone
7楼-- · 2019-01-31 12:22

Because I couldn't find this suggested in any of the questions I looked through for this, adding my case here:

I had this problem when I manually changed the namespace in the file MyService.svc.cs, and did not change the Service name in the corresponding file MyService.svc - turned out that it needed to be Service="namespace.classname".

查看更多
登录 后发表回答