I am working in VB for Visual Studio and have a class in a project that needs to declare a variable as a class in another project. For visualization: Solution A contains Project1 and Project2. In a class in Project1 I need to declare a variable as a classname of Project2. The class I need to access is a Friend class and I know I have to do something involving Imports, declarations, references, and maybe class libraries. If anyone can spell this out for me I'd appreciate it. I'm new to VB.
A friend class can only be accessed from the same assembly, unless you muck around with the InternalsVisibleTo attribute. If these assemblies are not declared as "Friend Assemblies" you need to make the class public. Given you're beginning to learn VB.NET I'd stick with making the class public.
You also need to add a project reference from Project1 to Project2. In the solution explorer right click "References" and choose Add Reference in the dialog that pops open, select "Solution"/"Project" and select Project2.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With