473,513 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# and VB.NET code in the same EXE

I am working with a fellow developer on a small project. I started in
VB6, but after her C# training we decided to build the application in
..NET. Rather than rewrite the VB6 code, I continued in VB6 then
converted it to VB.NET using the upgrade wizard, while she started in
C#. The VB.NET project has one windows (UI) form an some intensive
background processing (a report engine) and the C# code has the rest
of the UI which updates an Access Database.

The problem is we thought we could put both projects into VS.NET at
the same time and build a single EXE - but we can't get it working!
The C# project will not pick up the VB.NET form, so when we try and
compile it says it doesn't know what the form is defined as - we have
tried adding a reference and a dependancy, but neither has worked. Is
it possible to build a single Windows EXE using both C# and VB.NET
code? If so, what would the C# code look like that opens the VB.NET
form, and what do we have to do to the C# project to get it to see the
objects defined in the VB.NET form??

If it's not possible, and we have to compile the VB.NET code into a
DLL, will the C# code still be able to open the form from the VB.NET
dll, or will we have to move the windows form into the C# project and
just leave the processing code (no UI) in the VB.NET dll??

Any help would be appreciated!
Nov 15 '05 #1
4 1583

Nathan,

It is possible to have both VB.NET and C# code in the same assembly (EXE or
DLL) but you can't do it with Visual Studio, you have to use the command
line tools.

The easiest thing to do would be to make the VB.NET project into a DLL and
reference it in the C# app. There's no problem having forms or controls in
your DLL, .NET just treats them like any other class.

Hope this helps.

--
Rob Windsor
G6 Consulting
Toronto, Canada
"Nathan" <na******@yahoo.com> wrote in message
news:15**************************@posting.google.c om...
I am working with a fellow developer on a small project. I started in
VB6, but after her C# training we decided to build the application in
.NET. Rather than rewrite the VB6 code, I continued in VB6 then
converted it to VB.NET using the upgrade wizard, while she started in
C#. The VB.NET project has one windows (UI) form an some intensive
background processing (a report engine) and the C# code has the rest
of the UI which updates an Access Database.

The problem is we thought we could put both projects into VS.NET at
the same time and build a single EXE - but we can't get it working!
The C# project will not pick up the VB.NET form, so when we try and
compile it says it doesn't know what the form is defined as - we have
tried adding a reference and a dependancy, but neither has worked. Is
it possible to build a single Windows EXE using both C# and VB.NET
code? If so, what would the C# code look like that opens the VB.NET
form, and what do we have to do to the C# project to get it to see the
objects defined in the VB.NET form??

If it's not possible, and we have to compile the VB.NET code into a
DLL, will the C# code still be able to open the form from the VB.NET
dll, or will we have to move the windows form into the C# project and
just leave the processing code (no UI) in the VB.NET dll??

Any help would be appreciated!

Nov 15 '05 #2
Hi,

Check out this article on Building a Multifile Assembly.
http://msdn.microsoft.com/library/de...leassembly.asp

Regards
Benny

Nathan wrote:
I am working with a fellow developer on a small project. I started in
VB6, but after her C# training we decided to build the application in
.NET. Rather than rewrite the VB6 code, I continued in VB6 then
converted it to VB.NET using the upgrade wizard, while she started in
C#. The VB.NET project has one windows (UI) form an some intensive
background processing (a report engine) and the C# code has the rest
of the UI which updates an Access Database.

The problem is we thought we could put both projects into VS.NET at
the same time and build a single EXE - but we can't get it working!
The C# project will not pick up the VB.NET form, so when we try and
compile it says it doesn't know what the form is defined as - we have
tried adding a reference and a dependancy, but neither has worked. Is
it possible to build a single Windows EXE using both C# and VB.NET
code? If so, what would the C# code look like that opens the VB.NET
form, and what do we have to do to the C# project to get it to see the
objects defined in the VB.NET form??

If it's not possible, and we have to compile the VB.NET code into a
DLL, will the C# code still be able to open the form from the VB.NET
dll, or will we have to move the windows form into the C# project and
just leave the processing code (no UI) in the VB.NET dll??

Any help would be appreciated!


