D
Dave S
Anyone know how to get round the problem of circular references in VB.NET
(sorry I'm a .NET newbie).
I create one project which has 2 classes in it, MyHandler and MyObject.
MyHandler just needs to call another class in a different project and pass a
parameter of type MyObject to it.
So the class in the different project needs to import the first project
namespace so it know what MyObject is.
The MyHandler class needs to import the second project namespace so it can
call the class in the second project.
This doesn't seem to be allowed in .NET even though Java could easily do
this.
See code below :
(1st project : namespace = MyClass.Test1)
Public Class MyHandler
Public Function DoSomething(ByVal obj As MyObject) As String
Dim a As New [MyClass].Test2.MyAction
Return a.DoMethod(obj)[/QUOTE]
End Function
End Class
Public Class MyObject
Private a, b As String
Public Property attrib1() As String
Get
Return a
End Get
Set(ByVal Value As String)
a = Value
End Set
End Property
Public Property attrib2() As String
Get
Return b
End Get
Set(ByVal Value As String)
b = Value
End Set
End Property
End Class
(2nd project : namespace = MyClass.Test2)
Imports [MyClass].Test1
Public Class MyAction
Public Function DoMethod(ByVal obj As MyObject) As String
Return obj.attrib1
End Function
End Class
The line highlighted in red above fails because according to .NET it doesn't
know what type the value called 'obj' is when it comes to passing it to the
method in the 2nd project.
The error I get is :
H:\Work\testbed\MyClass.Test1\MyHandler.vb(4): Reference required to
assembly 'MyClass.Test1' containing the type 'MyClass.Test1.MyObject'. Add
one to your project.
This seems a really basic piece of functionality and I must be declaring
something incorrectly here
Any ideas ??
(sorry I'm a .NET newbie).
I create one project which has 2 classes in it, MyHandler and MyObject.
MyHandler just needs to call another class in a different project and pass a
parameter of type MyObject to it.
So the class in the different project needs to import the first project
namespace so it know what MyObject is.
The MyHandler class needs to import the second project namespace so it can
call the class in the second project.
This doesn't seem to be allowed in .NET even though Java could easily do
this.
See code below :
(1st project : namespace = MyClass.Test1)
Public Class MyHandler
Public Function DoSomething(ByVal obj As MyObject) As String
Dim a As New [MyClass].Test2.MyAction
Return a.DoMethod(obj)[/QUOTE]
End Function
End Class
Public Class MyObject
Private a, b As String
Public Property attrib1() As String
Get
Return a
End Get
Set(ByVal Value As String)
a = Value
End Set
End Property
Public Property attrib2() As String
Get
Return b
End Get
Set(ByVal Value As String)
b = Value
End Set
End Property
End Class
(2nd project : namespace = MyClass.Test2)
Imports [MyClass].Test1
Public Class MyAction
Public Function DoMethod(ByVal obj As MyObject) As String
Return obj.attrib1
End Function
End Class
The line highlighted in red above fails because according to .NET it doesn't
know what type the value called 'obj' is when it comes to passing it to the
method in the 2nd project.
The error I get is :
H:\Work\testbed\MyClass.Test1\MyHandler.vb(4): Reference required to
assembly 'MyClass.Test1' containing the type 'MyClass.Test1.MyObject'. Add
one to your project.
This seems a really basic piece of functionality and I must be declaring
something incorrectly here
Any ideas ??