How can I get rid of the "The target assembly contains no service types" error message in VS2008?
Solution 1
It's always like that. You search for 2 hours, you eventually end up posting on SO, and 5 minutes later, you find the answer.
In the WCF Options tab of the properties of the project defining the ServiceContract
,
there's a checkbox labelled "Start WCF Service Host when debugging another project in the same solution" that I unchecked.
I've no idea how it has been checked in the first place.
Anyway, that solved my problem. See the MSDN Reference for this project setting.
Solution 2
Just in case anyone else is looking for an answer, another cause of this error can be if you happen to have an App.config
file in a project that is a Class Library that has a <system.serviceModel>
section.
I moved service code out of a project that was an executable to a different project but accidentally left the old App.config
file. My new project, which was a Console application programatically configured and started WCF, but because the old App.config
file was in the referenced assembly, I would get that cryptic dialog box even when debugging the Console application.
Took about 12 hours to track this one down since I didn't realize that VS debugger checks all referenced assemblies for App.config which have WCF services configured.
Solution 3
To determine project with this problem find string 3D9AD99F-2412-4246-B90B-4EAA41C64699 in your project files.
Example: <ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
Then turn off project option "WCF Options/Start WCF Service Host when debugging another project in the same solution"
Solution 4
Some blogs say, it might have happend because of copying the project from a different branch, that overrides GUIDs... so just delete them as explained in this blog.
Solution 5
This error can also be caused by a wrong service name in your config file:
<system.serviceModel>
<services>
<service name="MyServiceLibrary.WrongServiceName">
...
Check your config file and be sure the service name is correct.
Brann
Updated on July 05, 2022Comments
-
Brann almost 2 years
I've got a Client/Server wcf application
My executable doesn't define any
ServiceContract
, it doesn't even have a reference toSystem.ServiceModel
(but instead has a reference to an assembly which contains the connection logic to the server)I've another assembly, which is referenced by my EXE, which contains a
ServiceContract
.It used to work fine. Yesterday, I've played a lot with my project settings (partial trust, full trust, deployment settings, and so on) and now, each and every time I launch my client, I've got the following message box :
Microsoft WCF Service Host
The target assembly contains no service types.
You may need to adjust the Code Access Security policy of this assembly.Then VS freezes for 1 minute, and eventually lets me debug my program as usual.
I've found a post on this problem, but the solution doesn't apply in my situation. Any ideas?
-
joncodo over 12 yearsWhere is this in visual studio 2010?
-
Brann over 12 years@Jonathan: my bet is that you're not looking at the properties of the correct project. You need to select the project defining the contract; not the one implementing it nor the one calling it.
-
joncodo over 12 yearsThanks Brann, you were right about it. It is in the same place in 2010
-
Omar Kooheji about 12 yearsI'm seeing this same issue and the project defining the contract doesn't have a WCF options tab. It's infuriating...
-
PositiveGuy over 10 yearsI'm looking in my WCF Web Service Project, my actual WCF service project. The properties have nothing to that effect.
-
puddinman13 about 9 yearsThis solved my issue. I think it's because I have the service defined in a different project from which it's implemented.
-
Ricardo Appleton over 7 yearsWhile this solution might resolve the matter for some folks, at least in vs2015 it will remove "Publish" from the context menu when right-clicking on the WCF project...
-
Hugo about 7 yearsFrom VS2015 removing de Guid, went the project invalid
-
wcb1 over 4 yearsYes this will help us find which project we have mistakenly checked the "Start WCF Service Host when ..." as @Brann pointed out. I am using the following command to find which project has the setting: c:\MyProjects>findstr /s /m "3D9AD99F-2412-4246-B90B-4EAA41C64699" *.csproj