Nov 15 '05 #3
In short that may be the answer you are looking for. However, the longer
answer is that multifile assemblies don't really solve the common problem,
and that is shipping a single physical file that contains VB and C# code.
Using a multifile assembly you'll end up with a C# module file, a VB module
file, and an assembly that references both of these. All three files are
required to run the program. If you managed to instead create a VB library
assembly and simply reference that in your C# application, you'd only have
to ship two files.

There are obviously reasons for multifile assemblies, but until they make it
possible to merge all of the information into a single physical assembly, it
probably won't be much help.
--
Justin Rogers
DigiTec Web Consultants, LLC.

"Benny Mathew" <be***@mvps.org> wrote in message
news:O1**************@TK2MSFTNGP11.phx.gbl...
Hi,

Check out this article on Building a Multifile Assembly.
http://msdn.microsoft.com/library/de...leassembly.asp
Regards
Benny

Nathan wrote:
I am working with a fellow developer on a small project. I started in
VB6, but after her C# training we decided to build the application in
.NET. Rather than rewrite the VB6 code, I continued in VB6 then
converted it to VB.NET using the upgrade wizard, while she started in
C#. The VB.NET project has one windows (UI) form an some intensive
background processing (a report engine) and the C# code has the rest
of the UI which updates an Access Database.

The problem is we thought we could put both projects into VS.NET at
the same time and build a single EXE - but we can't get it working!
The C# project will not pick up the VB.NET form, so when we try and
compile it says it doesn't know what the form is defined as - we have
tried adding a reference and a dependancy, but neither has worked. Is
it possible to build a single Windows EXE using both C# and VB.NET
code? If so, what would the C# code look like that opens the VB.NET
form, and what do we have to do to the C# project to get it to see the
objects defined in the VB.NET form??

If it's not possible, and we have to compile the VB.NET code into a
DLL, will the C# code still be able to open the form from the VB.NET
dll, or will we have to move the windows form into the C# project and
just leave the processing code (no UI) in the VB.NET dll??

Any help would be appreciated!

Nov 15 '05 #4
"Nathan" <na******@yahoo.com> wrote in message
news:15**************************@posting.google.c om...
I agree that while the
multi-file assembly will work, the easiest way around our problem will
be to recode the VB.NET form into the C# project and have the UI in a
single project,


One thing I found, when moving a VB.NET form to a C# form is to use the
designer. I created a blank form in C#, setup the properties (size, etc.)
to be identical to the VB form. Then, with both forms open in the designer,
just start selecting, copying and pasting the controls from VB over the C#.
This saved me about half of the typing (since it got all the placement,
properties, etc of the controls). For example, copying and pasting the
TabControl brought 5 tab-pages with probably 50 or so controls.

Then you just have to port over the event handlers (button click, etc) which
are hopefully pretty dumb little functions...

Good luck!

--
Mike Mayer
http://www.mag37.com/csharp/
mi**@mag37.com

Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

51
5204
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
3847
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
2416
by: jason | last post by:
Hello. Newbie on SQL and suffering through this. I have two tables created as such: drop table table1; go drop table table2; go
16
3085
by: Dario de Judicibus | last post by:
I'm getting crazy. Look at this code: #include <string.h> #include <stdio.h> #include <iostream.h> using namespace std ; char ini_code = {0xFF, 0xFE} ; char line_sep = {0x20, 0x28} ;
109
5748
by: Andrew Thompson | last post by:
It seems most people get there JS off web sites, which is entirely logical. But it is also a great pity since most of that code is of such poor quality. I was looking through the JS FAQ for any...
5
4036
by: ED | last post by:
I currently have vba code that ranks employees based on their average job time ordered by their region, zone, and job code. I currently have vba code that will cycle through a query and ranks each...
0
2079
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
18
3138
by: Joe Fallon | last post by:
I have some complex logic which is fairly simply to build up into a string. I needed a way to Eval this string and return a Boolean result. This code works fine to achieve that goal. My...
37
5917
by: Alan Silver | last post by:
Hello, Newbie here, so please forgive what is probably a basic question ... I see a lot of discussion about "code behind", which if I have understood correctly, means that the script code goes...
171
7596
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
0
7265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.