简体   繁体   中英

How to access a C# internal property from VB.NET project in same solution?

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"?

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")]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM