"Reference required to assembly 'RootLevel' containing the type 'RootLevel.Root'. Add one to your pr

  • Thread starter Thread starter Good Enchiladas
  • Start date Start date
G

Good Enchiladas

While building on a class library for an object model, I get the above error
message.

The steps to recreate the problem are as follows:

1. Build a RootLevel.dll containing only this code:

Public Class Root
End Class

2. Build a SecondLevel.dll containing a reference to RootLevel.dll and only
this code:

Public Class Child
Private _root As RootLevel.Root

Public Property Root() As RootLevel.Root
Get
Return _root
End Get
Set(ByVal value As RootLevel.Root)
_root = value
End Set
End Property
End Class


3. Edit the Root class, add a reference to SecondLevel.dll and Re-build the
RootLevel.dll. The edited code looks like this:

Public Class Root
Private _child1 As SecondLevel.Child 'there will be other children

Public ReadOnly Property Child1() As SecondLevel.Child
Get
If _child1 Is Nothing Then
_child1 = New SecondLevel.Child()
_child1.Root = Me
End If
Return _child1
End Get
End Property
End Class

The reference to 'Me' is marked with the following error by the Visual
Studio.NET IDE:
"Reference required to assembly 'RootLevel' containing the type
'RootLevel.Root'. Add one to your project."


Obviously, this a simplified example, where children are plugged into the
root as needed. The children can be pretty complex and considerably
different from each other. Children need to reference the root, and children
often need to reference each other.

How do I work around this circular compilation reference situation or
whatever is going on here?

Thanks,
Kelly
 
Okay, I'll buy that. What is the workaround? What design change do I need to
make?
 
For Armin,

See my answer above first I did not see there was a reposting.

Cor
 
* "Cor Ligthert said:
See my answer above first I did not see there was a reposting.

I don't see any answer written by you?!
 
I answered an almost the same question about a wrong class name.

There was used root root child, and had to be in my opinion something as
root child rootlevel

Cor
 
* "Cor Ligthert said:
I answered an almost the same question about a wrong class name.

OK, I didn't know that. I only wanted to make sure that my newsreader
doesn't hide part of the thread.
 

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

Back
Top