Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / January 2005

Tip: Looking for answers? Try searching our database.

Mixing VB.NET & C# & How to Do This

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeffrey Roughgarden - 12 Jan 2005 20:47 GMT
Within a single web application, is it possible to have some asp.net pages
use vb.net and some use c#? If so, how does one actually do this in Visual
Studio?

I have been doing pages in vb.net and wanted to add a page in c#. How do I
do this? When I add a web form, it always has a vb code-behind page. If I
change the language="vb" to "c#", it still stays vb. How do I open a new web
form in c#?
Carlos J. Quintero [.NET MVP] - 13 Jan 2005 11:13 GMT
No, at least using VS.NET. Maybe using the command-line compilers of the
.NET Framework SDK. Couldn?t you translate them into a single language and
have a uniform project?

Signature

Carlos J. Quintero

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

> Within a single web application, is it possible to have some asp.net pages
> use vb.net and some use c#? If so, how does one actually do this in Visual
[quoted text clipped - 5 lines]
> web
> form in c#?
Jeffrey Roughgarden - 13 Jan 2005 17:15 GMT
Hmmm. So you can't mix and match lnaguages in a single Web application. But
you can write a dll in say C# and use it in a VB.NET/ASP.NET application,
right?

I wonder if you know the answer to my second question. My Visual Studio has
both VB and C#installed. Now when I start a web app, it always defaults to
VB. How do I start a project in C#?

Thanks in advance.
Carlos J. Quintero [.NET MVP] - 14 Jan 2005 10:02 GMT
> Hmmm. So you can't mix and match lnaguages in a single Web application.
> But
> you can write a dll in say C# and use it in a VB.NET/ASP.NET application,
> right?

The DLL generated for the code-behind code must be written in a single
language. Other thing is that you code-behind code uses an external DLL that
you have written in a different language, that is possible of course.

> I wonder if you know the answer to my second question. My Visual Studio
> has
> both VB and C#installed. Now when I start a web app, it always defaults to
> VB. How do I start a project in C#?

What do you mean with "I start a web app".

- If you open an existing Web App, the Add File uses the language of the
project of the Web App.
- If you create a new Web App, you can choose if the project is VB.NET or C#

Signature

Carlos J. Quintero

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

Jeffrey Roughgarden - 14 Jan 2005 19:05 GMT
> - If you create a new Web App, you can choose if the project is VB.NET or C#
>
> Carlos J. Quintero

Carlos,

Sorry to be dense, but when I create a new Web App, it comes up in vb.net. I
don't get a choice to start in C#. Where do you get the choice?

The top line on the HTML is:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb"
Inherits="WebApplication1.WebForm1"%>

I also have AssemblyInfo.vb, Global.asax.vb, and a Web.config that includes
the following:

   <compilation defaultLanguage="vb" debug="true" />

Why is it assuming vb? How can I make it create a new Web app in C#?

Thanks in advance to anyone who can clear up this probably trivial problem.

Jeff Roughgarden, MCSD, MCDBA
Carlos J. Quintero [.NET MVP] - 17 Jan 2005 10:51 GMT
- Open VS.NET
- Click the File, New, Project... menu
- You get a New Project dialog. In this dialog, to the left there is a
Project Types treeview which contains at least "Visual Basic Projects",
"Visual C# Projects", etc. Once you choose one of them, to the right you
have a list of templates and you select ASP.NET Web application.

The treeview shows only the language packages (Visual Basic, Visual C#,
Visual J#, etc.) that you selected for installation when you installed
Visual Studio .NET.

Do you get that New Project dialog? Which project types do you get?

Signature

Carlos J. Quintero

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

>> - If you create a new Web App, you can choose if the project is VB.NET or
>> C#
[quoted text clipped - 24 lines]
>
> Jeff Roughgarden, MCSD, MCDBA
Jeffrey Roughgarden - 18 Jan 2005 02:39 GMT
Thanks, Carlos. I finally got it.

You can have projects of different languages in the same solution, but
within a project all has to be in one language.

And yes, I see where I get to chose the language when I open a new project.

Sorry to have been so dense; thanks again.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.