How to use InternalsVisibleTo in VB?

Hello!

I tried to create friend assemblies by using the InternalsVisibleTo attribute, but the example in MSDN doesn't work. I tried to add


<assembly: InternalsVisibleToAttribute("AssemblyA, PublicKeyToken=AssemblyA.snk")>
 


to AssemblyInfo.vb but IntelliSense didn't even accept the attribute name. I signed the other assembly that has to be the "friend" with a strong name key file "AssemblyA.snk".

Could anybody give me an example how to do this signing

Thanks!


Answer this question

How to use InternalsVisibleTo in VB?

  • Ben Christian

    If it did not accept the Attribute are you sure you had System.Runtime.CompilerServices referenced and imported   This attribute is not availble except in .Net 2.0



  • jocamill

    First of all this attribute is only available in .NET 2.0.

    Second of all the attribute unlike in previous betas and CTP versions now only accepts the full PublicKey of the assembly you want to trust. You also can't point it to the path of a strong name key.

    I've actually written a small utility to help generate these attributes for VB and C# (as it can be a pain to get the public key):

    You can download it from here:
    http://davidkean.net/archive/2005/10/06/1183.aspx



  • How to use InternalsVisibleTo in VB?