3

I have a Common DLL which have some internal methods for internal usage. Beside I also have 3 other projects WebServices, UnitTests and PATs

In AssemblyInfo.cs of Common project, I added these lines:

[assembly: InternalsVisibleTo("WebServices, PublicKey=00240...b59a0")]
[assembly: InternalsVisibleTo("UnitTests, PublicKey=00240...dcf98")]
[assembly: InternalsVisibleTo("PATs, PublicKey=00240...e65cf")]

These internal methods work perfect with UnitTests and PATs but WebService. It's weird that I can see these internal methods in the IntelliSense box when I write code in WebService project. There is no error alert when I write code but when I build the project, I got this error message

'Common' does not contain a definition for 'internal method name'

At that time, I thought the assembly name is wrong in some way. And I try to make it's really wrong for sure:

[assembly: InternalsVisibleTo("WebSer, PublicKey=00240...b59a0")]

Then in the WebService project, it turns red immediately at the line I use Common internal methods without compiling with this message:

Cannot access internal method 'internal method name' here

So I think my assembly name is correct but I still don't know why I cannot use internal methods in my WebServices project.

Daniel A.A. Pelsmaeker
  • 47,471
  • 20
  • 111
  • 157
Vi Tran
  • 31
  • 1
  • 4
  • I have just found some clues for this. In my WebService project, I used Workflow, when I remove all Workflows, the build was success. And I re-add Workflow into my project, above error occur. Is there anyone know what's wrong with friendly assembly for assembly which use Workflow ? – Vi Tran Dec 08 '11 at 16:41

1 Answers1

0

The first error message you gave here suggests that you are using wrong namespace:

'Common' does not contain a definition for 'internal method name'

It means that the method you want to use it's not there. It is in some other namespace most probably - especialy if you're using extension methods to your classes.

As you've probably noticed, the second error you've got, after putting wrong name to InternalsVisibleTo expression, is different:

Cannot access internal method 'internal method name' here

Only the second error is related to exposing internals to other dll.

It's also possible that Visual Studio has gone crazy and restarting/rebuilding would be sufficient.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Zbyszek M.
  • 85
  • 1
  • 8