Creating a C# class Inherited from VB.Net

  • Thread starter Thread starter Steven Blair
  • Start date Start date
S

Steven Blair

Hi,

I have a VB.NET class which I would like to use in a C# application. I
know I can create a C# class inherited from the VB.NET, but have only
done this using seperate DLL's (One DLL for VB, one dll for C#)

Is it possible to do this within one project ( C# App and no DLL's used)

Any help on this would be appreciated

Regards,

Steven
 
Hi Steven,

This is not possible in visual studio.net

Mainly because every project file is bound to a specific compiler, but
there's also other reasons.

If you want to interact between C# and VB.NET, the classes have to be in
separate vs.net projects.
 
Steven said:
Hi,

I have a VB.NET class which I would like to use in a C# application. I
know I can create a C# class inherited from the VB.NET, but have only
done this using seperate DLL's (One DLL for VB, one dll for C#)

Is it possible to do this within one project ( C# App and no DLL's used)

No, you cannot mix languages in the same project in VS.NET 2002/2003. I
have seen reports that VS.NET 2005 will allow this, but don't have any
cites at the moment.

Unfortunately, this does mean that you need to use separate DLLs for the
time being.
 
Steven Blair said:
I have a VB.NET class which I would like to use in a C# application. I
know I can create a C# class inherited from the VB.NET, but have only
done this using seperate DLL's (One DLL for VB, one dll for C#)

Is it possible to do this within one project ( C# App and no DLL's used)

No. VS.NET doesn't allow multimodule assemblies, and even if it did, I
don't think the results would be what you wanted (there would be
..netmodule files).
 
just to add to the above responses (just in case you are not already aware),
once you have referenced the vb .dll, its classes can be used without having
to inherit them first into a C# class; in otherwords you can instanciate an
object directly from that dll as you would any other C# class.
You probably already knew that, but just wanted to make sure.

--


Br,
Mark Broadbent
mcdba , mcse+i
=============
 
You may create .netmodule for your vb.NET class and use that .netmodule in
the C# class. This way both your VB.NET class and C# class will be in one
dll(or in one project). Yes, but you will have separate file that will
contain VB.NET class and C# class. You can create .netmodule by using the
following statement( i don't remember exactly, so check the .NET
documentation)

vbc /t:module FileName.vb

regards,
Ashish
 
Back
Top