tags:

views:

431

answers:

2

Hi,

In my WCF service, I have methods that are currently public, but I want to hide them from the outside world but be able to use them in my WCF service.

Is internal what I'm looking at?

+2  A: 

yes internal will limit access to the current assembly

http://msdn.microsoft.com/en-us/library/ba0a1yw2.aspx

Hath
True it limits access, but it's not a complete answer. Really, "public" is ok as long as the developer doesn't openly expose them with the ServiceContract attribute as stated above.
Timothy Khouri
+2  A: 

All you have to do to not have the outside world ( WCF clients) know of them is to not mark them with [ServiceContract] attribute, then it doesn't matter if they are public

if you distribute the DLL with the WCF service in it you can mark the methods:

  • private (can only be called from within the same class)
  • protected (same as private + a class inheriting from it)
  • internal (same as private + all other classes in the same assembly + any classes in assemblies which has been named in InternalsVisibleTo (google it)
AndreasKnudsen
thanks for the userfriendly definitions. InternalsVisibleTo is a new one!
Blankman
I agree removing the [ServiceContract] decoration is the correct answer.
Chris Marisic