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 805545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:05:50+00:00 2026-05-15T00:05:50+00:00

In my most recent question: Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for

  • 0

In my most recent question: Unit Testing Best Practice? / C# InternalsVisibleTo() attribute for VBNET 2.0 while testing?, I was asking about InternalsVisibleToAttribute.

I have read the documentation on how to use it, and everything is fine and understood. However, I can’t instantiate my class Groupe from my Testing project.

I want to be able to instantiate my internal class in my wrapper assembly, from my testing assembly.

Any help is appreciated!

EDIT #1

Here’s the compile-time error I get when I do try to instantiate my type:

Erreur 2 ‘Carra.Exemples.Blocs.ActiveDirectory.Groupe’ n’est pas accessible dans ce contexte, car il est ‘Private’. C:\Open\Projects\Exemples\Src\Carra.Exemples.Blocs.ActiveDirectory\Carra.Exemples.Blocs.ActiveDirectory.Tests\GroupeTests.vb 9 18 Carra.Exemples.Blocs.ActiveDirectory.Tests

(This says that my type is not accessible in this context, because it is private.) But it’s Friend (internal)!

EDIT #2

Here’s a piece of code as suggested for the Groupe class implementing the Public interface IGroupe:

#Region "Importations"
Imports System.DirectoryServices
Imports System.Runtime.CompilerServices
#End Region

<Assembly: InternalsVisibleTo("Carra.Exemples.Blocs.ActiveDirectory.Tests")> 

Friend Class Groupe
    Implements IGroupe

#Region "Membres privés"
    Private _classe As String = "group"
    Private _domaine As String
    Private _membres As CustomSet(Of IUtilisateur)
    Private _groupeNatif As DirectoryEntry
#End Region

#Region "Constructeurs"
    Friend Sub New()
        _membres = New CustomSet(Of IUtilisateur)()
        _groupeNatif = New DirectoryEntry()
    End Sub

    Friend Sub New(ByVal domaine As String)
        If (String.IsNullOrEmpty(domaine)) Then Throw New ArgumentNullException()
        _domaine = domaine
        _membres = New CustomSet(Of IUtilisateur)()
        _groupeNatif = New DirectoryEntry(domaine)
    End Sub

    Friend Sub New(ByVal groupeNatif As DirectoryEntry)
        _groupeNatif = groupeNatif
        _domaine = _groupeNatif.Path
        _membres = New CustomSet(Of IUtilisateur)()
    End Sub
#End Region

And the code trying to use it:

#Region "Importations"
Imports NUnit.Framework

Imports Carra.Exemples.Blocs.ActiveDirectory
#End Region

<TestFixture()> _
Public Class GroupeTests
    <Test()> _
    Public Sub CreerDefaut()
        Dim g As Groupe = New Groupe()
        Assert.IsNotNull(g)
        Assert.IsInstanceOf(Groupe, g)
    End Sub
End Class

EDIT #3

Damn! I have just noticed that I wasn’t importing the assembly in my importation region.

Nope, didn’t solve anything =(

Thanks!

  • 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-15T00:05:51+00:00Added an answer on May 15, 2026 at 12:05 am

    After researching and researching, still researching and guess what? Researchain again, I have found a link where it is said that ‘InternalsVisibleTo’ was not available for VB.NET, thought the attribute was available in .NET 2.0. Here’s the link in question:

    InternalsVisibleTo: Testing internal methods in .Net 2.0

    The Remark states:

    In the .NET Framework version 2.0, Visual Basic does not support the use of this attribute.

    So it is not available, that’s all! =)

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

Sidebar

Ask A Question

Stats

  • Questions 417k
  • Answers 417k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You will still need to convert to unixtime, but ArrayOfStructsSort… May 15, 2026 at 9:49 am
  • Editorial Team
    Editorial Team added an answer You can try using the Solution Load Manager. It'll let… May 15, 2026 at 9:49 am
  • Editorial Team
    Editorial Team added an answer You could use selenium and automate navigating to all those… May 15, 2026 at 9:49 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.