VB.Net- C# integration

  • Thread starter Thread starter Madhuri Mittal
  • Start date Start date
M

Madhuri Mittal

I have a ASP.net application written in VB.Net which is
the main application. I have another ASP.net application
written in C#. I want to integrate the C# project files
into the VB.net project ( without having to convert C#
code to VB.net ) . The C# project contains few aspx pages
and couple of C# utility classes.

What would be the best way to integrate the C# files into
VB.net project and run these successfully within the
ASP.net app?

Thanks

Madhuri Mittal
 
You cannot mix different languages into a project. You can put all C# (or
vb) - classes in a .dll project, and add a reference from the vb (or c#)
project to the .dll project

GP
 
Not true -- you can incorporate a C# webform into a VB project -- I have an
idiot ex-contractor who did that here. Let me first say that I STRONGLY DO
NOT RECOMMEND doing this. What will happen is the IDE will have ABSOLUTELY
NO IDEA what any of the objects are.

If you still want to do it, you can just add the C# webform into the VB
project. You put the entire contents of the .cs class file into the HTML
source of the webform first and say <script language = "c#" runat =
"server"> Then after you close script, the normal HTML code exists.

Again, NOT A GOOD IDEA -- you will not be able to edit anything at all
unless you do it text. Basically this is no better than writing a webform
in Notepad.

I would recommend you look into either coding standard in one language,
investigate some C# to VB.net (or vise versa) code converters, or look into
how web references work.

Bob J.
 
Ok, in what you are saying, the vs.net doesn't compile that script when it
compiles the project. The C# compiler will compile that when the page is
requested.

So the post was correct, in that you cannot have a C# source file and a VB
source file be in the same project where they both be compiled. Since
VS.NET doesn't have to compile that page, it doesn't care that there is a C#
script, since it's not bothering to do anything with it anyway.

Yes, you can fool around with it by moving everything into a script - but
then vs.net doesn't actually compile that.
 
This will only work, if you don' t use the CodeBehind - Feature to compile
the Server-Code for multiple Pages into a single dll. Becaurse VS.Net don't
give you a choise to use or not to use codebehind, it won't work wich
VS.Net, but you can do it, but as Bob said, it's no good idea, if you use
e.g. WebMatrix or Notepad.

GP
 
Back
Top