tags:

views:

161

answers:

1

My Visual Studio 2008 solution contains both C# and VB.NET projects. From a VB.NET project, how can I access a C# property with its access modifier set to "internal"?

+7  A: 

You need to make the assembly's friends with the InternalsVisibleTo attribute.

Assuming that you don't sign your assemblies, it's as easy as adding an assembly level InternalsVisibleTo attribute to the C# project with the name of the VB.Net assembly. Typically you do this in AssemblyInfo.cs (under the Properties folder)

[assembly:InternalsVisibleTo("MyVbAssemblyName")]
JaredPar
+1 beat me to it.
klabranche
Here's an SO link discussing this: http://stackoverflow.com/questions/171332/accessing-internal-members-via-system-reflection
klabranche
Thanks. Works great between C# and VB.NET. It looks like there's no good way to make my C# internals visible to ASP.NET though. That's not a huge problem for me though.
Slack