|
-
October 20th, 2006, 09:15 AM
#1
Inheriting Classes from another VB.NET project(s)
Hi experts
I am VERY new to DOTNET so pardon my knowledge.
Can we inherit classes from other VB Projects in DOTNET?
Because I have a VB DOT NET Source Code Project and I need to implement its standard Interfaces and Inherit some classes in my new VB project.
I dont want to make DLL of that API project and refrrering it in my project to make its COM like objects for the reason that I think that way I wont be able to use its Interfaces [If I am Correct?] Hence the question.
I use VS-DOTNET 2005.
V.V.Sankhe
-
October 20th, 2006, 09:14 PM
#2
Re: Inheriting Classes from another VB.NET project(s)
Yes, you can... but you either have to compile everything in to one assembly, or you need to compile it in to a separate assembly and reference it.
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
-
October 21st, 2006, 02:42 PM
#3
Re: Inheriting Classes from another VB.NET project(s)
 Originally Posted by Craig Gemmill
Yes, you can... but you either have to compile everything in to one assembly, or you need to compile it in to a separate assembly and reference it.
Thx Craig. But I have already done that
Which reference r u talking about?
I had a project Vehicle with a VB class Vehicle (that has 2 functions defined in it).
I have another project Car that has VB class Car that Inherits Vehicle and its 2 functions.
Vehicle directory and Car directory exist diferently on the hard disks.
Now in Car project I add Vehicle Project to make a Parent Assembly Car. Thus this parent assembly has 2 projects Car and Vehicle each showing their respective classes. But still in my Car project's Car class I see
Class Car
Inherits Vehicle
showing Vehicle as Unknown Identifier.
Parent Assembly Car when right clicked and chosen properties, properly shows Vehicle as the referenced project.
Oh and BTW Vehcile was successfully build for its DLL. So now we have 2 options. Either Vehicle project Or vehicle Dll. My problem is I have to INHERIT Vehicle Class in Car.
Thx.
Last edited by vinitsankhe; October 21st, 2006 at 03:02 PM.
V.V.Sankhe
-
October 21st, 2006, 03:08 PM
#4
Re: Inheriting Classes from another VB.NET project(s)
Sounds like you need to use the correct namespace to reference VEHICLE. So instead of doing this:
Inherits Vehicle
You might have to use:
Inherits Project2.Vehicle
Where Project2 is the name of the project/library that contains the VEHICLE definition.
Open the Object Browser in Visual Studio. It will show you all the relationships among objects.
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
-
October 23rd, 2006, 10:08 AM
#5
-
October 24th, 2006, 12:02 AM
#6
Re: Inheriting Classes from another VB.NET project(s)
Ok, in your Car project references: Add a reference to the PROJECT Vehicle. Then your Car code should look like this:
Code:
Public Class Car
Inherits Vehicle.Vehicle
Public Overrides Sub ApplyBreaks()
End Sub
End Class
I know it works, so keep trying until you get it.
Good Luck,
Craig - CRG IT Solutions - Microsoft Gold Partner
-My posts after 08/2015 = .NET 4.x and Visual Studio 2015
-My posts after 11/2011 = .NET 4.x and Visual Studio 2012
-My posts after 02/2010 = .NET 4.0 and Visual Studio 2010
-My posts after 12/2007 = .NET 3.5 and Visual Studio 2008
-My posts after 04/2007 = .NET 3.0 and Visual Studio 2005
-My posts before 04/2007 = .NET 1.1/2.0
*I do not follow all threads, so if you have a secondary question, message me.
-
October 24th, 2006, 09:28 AM
#7
Re: Inheriting Classes from another VB.NET project(s)
Oh my god!
I have been going thru the same UIs for a week now, but never tried adding PROJECT Vehicle reference into generic references of Car.
I would access the projects tab of Car Add Refernce window and would always see vehicle shown there. thus thinking that Vehicle is already referred. But never tried referencing Vehicle explicitly to the Car project's generic refernces.
That was a relief!
Thx Craig
V.V.Sankhe
-
October 24th, 2006, 10:27 AM
#8
Re: Inheriting Classes from another VB.NET project(s)
I just want to add that naming a class in the same name as the namespace is a very bad idea, and can causeyou problems in the future.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|