Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1095285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:06:00+00:00 2026-05-17T00:06:00+00:00

I have a solution with two projects within: Company.Project.vbproj Company.Project.Tests.vbproj Within the Company.Project.vbproj assembly,

  • 0

I have a solution with two projects within:

Company.Project.vbproj
Company.Project.Tests.vbproj

Within the Company.Project.vbproj assembly, I have a class FriendClass.vb which scope is Friend (internal in C#).

Now I wish to test this FriendClass.vb from within the Company.Project.Tests.vbproj assembly. I know about the InternalsVisibleToAttribute, but that is not an option in Visual Basic .NET 2.0, as it is only available with C#, in .NET 2.0 (see here).

I would like to create myself a proxy class using this internal FriendClass from within my testing assembly, so that I could instantiate it and do the testings accordingly.

Any idea or known practices to do so?

Thanks in advance! =)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:06:01+00:00Added an answer on May 17, 2026 at 12:06 am

    The only workaround that I have found is one used back in .NET Framework 1.1.

    As the InternalsVisibleToAttribute is not useable in .NET 2.0 Visual Basic, the only workaround that I have found is to include my tests within the same project as my library itself. Besides, some further work needs to be accomplished.

    1. Create yourself a new compilation CONFIG called “Tests” (that is where you may select “Release”/”Debug”);
    2. Create a new folder named “Tests” within your project;
    3. Add a new class, the one to test your Friend (internal in C#) members;
    4. First line of code within this class should be: #if CONFIG = "Tests" then ... #end if;
    5. Place your code between this compiler IF directive.

    For example, if I have the following Friend class:

    Friend Class MyFactory
        Friend Property Property1 As Object
            Get
                Return _field1
            End Get
            Set (ByVal value As Object)
                _field1 = value
            End Set
        End Property
    
        Friend Sub SomeSub(ByVal param1 As Object)
            ' Processing here...
        End Sub
    End Class
    

    Then, if you want to test this class in .NET 2.0 Visual Basic, you will need to create a test class within the same project where the MyFactory class sits. This class should look like so:

    #If CONFIG = "Tests" Then
    
        Imports NUnit.Framework
    
        <TestFixture()> _
        Public Class MyFactoryTests
            <Test()> _
            Public Sub SettingProperty1Test
                ' Doing test here...
            End Sub
        End Class
    
    #End If
    

    Since you have a compiler directive telling the compiler to compile and to include this class only when the “Tests” CONFIG is selected, you won’t get this class on “Debug” or on “Release” mode. This class won’t even be part of the library, this for not polluting your library unnecessarily, and this allows you to test your Friend class anyway.

    That is the smartest way I have found to work around this issue in Visual Basic .NET 2.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an solution in VS 2008 which contains two class library projects and
I have a solution with two projects. One for project for the production code
In Visual C# 2008, I have a solution with two projects. First project contains
I have a solution that contains two projects. One project is an ASP.NET Web
I have a Visual Studio 2008 solution with two projects (a Word-Template project and
I have two projects in my solution   1- asp.net web project.   2-
I have two projects in my solution... a domain project and MVC3 web project
I have a VS 2011 solution file with two projects, each is a project
I have a rather large solution, which contains two documentation projects based on Sandcastle
I have two projects in my solution, an MVC 3 (UI) project and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.