Including a C# class in VB project

C

Craig Kenisston

Hi,

I'm creating a VB Windows Application project that needs to call some
classes already written in C#.
I can create a class library (dll) and include them as reference in my
project, that works ok.

But I was thinking, could I add directly add the CS files in the VB project
and have access to the class ?

I already did it, but it seems not to work.
If I put "Imports MyCSnamespace" it does not find "MyCSnamespace".
If I delete it, than my reference to the CS classes are invalid in the body
of the VB project.

So, is it possible ?

Regards,
 
K

Kevin Thomas

Currently not possible.

I have read that in the next version of Visual Studio this will be allowed.

Kevin
 
C

Craig Kenisston

Hi,

Thanks for the comment.
I was digging in the help file and just found something called "multifile
assemblies". It seems this is to help to create a DLL combined by different
languages.
May I misunderstood.
Still reading .....

Regards,
 
K

Kevin Thomas

Hey if you read that it can be done, point me to that article. That'd be
pretty cool.

Thanks,

Kevin
 
J

Jeff Johnson [MVP: VB]

I was digging in the help file and just found something called "multifile
assemblies". It seems this is to help to create a DLL combined by different
languages.
May I misunderstood.
Still reading .....

I believe you create the individual pieces as modules ("netmodules") and
then link them together. I'm not sure if Visual Studio can do this or if you
have to use command-line tools.
 
T

Tom Shelton

Hey if you read that it can be done, point me to that article. That'd be
pretty cool.

Thanks,

Kevin

It can be done - just not from the IDE. You can compile your file to a
module (*.netmodule) and then use the assembly linker tool (al.exe) to
create a multifile assembly. You just have to do all your builds from
the command line and it takes more then one step. Of course, you could
create a script to handle it :)
 

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