Creating a C# class Inherited from VB.Net

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
 
P

Patrik Löwendahl

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.
 
E

Ed Courtenay

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.
 
J

Jon Skeet [C# MVP]

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).
 
M

Mark Broadbent

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
=============
 
A

Ashish Sheth

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
 

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