Project reference problem

D

Dominic Rousseau

Hi!

According the code below (2 class library projets):

'Project 1: ns1.Class1
Public Class Class1
Public Sub New()
Dim cls2 As New ns2.Class2
cls2.method1(Me) 'THE ERROR OCCURS HERE (on Me keyword)...
cls2 = Nothing
End Sub
End Class

'Project 2: ns2.Class2
Public Class Class2
Public Sub method1(ByVal cls1 As ns1.Class1)
'do something here...
End Sub
End Class

I get de following precompiler error:
Reference required to assembly 'class1' containing the type
'ns1.Class1'. Add one to your project.

I read similar posts on other groups but no one suggested a solution
that worked for me...
Thanks.
Dom
 
C

CJ Taylor

Um, silly question, but you DID Add a refernce from class one to class 2
right? Go to your class1 project, Add Reference, go to the Projects Tab,
you will see class 2..

add that.

-CJ
 
D

Drou

Excuse me CJ, I forgot to mention that my references are corrects. My
Class1 references Class2... It seams like 'Me' is not recognized as the
type required by 'method1' (read the error message correctly). Any other
ideas ?

Thanks for you help CJ!
Dom
 
A

Armin Zingler

Dominic Rousseau said:
'Project 1: ns1.Class1
Public Class Class1
Public Sub New()
Dim cls2 As New ns2.Class2
cls2.method1(Me) 'THE ERROR OCCURS HERE (on Me keyword)...
cls2 = Nothing
End Sub
End Class

'Project 2: ns2.Class2
Public Class Class2
Public Sub method1(ByVal cls1 As ns1.Class1)
'do something here...
End Sub
End Class

You're trying to make circular references between projects. This is not
possible.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
C

CJ Taylor

ahhh

you can't.

it would create a circular reference between the projects...

Class 1 Requires class 2

class 2 requires class 1

try to create a reference to class1 from class2, should say some kind of
error... if not, then that should work. =)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top