?
Solved

Merging C# and VB.NET projects

Posted on 2005-05-10
12
Medium Priority
?
342 Views
Last Modified: 2012-05-05
Hi experts,

I have two Windows app projects, one written in C# and another written in VB.NET. Is it possible to combine these 2 projects?

I know we can add multiple projects under the same solution but what I want to do is really calling forms in C# project from VB project. If it's possible, may I know how to do it? Using DLL?

Thanks!
0
Comment
Question by:yeewee64
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 23

Assisted Solution

by:b1xml2
b1xml2 earned 600 total points
ID: 13967119
Create a blank solution.

Add both projects to the solution.

Add the c# project reference to the VB project

Now you can instantiate the forms in c# from vb.net
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13967221
You cannot have VB code in a C# project until 2005 (or 2006?) version of .NET.

Bob
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13967326
that is obvious Bob,

but you can instantiate forms written in c# in the vb.net project using vb.net syntax
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 13967344
Sometimes, though, you gotta state the obvious, because it is not always so obvious to everyone.  :)

Bob
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13967431
that, I must give you, is so true!
0
 
LVL 4

Expert Comment

by:nachiket
ID: 13973100
well one more thing, it has to follow CLS standards to call VB.NET object from C# and vice versa!!
0
 

Author Comment

by:yeewee64
ID: 13974584
Hi guys, thanks for your prompt reply.

BTW, b1xml2, I tried to follow your instructions but I don't know how to do this step "Add the c# project reference to the VB project". I tried to bring up the "Add Reference" dialog in the VB project, and then clicked the "Project" tab, from there I selected the C# project. When I clicked OK, I was given an error message saying "A reference to ... could not be added. An assembly must have a 'dll' extension in order to be referenced".

Did I add reference the right way?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 200 total points
ID: 13976839
Now, we are getting into a sticky situation :)  What do the two projects do?  Would a redesign be better?  Are they large, gonzo projects?  Could one of the projects be changed to a DLL project?

Bob
0
 

Author Comment

by:yeewee64
ID: 13984558
OK, I've done a simple test, create a form in C# class library project and then instantiate the form from another VB project, it works.

So is this the way you guys are referring to? Or did I understand wrongly?

Somehow I got the impression that VB and C# can work together pretty well so I thought they could be integrated without using DLL. :)

Anyway, converting the C# project to VB or vice versa is not a huge task, I'm just trying to avoid rewriting codes.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 13985159
Until I can figure out how to make a project reference to an EXE, I think that the only way that you are going to get this to work is to convert one of the projects to a DLL and go from there.

Bob
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 13985362
only dlls would work, You could in any .NET project load an exe but you then have to pass in external args... not the same of course as referencing an assembly
0
 

Author Comment

by:yeewee64
ID: 13986506
OK, thanks guys for all your comment.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Integration Management Part 2
There may be issues when you are trying to access Outlook or send & receive emails or due to Outlook crash which leads to corrupt or damaged PST file. To eliminate the corruption from your PST file, you need to repair the corrupt Outlook PST file. U…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question