How can I get rid of the "The target assembly contains no service types" error message in VS2008?

.NetVisual Studio-2008WcfDebugging

.Net Problem Overview


I've got a Client/Server wcf application

My executable doesn't define any ServiceContract, it doesn't even have a reference to System.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?

.Net Solutions


Solution 1 - .Net

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 - .Net

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 - .Net

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 - .Net

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 - .Net

I also went through the same kind of problem and searched for hours to get rid of this particular error. Finally i did find out a way out of it.

When you come across this particular problem, you try to run your both server and client application as administrator, and change the WPF properties of project.

When you click the WPF properties of the project, you will find a build option. In build option, there is a option called PLATFORM TARGET, in which you can change the platform target to x86. Also note that in case of x84, you need to set it to x84.

Now run your project from console, i.e. go to the folder where your projects are saved and in the bin of client, you will find a folder debug where you will get your console application. You should now be able to run the application successfully.

Solution 6 - .Net

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.

Solution 7 - .Net

Old thread. Just remove any commandline arguments from the Debug section in Options. That helped me.

Solution 8 - .Net

Adding another solution since this message seems to have multiple causes. Removing the following GUID from the ProjectTypeGuids tag in the project file resolved the issue.

<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699}</ProjectTypeGuids>

Solution 9 - .Net

In my case the problem was, because one of the normal class library project (that was referenced by the WCF service library) had this in it's .csproj file:

<ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}">
        <WcfProjectProperties>
          <AutoStart>True</AutoStart>
        </WcfProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>

Changing this to False solved the problem. This answer was already there, but make sure that you checked all projects, not just the WCF service library one.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionBrannView Question on Stackoverflow
Solution 1 - .NetBrannView Answer on Stackoverflow
Solution 2 - .NetbpeikesView Answer on Stackoverflow
Solution 3 - .Netalexey.petriashevView Answer on Stackoverflow
Solution 4 - .NetHydPhaniView Answer on Stackoverflow
Solution 5 - .NetREESHABH CHOUDHARYView Answer on Stackoverflow
Solution 6 - .NetStackedView Answer on Stackoverflow
Solution 7 - .NetBlueHeavenView Answer on Stackoverflow
Solution 8 - .NettgriffinView Answer on Stackoverflow
Solution 9 - .NetMuzzyView Answer on Stackoverflow