InternalsVisibleTo is not working for my managed C++ projects, but it is for my C# projects. Any help would be appreciated. Here is a simplified layout.
Project A - C#, has an internal property I want to access from B/C.
Project B - Managed C++. References A.
Project C - C#, references A.
All projects are signed with the same key. Looking at the compiled assemblies with ILDASM or Reflector show that they are all signed correctly (when I comment out the internal property usage).
In AssemblyInfo.cs in Project A, I have the following InternalsVisibleTo;
[assembly: InternalsVisibleTo( "B, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" )]
[assembly: InternalsVisibleTo( "C, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" )]
The keys are cut'n'pasted, so I know they are correct.
When I try to compile, A & C compile fine, but project B fails with
Error 1 error C3767: 'A::MyClass::MyProperty::get': candidate function(s) not accessible c:\Users\<snip>\CppClass.cpp 201 B
The MSDN docs say this works with C++. Is there a bug or something else I need to do?
Is there another way that I can protect a property so that it can only be used by assemblies signed by me? I know I can protect all of my assembly, but can I do it on a granular level like this?
EDIT
Based on comments in MSDN, I changed the attribute to the following, but that still doesn't work.
[assembly: InternalsVisibleTo( "B, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" ),
InternalsVisibleTo( "C, " +
"PublicKey=00240000048000009400000006020000002400005253413100040000010001007" +
"50098646D1C04C2A041FAAF801521A769535DE9A04CD3B4DEDCCBF73D1A6456BF4FE5881451" +
"0E84983C72D0460B8BA85C52A9CACDC4A0785A08E247C335884C2049ECFE6B2C5E20A18FE4B" +
"9BFF009ADA232E980D220B3C9586C9C5EE29C29AEE8853DB7BB90CF5A4C704F5244E1A1085C" +
"4306008535049A0EBB00FE47E78DCB" )]