473,378 Members | 1,441 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,378 software developers and data experts.

Mixing VB.NEt with CS

Hi All,

I have a VB .NET application. I want to use one class written in CS. Can I
include the CS file and use the class in my VB app? I have tried it but I
cant seem to instantiate the class....

Cheers
Rohit
Jul 21 '05 #1
3 7098
Hi Rohit,

You cannot include C# code in VB.NET. You need to create a new C# project
with the C# code in (as a class library), then reference your VB.NET project
to the C# project. The resulting DLL from the C# project needs to be copied
around with your app.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

"Chaos, Panic, Disorder, my work here is done"
"Rohit Sharma" <lt*************@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP11.phx.gbl...
: Hi All,
:
: I have a VB .NET application. I want to use one class written in CS. Can I
: include the CS file and use the class in my VB app? I have tried it but I
: cant seem to instantiate the class....
:
: Cheers
: Rohit
:
:
Jul 21 '05 #2
Hello,

"Rohit Sharma" <lt*************@hotmail.com> schrieb:
I have a VB .NET application. I want to use one class written
in CS. Can I include the CS file and use the class in my
VB app? I have tried it but I cant seem to instantiate the class....


You will have to compile the class into a C# Class Libarary project and
reference this project from your VB.NET application.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Jul 21 '05 #3
Hi Rohit,

While you can't mix C# and VB within the same project, you can mix them in
the same assembly and you don't need to use a separate class library. To do
this, you need to compile your C# class as a .NetModule, then add that
module when you compile your VB app. This needs to be compiled from the
command-line, as it isn't directly supported within Visual Studio. The
command lines could be something like:

csc /t:module /out:CSharp.NetModule CSharp.cs
vb /t:exe /out:VbTest.Exe /addmodule:CSharp.NetModule VbTest.vb

NetModules are also quite cool in that they allow you to create a plug-in
architecture for your apps.

HTH,

Mark
--
Author of "Comprehensive VB .NET Debugging"
http://www.apress.com/book/bookDisplay.html?bID=128
"Rohit Sharma" <lt*************@hotmail.com> wrote in message
news:es**************@TK2MSFTNGP11.phx.gbl...
Hi All,

I have a VB .NET application. I want to use one class written in CS. Can I
include the CS file and use the class in my VB app? I have tried it but I
cant seem to instantiate the class....

Cheers
Rohit

Jul 21 '05 #4

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

Similar topics

3
by: bergel | last post by:
Hello, Does anyone already have some experience in mixing AWT and Swing? Is it conceptually doable? Does the design of Swing prevent interaction between an AWT and a Swing widget? Regards,...
6
by: Russell E. Owen | last post by:
At one time, mixing for x in file and readline was dangerous. For example: for line in file: # read some lines from a file, then break nextline = readline() # bad would not do what a naive...
0
by: Erik Max Francis | last post by:
Is there any prohibition against mixing different protocols within the same pickle? I don't see anything about this in the Python Library Reference and, after all, the pickle.dump function takes a...
4
by: Rudolf | last post by:
Is it possible to add a vb.net source code module to a c# project and if so how? Thanks Rudolf
1
by: Marc Cromme | last post by:
I would like to ask a question about (good ?) style and possibilities in mixing C FILE* and C++ file streams. The background is that I want to use the C libpng library from within C++, but I...
4
by: Cristian Tota | last post by:
Hi, I'd appreciate any thoughts on mixing C++ and C code. I have a project that uses a given C interface, the rest of the project can be either in C or C++. What would be the recomended design...
2
by: Dan | last post by:
Hi What are the dangers of mixing asp and asp.net? For the .net part of the site i will need to use the global.asax file but for the asp parts it will be using the other global. file, is there...
0
by: dhruba.bandopadhyay | last post by:
I know that it's possible to mix ASP & ASP.NET 1.1 in the same website/application so long as they are in separate frames (iframes). This also holds for mixing ASP & ASP.NET 2.0 pages. But what I...
28
by: ziman137 | last post by:
Hello all, I have a question and am seeking for some advice. I am currently working to implement an algorithmic library. Because the performance is the most important factor in later...
3
by: jason | last post by:
I've been working with C# for over a year now without touching vb.net code. I had a few light years of vb.net before that. No real vb6 or windows form experience. Suddenly, I have an assignment...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?

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.