Mixing languages in one assembly

B

BK

I have a .NET project named FormattedOuput with output type set to
Class Library. In it, I have a source file named ExcelOutput.Vb. This
class produces an Excel object and manipulates it based on some input I
provide. It works fine and has been fully tested.

Meanwhile, another programmer was writing a source file named
RTFOutput.Cs, a C Sharpt program that does similiar work for RTF file
output. He has fully tested his source and it works as we need it.

I *thought* that all I would need to do is add his Cs file to my
project, recompile, and life would be grand. However, intellisense
only shows me the Vb class. So while FormattedOutput.ExcelOutput is
valid, FormattedOutput.RTFOutput is not. We've mixed and matched
different source files in this Solution before, but never mixed
languages in the same assembly. Can this be done?
 
T

Tom Shelton

BK said:
I have a .NET project named FormattedOuput with output type set to
Class Library. In it, I have a source file named ExcelOutput.Vb. This
class produces an Excel object and manipulates it based on some input I
provide. It works fine and has been fully tested.

Meanwhile, another programmer was writing a source file named
RTFOutput.Cs, a C Sharpt program that does similiar work for RTF file
output. He has fully tested his source and it works as we need it.

I *thought* that all I would need to do is add his Cs file to my
project, recompile, and life would be grand. However, intellisense
only shows me the Vb class. So while FormattedOutput.ExcelOutput is
valid, FormattedOutput.RTFOutput is not. We've mixed and matched
different source files in this Solution before, but never mixed
languages in the same assembly. Can this be done?

It can be... It just takes manual intervention (I think VS2005 can
handle this - but, I haven't tried it there so I'm not positive). In
other words, you will have to compile and link the code using the
commandline compiler/linker programs.

It would probably be easier to put the C# code in it's own dll and then
reference it from your VB project....
 
P

Patrice

AFAIK :
- you can't mix languages inside the same project.
- if I remember this is a VS.NET limitation. A workaround could be to
compile (using the command line compiler) one of the file to a "module"
(doesn't have anything to do with vb modules, see this rather as a .LIB
file) and then you could be able to compile (wiht the command line compiler)
the other file adding the previous "module"

I actually tried to find this in the doc and saw :
http://msdn.microsoft.com/library/d...rfTargetmoduleCreateModuleToAddToAssembly.asp

Please let us know (never tried, would like to know if it works).
 
M

Mythran

BK said:
I have a .NET project named FormattedOuput with output type set to
Class Library. In it, I have a source file named ExcelOutput.Vb. This
class produces an Excel object and manipulates it based on some input I
provide. It works fine and has been fully tested.

Meanwhile, another programmer was writing a source file named
RTFOutput.Cs, a C Sharpt program that does similiar work for RTF file
output. He has fully tested his source and it works as we need it.

I *thought* that all I would need to do is add his Cs file to my
project, recompile, and life would be grand. However, intellisense
only shows me the Vb class. So while FormattedOutput.ExcelOutput is
valid, FormattedOutput.RTFOutput is not. We've mixed and matched
different source files in this Solution before, but never mixed
languages in the same assembly. Can this be done?

No. One assembly, one language. You will either have to convert to a
single language or create two different projects.

Mythran
 
C

Carlos J. Quintero [VB MVP]

Not using the VS IDE, you need to do it by hand using the SDK command-line
compilers / linkers.

You can only mix languages in the same project using the IDE when doing VS
2005 web projects.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
 
M

Mythran

Mythran said:
No. One assembly, one language. You will either have to convert to a
single language or create two different projects.

Mythran

I stand corrected.

Mythran
 
B

BK

What I'm seeing from my research, it can be done but it must be done
from command line calls. It's not the end of the world if I can't do
it, I'll probably just rewrite my part in C# as an excercise. This
other developer and I get along real well here and commonly split
things up. He prefers C#, I prefer Vb. Thanks for all the replies!

Bill
 
T

Tom Shelton

BK said:
What I'm seeing from my research, it can be done but it must be done
from command line calls. It's not the end of the world if I can't do
it, I'll probably just rewrite my part in C# as an excercise. This
other developer and I get along real well here and commonly split
things up. He prefers C#, I prefer Vb. Thanks for all the replies!

Bill

You can still share your code without duplicating effort... Just write
them in class libraries/user controls and distribute the dll's. You
can have different projects in the same solution that use different
languages - the problems arise when you want to use different languages
in the same project.
 

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