Why adding external dll in class library expected to be added in calling project?

33 Views Asked by At

I have to call an external .Net Framework assembly that required to be consumed in different projects (Console, Desktop and Web Applications). In order to avoid adding external assembly, I have created a class library project and wrap external assembly calls in an Friend class and called that class from a public class that is exposed to outside world. But When I run my project, it expect dll to be included in Console application as well.

I was expecting that friend classes are not accessible to outside world, so assemblies consumed are not required to outside world. But as soon as I inherit my friend class from an outside assembly, Console application call of MyCalling.UserLogin blows up. I also tried making Friend class Private that does not work as well.

Public Class MyCaller
    Public Shared Function UserLogin(ByVal username As String, ByVal password As String) As Boolean
        Return MyFunctions.Instance.UserLogin(username, password)
    End Function
End Class

Imports ExternalLibrary

Friend Class MyFunctions
        Inherits ExternalClass

        Private Shared instanceField As MyFunctions = Nothing
        Friend Shared ReadOnly Property Instance As MyFunctions
            Get
                If instanceField Is Nothing Then
                    instanceField = New MyFunctions()
                End If
                Return instanceField
            End Get
        End Property

        Public Function UserLogin(ByVal username As String, ByVal password As String) As Boolean
            Return False
        End Function
End Class

I try to avoid adding external assemblies to multiple projects, and expect my code to not expect the assembly that's references in a friend class, but everytime I run the project it blows-up

0

There are 0 best solutions below