'How to pass a class instance to library class in Windows Forms

How should I pass a class instance to my class library so that it can access its properties?

I have a class library "classLib"

Public Class libraryClass
    Public Sub New(sent As clsMyClass)
       sent.prop = "changed value"
    End Sub
End Class

I have a console app "myApp" with a module...

Sub Main()
    Dim myClassInstance = New clsMyClass
    Dim classLibInstance As New classLib.libraryClass(myClassInstance)
End Sub

and a class

Public Class clsMyClass
    Property prop As String = "Initial value"
End Class

"Myapp" and "classLib" have clsMyClass, and "myApp" has a reference to "classLib"

The solution fails with the error BC30311 Value of type 'clsMyClass' cannot be converted to 'clsMyClass'

Pressing Alt+Enter for help shows I should add a 'widening operator' to "libraryClass"

Public Shared Widening Operator CType(v As clsMyClass) As clsMyClass
    Throw New NotImplementedException()
End Operator

but this then gives the error message BC33024 Conversion operators cannot convert from a type to the same type.

I'm sure I'm misunderstanding something here - how should I pass the instance so my class library can refer to it properties?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source