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

vb.net using a .cs class

I was given a c# class to use in my vb.net project. What do i have to do
other than just placing it in my project for my vb.net classes to be able to
use it? Or can I not do that?

Nov 20 '05 #1
19 1428
Call me ignorant but won't it just work?

Have you tried calling the c# proc from VB using VB.NET?

It should work. I have used several c# dll's and called from my VB
routines. Maybe I am missing something but I don't think so.

If you can't just call it, then please write back.

Shane

"William Gower" <w_*****@hotmail.com> wrote in message
news:O%***************@TK2MSFTNGP10.phx.gbl...
I was given a c# class to use in my vb.net project. What do i have to do
other than just placing it in my project for my vb.net classes to be able to use it? Or can I not do that?

Nov 20 '05 #2
On Wed, 9 Jun 2004 17:17:09 -0400, William Gower wrote:
I was given a c# class to use in my vb.net project. What do i have to do
other than just placing it in my project for my vb.net classes to be able to
use it? Or can I not do that?


You can't use a .cs file in a VB.Net project. You must place the .cs file
in its own C# project and then add that project to your solution. You
should then be able to use it with VB.

--
Chris

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Nov 20 '05 #3
Compile the *.cs file into a class library. You can then reference the assembly in your VB.NET project and use it in your code

You can't mix C# and VB.NET in the same project using Visual Studio.
Nov 20 '05 #4
* "William Gower" <w_*****@hotmail.com> scripsit:
I was given a c# class to use in my vb.net project. What do i have to do
other than just placing it in my project for my vb.net classes to be able to
use it? Or can I not do that?


What you cannot do is adding the C# file to your VB.NET project. One
project, one programming language. If you are using VS.NET Professional
or better, or you have C# Standard, you can create a C# class library,
add the file and set the root namespace in the project properties, let's
say, to 'ClassLibrary1'.

Then you add this project to your solution and add a reference inside
the solution explorer (have a look at the items in the context menus
that are shown when right-clicking projects in solution explorer.

After setting up a reference from your VB.NET project to the C# class
library, you can import the namespace of the class library ('Imports
ClassLibrary1' on top of your VB.NET file, and then use the class
defined in the library.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #5
Guess I stand corrected by the other posts.

I do know that I used it. Guess I was able to via the fact that they were
already compiled dll's.
"SStory" <Th*******@TAKEOUTTHISSPAMBUSTERsofthome.net> wrote in message
news:ej*************@tk2msftngp13.phx.gbl...
Call me ignorant but won't it just work?

Have you tried calling the c# proc from VB using VB.NET?

It should work. I have used several c# dll's and called from my VB
routines. Maybe I am missing something but I don't think so.

If you can't just call it, then please write back.

Shane

"William Gower" <w_*****@hotmail.com> wrote in message
news:O%***************@TK2MSFTNGP10.phx.gbl...
I was given a c# class to use in my vb.net project. What do i have to do other than just placing it in my project for my vb.net classes to be
able to
use it? Or can I not do that?


Nov 20 '05 #6
as of VS 2005 you can use C# VB J# and C++ code all in the same project and
compiled into one assembly
"Chris Dunaway" <"dunawayc[[at]_lunchmeat_sbcglobal[dot]]net"> wrote in
message news:tl*****************************@40tude.net...
On Wed, 9 Jun 2004 17:17:09 -0400, William Gower wrote:
I was given a c# class to use in my vb.net project. What do i have to do other than just placing it in my project for my vb.net classes to be able to use it? Or can I not do that?


You can't use a .cs file in a VB.Net project. You must place the .cs file
in its own C# project and then add that project to your solution. You
should then be able to use it with VB.

--
Chris

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.

Nov 20 '05 #7
Hi Herfried,

Seeing all the answers I had from you expected more some links to a
translate tool for C# to VB.net with the sentence "Why would you use C#".

:-)

(Just for fun your explanation is very clear and not echoing seeing the
times of the other posts.)

Cor
Nov 20 '05 #8
* "Brian Henry" <br**********@newsgroups.nospam> scripsit:
as of VS 2005 you can use C# VB J# and C++ code all in the same project and
compiled into one assembly


AFAIK that won't be possible...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #9
* "Cor Ligthert" <no**********@planet.nl> scripsit:
Seeing all the answers I had from you expected more some links to a
translate tool for C# to VB.net with the sentence "Why would you use C#".


LOL -- I thought about posting the links, but then I decided to wait for
the OP's reaction...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #10
really? because it's in the VS 2005 may preview and works pretty well from
what ive tested ;)
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de...
* "Brian Henry" <br**********@newsgroups.nospam> scripsit:
as of VS 2005 you can use C# VB J# and C++ code all in the same project and compiled into one assembly


