Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / April 2004

Tip: Looking for answers? Try searching our database.

Build error for VB.NET but not C#

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Good Enchiladas - 22 Apr 2004 00:29 GMT
While building on a class library for an  VB.NET object model, I get
something similar to the above error message, but not with C#.

The steps to recreate the problem are as follows:

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

using System;
namespace RootLevel {
   public class Root {
   }
}

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

using System;
namespace SecondLevel {
   public class Child {
       private RootLevel.Root _root;
       public RootLevel.Root Root {
           get {
               return _root;
           }
           set {
               _root = value;
          }
       }
   }
}

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

using System;
namespace RootLevel {
   public class Root {
       private SecondLevel.Child _child1; //there will be other children
       public SecondLevel.Child Child1 {
           get {
               if (_child1 == null) {
                   _child1 = new SecondLevel.Child();
                   _child1.Root = this;
               }
               return _child1;
           }
       }
   }
}

And it builds without an error. Unfortunately, using VB.NET, it doesn't.

1.

Public Class Root
End Class

2.

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

3.

Public Class Root
   Private _child1 As SecondLevelVB.Child 'there will be other children
   Public ReadOnly Property Child1() As SecondLevelVB.Child
       Get
           If _child1 Is Nothing Then
               _child1 = New SecondLevelVB.Child
               _child1.Root = Me
           End If
           Return _child1
       End Get
   End Property
End Class

I believe my conversion from VB.NET to C# is 100% equivalent.

The reference to 'Me' in VB.NET step 3 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 can I fix the VB.NET situation. Is this a VB.NET compiler bug or a
default C# setting that differs? How do I work around this circular
compilation reference situation or whatever is going on here?

Thanks,
Kelly
Robert Gruen [MSFT] - 26 Apr 2004 16:11 GMT
Kelly,

This is most likely occurring since VB projects already have a namespace
associated with them.  If you check the project properties for the VB
project you'll see that the Root Namespace for your project has a value
(i.e. ClassLibrary1) so when you place the namespace directive within your
VB code the fully qualified name for your class is
ClassLibrary1.MyNamespaceName.MyClass.  Try setting the root namespace
value for the project properties to nothing (i.e. "").

Thanks!  Robert Gruen
Microsoft, VB.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
--------------------
#Reply-To: "Good Enchiladas" <goodenchiladas@hotmail.com>
#From: "Good Enchiladas" <goodenchiladas@hotmail.com>
#Newsgroups: microsoft.public.dotnet.framework.sdk
#Subject: Build error for VB.NET but not C#
#Lines: 107
#X-Priority: 3
#X-MSMail-Priority: Normal
#X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
#X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
#Message-ID: <8tDhc.50744$B%4.3526@fe2.columbus.rr.com>
#Date: Wed, 21 Apr 2004 23:29:08 GMT
#NNTP-Posting-Host: 24.166.248.48
#X-Complaints-To: abuse@rr.com
#X-Trace: fe2.columbus.rr.com 1082590148 24.166.248.48 (Wed, 21 Apr 2004
19:29:08 EDT)
#NNTP-Posting-Date: Wed, 21 Apr 2004 19:29:08 EDT
#Organization: Road Runner High Speed Online http://www.rr.com
#Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.s
ul.t-online.de!t-online.de!border2.nntp.ash.giganews.com!nntp.giganews.com!f
eed2.newsreader.com!newsreader.com!newshosting.com!nx02.iad01.newshosting.co
m!news-feed01.roc.ny.frontiernet.net!nntp.frontiernet.net!peer02.cox.net!cox
.net!news-server.columbus.rr.com!fe2.columbus.rr.com.POSTED!not-for-mail
#Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.sdk:9065
#X-Tomcat-NG: microsoft.public.dotnet.framework.sdk
#
#While building on a class library for an  VB.NET object model, I get
#something similar to the above error message, but not with C#.
#
#The steps to recreate the problem are as follows:
#
#1. Build a RootLevel.dll containing only this code:
#
#using System;
#namespace RootLevel {
#    public class Root {
#    }
#}
#
#2. Build a SecondLevel.dll containing a reference to RootLevel.dll and only
#this code:
#
#using System;
#namespace SecondLevel {
#    public class Child {
#        private RootLevel.Root _root;
#        public RootLevel.Root Root {
#            get {
#                return _root;
#            }
#            set {
#                _root = value;
#           }
#        }
#    }
#}
#
#3. Edit the Root class, add a reference to SecondLevel.dll and Re-build the
#RootLevel.dll. The edited code looks like this:
#
#using System;
#namespace RootLevel {
#    public class Root {
#        private SecondLevel.Child _child1; //there will be other children
#        public SecondLevel.Child Child1 {
#            get {
#                if (_child1 == null) {
#                    _child1 = new SecondLevel.Child();
#                    _child1.Root = this;
#                }
#                return _child1;
#            }
#        }
#    }
#}
#
#And it builds without an error. Unfortunately, using VB.NET, it doesn't.
#
#1.
#
#Public Class Root
#End Class
#
#2.
#
#Public Class Child
#    Private _root As RootLevelVB.Root
#    Public Property Root() As RootLevelVB.Root
#        Get
#            Return _root
#        End Get
#        Set(ByVal value As RootLevelVB.Root)
#            _root = value
#        End Set
#    End Property
#End Class
#
#3.
#
#Public Class Root
#    Private _child1 As SecondLevelVB.Child 'there will be other children
#    Public ReadOnly Property Child1() As SecondLevelVB.Child
#        Get
#            If _child1 Is Nothing Then
#                _child1 = New SecondLevelVB.Child
#                _child1.Root = Me
#            End If
#            Return _child1
#        End Get
#    End Property
#End Class
#
#I believe my conversion from VB.NET to C# is 100% equivalent.
#
#The reference to 'Me' in VB.NET step 3 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 can I fix the VB.NET situation. Is this a VB.NET compiler bug or a
#default C# setting that differs? How do I work around this circular
#compilation reference situation or whatever is going on here?
#
#Thanks,
#Kelly
#
#
#

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.