Welcome to RightHand's community place Sign in | Join | Help

"The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly." annoyance

Did you ever encounter this dialog box when dealing with WCF services?

"The target assembly contains no service types.  You may need to adjust the Code Access Security policy of this assembly."

It might happen when you run application at debug time. It is highly annoying and time consuming (it pauses application for more than one minute without any apparent reason). But what does it mean and why does it happen?

When you create a project from a WCF project templates Visual Studio knows that this project is a WCF service and thus it offers two debug time helpers: WCF Service Host and WCF Client. These two guys are intended to help you with running and testing WCF services without writing any code - they just appear at debug time. So far so good. But why the annoying dialog?

The dialog in question means that you have a project, created using one of the WCF project templates, with an interface marked with ServiceContract attribute and in the same project you don't have a class that implements this interface (perhaps you implemented that interface in another project). So, the WCF Service Host can't find a suitable class to host the service and it complains through that dreaded dialog box. Note that WCF Service Host is pretty dumb and it is incapable of searching through other projects in same solution. OK, the solution is to stop running WCF Service Host or even better, instruct it which class implements the interface in question. Well, AFAIK the later is impossible while the former can be done through project file modification using notepad. Here is how:

Delete this line from your project file:

<ProjectTypeGuids>{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

And you won't see WCF Service Host or dreaded dialog anymore.

The question is, why didn't Microsoft think of these scenarios before?

BTW, if you just want to stop WCF Client from runing then delete this command line argument: /client:"WcfTestClient.exe", created by WCF project template.

Published 10. marec 2008 9:45 by Miha Markic
Filed under: ,

Comments

# re: &quot;The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly.&quot; annoyance

17. marec 2008 22:51 by Raghu
Thanks.. your tip saved me couple of hours of my research.

# re: &quot;The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly.&quot; annoyance

16. april 2008 16:20 by Peter Schnupp
Sorry, where must I delete which line: ------------------------------------------- Delete this line from your project file: {3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} And you won't see WCF Service Host or dreaded dialog anymore. ---------------------------------------- My browser only shows a horizontal scroll bar instead of the stuff. Thanks a lot, Peter

# re: "The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly." annoyance

21. april 2008 13:28 by Miha Markic

You have to delete from project file (.csproj or .vbproj or some else, depending on the project language):

<ProjectTypeGuids>

{3D9AD99F-2412-4246-B90B-4EAA41C64699};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

You have to open the file in question in text editor application, i.e. notepad.exe.

# re: &quot;The target assembly contains no service types. You may need to adjust the Code Access Security policy of this assembly.&quot; annoyance

8. junij 2008 6:44 by George
Thanks for sharing that, but I tried it and it caused my Test Project (which has that value deleted) kind of disabled and not being able to run any test.
New Comments to this post are disabled