AFAIK that won't be possible...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #11
* "Brian Henry" <br**********@newsgroups.nospam> scripsit:
really? because it's in the VS 2005 may preview and works pretty well from
what ive tested ;)


As far as I see, this doesn't work. I created a new Windows Forms
project and added a C# file. When setting its 'Build Action' to
'Compile', there were numbers of errors because the file didn't contain
VB code.

I still doubt that this will work, but can you describe how you got it
to work?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #12
Herfried,
I suspect Brian is using a ASP.NET project.

As my understanding is the same as yours. VS 2005 will not support mixing
languages in a single assembly (project).

ASP.NET is different, as it supports putting any source file in the Code
directory, when the user browses to the web app ASP.NET (not VS.NET) will
take the files in the Code directory and create the appropriate assemblies
out of them...

Jay

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de...
* "Brian Henry" <br**********@newsgroups.nospam> scripsit:
really? because it's in the VS 2005 may preview and works pretty well from what ive tested ;)


As far as I see, this doesn't work. I created a new Windows Forms
project and added a C# file. When setting its 'Build Action' to
'Compile', there were numbers of errors because the file didn't contain
VB code.

I still doubt that this will work, but can you describe how you got it
to work?

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #13
* "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> scripsit:
I suspect Brian is using a ASP.NET project.

As my understanding is the same as yours. VS 2005 will not support mixing
languages in a single assembly (project).

ASP.NET is different, as it supports putting any source file in the Code
directory, when the user browses to the web app ASP.NET (not VS.NET) will
take the files in the Code directory and create the appropriate assemblies
out of them...


OK, thank you! I didn't think of that for some reason...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #14
Hi Jay,

That is sure for ASPX scripting, (was already with framework 1.0).

However when this will not go with windowforms than I am in doubt if it will
go with compiled asp.net.

Basicly it is using that the same as windowforms, you create a dll, which is
the server apllication.

However I know of course nothing or almost nothing about VS2005.

Cor
ASP.NET is different, as it supports putting any source file in the Code
directory, when the user browses to the web app ASP.NET (not VS.NET) will
take the files in the Code directory and create the appropriate assemblies
out of them...


Nov 20 '05 #15
Hi Jay,

Before you write it, reading it over I think you wrote partially the same
as I, however told it in another way. When you mean with VS.net an builded
DLL than it probably complete the same otherwise that part stays.

Cor
Nov 20 '05 #16
Cor,
That is sure for ASPX scripting, (was already with framework 1.0). The code directory/folder is new for ASP.NET 2.0

Scripting I tend to think of client side, the Code directory is server side,
just as the ASPX itself is server side...

My explanation of the Code folder is based on the information in Alex Homer,
Dave Sussman and Rob Howard's book "A First Look at ASP.NET v. 2.0" from
Addison Wesley.

Of course VS.NET 2005 (Whidbey) is still a beta product and actual specifics
can change.

Hope this helps
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:uh**************@tk2msftngp13.phx.gbl... Hi Jay,

That is sure for ASPX scripting, (was already with framework 1.0).

However when this will not go with windowforms than I am in doubt if it will go with compiled asp.net.

Basicly it is using that the same as windowforms, you create a dll, which is the server apllication.

