473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 20 '05 #1
4 6302

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 20 '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 20 '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 20 '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 20 '05 #5

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

Similar topics

51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
9
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.