[Mono-list] InternalsVisibleTo - how to use

Abe Gillespie abe.gillespie at gmail.com
Tue Apr 6 13:16:18 EDT 2010


Oh, sorry, totally my bad.  The classes were inheriting internal members
from base classes in another assembly - that's where I needed to place the
[assembly] attribute.  For the record, I didn't have to all the strong name
stuff and it worked as you originally suggested.

Thanks for the help.
-Abe

On Tue, Apr 6, 2010 at 1:12 PM, Abe Gillespie <abe.gillespie at gmail.com>wrote:

> Hmm ... can't seem to get it to work in MD.
>
> This is what I've done:
> 1.  Added assembly: InternalsVisibleTo("MyTest,
> PublicKey=a-bunch-of-hex-chars")] to the granting assembly a la
> http://stackoverflow.com/questions/106880/internalsvisibleto-attribute-aint-workin
> <http://stackoverflow.com/questions/106880/internalsvisibleto-attribute-aint-workin>2.
>  Generated a strong name file with "sn -k Tests.snk".
> 3.  In the Unit Tests project set the Options > Build > Assembly Signing to
> point to the Tests.snk file.
> 4.  Compiled the Unit Tests project first w/o any internal member
> references so it gets the strong name.
> 5.  Add the code to the Unit Test project that references internal members
> in the other assembly.
>
> 6.  No worky - Error CS0122: `<internal-member>' is inaccessible due to its
> protection level (CS0122) (UnitTests)
>
> Thoughts?
>
> On Tue, Apr 6, 2010 at 12:49 PM, Robert Jordan <robertj at gmx.net> wrote:
>
>> On 06.04.2010 18:39, Abe Gillespie wrote:
>> > What do I need to do to allow the InternalsVisibleTo attribute to work
>> for a
>> > testing project within MonoDevelop.  (If this is a MD-specific question
>> then
>> > I'm happy to take the discussion there.)
>>
>> Add this attribute to the assembly whose internals should
>> be exposed:
>>
>> [assembly: InternalsVisibleTo("Assembly.Name.Of.Your.Test.Assembly")]
>>
>> If your test assembly is called "Test.dll", the assembly name would
>> be "Test".
>>
>> MonoDevelop isn't even involved here.
>>
>> Robert
>>
>> _______________________________________________
>> Mono-list maillist  -  Mono-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-list
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20100406/99ad7d7c/attachment.html 


More information about the Mono-list mailing list