However I know of course nothing or almost nothing about VS2005.

Cor
ASP.NET is different, as it supports putting any source file in the Code
directory, when the user browses to the web app ASP.NET (not VS.NET) will
take the files in the Code directory and create the appropriate assembliesout of them...


Nov 20 '05 #17
Jay,

Scripting I tend to think of client side, the Code directory is server side, just as the ASPX itself is server side...


Sorry, to say it is not, that is the great misunderstanding all the time. I
do not know if you have ever looked at the VB6 IIS class. I tried it a while
and then there was said that the project was stopped, it was full of bugs.
However it creats a serverside dll for an IS server.

Now we have our VS.studio way as you and I recognize making serverside DLL
applications.

However when you take the samples from the SDK 1.1 it is all a kind of
scripting.
(And most samples on msde are, and therefore mostly difficult for us)

You can make aspx pages and ascx pages. In that you can place your HTML and
language code, however not compile, it is compiled just in time at
serverside. There is no problem to place VB after a C# paragraph.

See this by instance (it is old)

<script language="C#" runat="server">
public string loging
{
get { return loginbox.Text; }
set { loginbox.Text = value; }
}
public string pw
{
get { return pwbox.Text; }
set { pwbox.Text = value; }
}
</script>

I hope I clear with this more what I mean?

Cor

Nov 20 '05 #18
Cor,
Sorry, to say it is not, that is the great misunderstanding all the time. I
You sure did misunderstand my statement! Then again you normally do! :-(

My statement meant to say: Within the context of ASP.NET I tend to think of
& use scripting as client side, the code directory itself is server side.

Obviously for your benifit I should have added: Yes you can do server side
scripting within ASP.NET. However my statement was not including server side
scripting...

If you really don't understand what I am stating, please ask. Do not give me
a dissertations on what you think I don't know. As it simply insults me, and
belittles you.

I consider this matter dropped.

Thanks for understanding.
Jay

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:On**************@tk2msftngp13.phx.gbl... Jay,

Scripting I tend to think of client side, the Code directory is server side,
just as the ASPX itself is server side...


Sorry, to say it is not, that is the great misunderstanding all the time.

I do not know if you have ever looked at the VB6 IIS class. I tried it a while and then there was said that the project was stopped, it was full of bugs.
However it creats a serverside dll for an IS server.

Now we have our VS.studio way as you and I recognize making serverside DLL
applications.

However when you take the samples from the SDK 1.1 it is all a kind of
scripting.
(And most samples on msde are, and therefore mostly difficult for us)

You can make aspx pages and ascx pages. In that you can place your HTML and language code, however not compile, it is compiled just in time at
serverside. There is no problem to place VB after a C# paragraph.

See this by instance (it is old)

<script language="C#" runat="server">
public string loging
{
get { return loginbox.Text; }
set { loginbox.Text = value; }
}
public string pw
{
get { return pwbox.Text; }
set { pwbox.Text = value; }
}
</script>

I hope I clear with this more what I mean?

Cor

Nov 20 '05 #19
Jay,

I do not know why you are accusing me in such a low manner.

The only thing I can say is, take your message, go to the mirror, and say it
loud, while you are thinking I am speaking to you.

Cor
Nov 20 '05 #20

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

Similar topics

4
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it...
5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
10
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
8
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
3
by: flat_ross | last post by:
For anyone who is just getting into VB.NET and/or is starting to work with inheritance I would like to point out a potential pitfall. We found this confusion recently when code-reviewing an...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
1
by: Peter Nofelt | last post by:
Hey All, I am having issue with serializing a class and its base class using ..net 2.0. I am using IXmlSerializable I've provided code displaying my at the bottom of this post. Thanks ahead...
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
8
by: =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?= | last post by:
Hi there I've successfully added some .NET validation controls to a page (using <asp:RequiredFieldValidator ...), however when I try to set the 'display' property to 'dynamic', my page then...
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: 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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.