PC Review


Reply
Thread Tools Rate Thread

Calling of C# methods from VB.Net

 
 
Muhammad Arif
Guest
Posts: n/a
 
      25th Feb 2004
Dear All,
How I can call a method of C# class from VB.Net? Suppose I have a
class SaveFile in C# having a method saveImageFile(). There is a form
Form1 in VB.Net having an picturebox populated with an image. I want
to call SaveFile.saveImageFile() method from Form1. How it will be
done?

Regares,
Arif
 
Reply With Quote
 
 
 
 
Maarten Struys, eMVP
Guest
Posts: n/a
 
      25th Feb 2004
Is your C# code available in a separate DLL? What you do then is add a
reference to that particular dll. After having set that reference you simply
invoke the C# function with its name + expected parameters from VB.NET, e.g.
SaveFile.saveImageFile().

--
Regards,

Maarten Struys, eMVP
PTS Software bv

www.opennetcf.org | www.dotnetfordevices.com

"Muhammad Arif" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Dear All,
> How I can call a method of C# class from VB.Net? Suppose I have a
> class SaveFile in C# having a method saveImageFile(). There is a form
> Form1 in VB.Net having an picturebox populated with an image. I want
> to call SaveFile.saveImageFile() method from Form1. How it will be
> done?
>
> Regares,
> Arif



 
Reply With Quote
 
Milosz - [playseven.com]
Guest
Posts: n/a
 
      25th Feb 2004
You can also add the C# project to your Solution

regards

--
-> Milosz Weckowski
www.playseven.com

private.php?do=newpm&u=
ICQ Number: 84867613

Get the enhanced Progressbar and a fine Colorpicker for the Compact Framwork
for free:
http://www.playseven.com/11620/p7_Controls.html


"Muhammad Arif" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Dear All,
> How I can call a method of C# class from VB.Net? Suppose I have a
> class SaveFile in C# having a method saveImageFile(). There is a form
> Form1 in VB.Net having an picturebox populated with an image. I want
> to call SaveFile.saveImageFile() method from Form1. How it will be
> done?
>
> Regares,
> Arif



 
Reply With Quote
 
Neil Cowburn [MVP]
Guest
Posts: n/a
 
      25th Feb 2004
Add your C# class to a class library project, compile it and then
reference the assembly from your VB .NET project. Very simple, yet
effective.

HTH
Neil

--
Neil Cowburn, MVP
Co-founder, OpenNETCF.org
Technologist, Content Master Ltd
Microsoft .NET Compact Framework MVP

www.opennetcf.org | www.contentmaster.com


Muhammad Arif wrote:
> Dear All,
> How I can call a method of C# class from VB.Net? Suppose I have a
> class SaveFile in C# having a method saveImageFile(). There is a form
> Form1 in VB.Net having an picturebox populated with an image. I want
> to call SaveFile.saveImageFile() method from Form1. How it will be
> done?
>
> Regares,
> Arif

 
Reply With Quote
 
Muhammad Arif
Guest
Posts: n/a
 
      26th Feb 2004
Dear Milosz,
Yup, I can add C# project to my solution but how i can use it? The C#
namespace is not accessible in VB.Net project.

Regards,
Arif

"Milosz - [playseven.com]" <(E-Mail Removed)> wrote in message news:<OAdlOf4#(E-Mail Removed)>...
> You can also add the C# project to your Solution
>
> regards
>
> --
> -> Milosz Weckowski
> www.playseven.com
>
> private.php?do=newpm&u=
> ICQ Number: 84867613
>
> Get the enhanced Progressbar and a fine Colorpicker for the Compact Framwork
> for free:
> http://www.playseven.com/11620/p7_Controls.html
>
>
> "Muhammad Arif" <(E-Mail Removed)> schrieb im Newsbeitrag
> news:(E-Mail Removed)...
> > Dear All,
> > How I can call a method of C# class from VB.Net? Suppose I have a
> > class SaveFile in C# having a method saveImageFile(). There is a form
> > Form1 in VB.Net having an picturebox populated with an image. I want
> > to call SaveFile.saveImageFile() method from Form1. How it will be
> > done?
> >
> > Regares,
> > Arif

 
Reply With Quote
 
Muhammad Arif
Guest
Posts: n/a
 
      26th Feb 2004
Dear Neil,
I have compiled my C# class library and add it to VB.Net project. When
I rebuilt the solution of VB.Net project, I gave an error that
application conflict with "mscorlib.dll". I dig out this file from my
computer and placed it with my application and start the error was
resolved.
But when my other team member took the latest version of application
and compiled VB.Net project, he also got the same error and it is not
be resolved in any case.
What would be the problem with this?

Regards,
Muhammad Arif





"Neil Cowburn [MVP]" <(E-Mail Removed)> wrote in message news:<#lByD34#(E-Mail Removed)>...
> Add your C# class to a class library project, compile it and then
> reference the assembly from your VB .NET project. Very simple, yet
> effective.
>
> HTH
> Neil
>
> --
> Neil Cowburn, MVP
> Co-founder, OpenNETCF.org
> Technologist, Content Master Ltd
> Microsoft .NET Compact Framework MVP
>
> www.opennetcf.org | www.contentmaster.com
>
>
> Muhammad Arif wrote:
> > Dear All,
> > How I can call a method of C# class from VB.Net? Suppose I have a
> > class SaveFile in C# having a method saveImageFile(). There is a form
> > Form1 in VB.Net having an picturebox populated with an image. I want
> > to call SaveFile.saveImageFile() method from Form1. How it will be
> > done?
> >
> > Regares,
> > Arif

 
Reply With Quote
 
Neil Cowburn [MVP]
Guest
Posts: n/a
 
      26th Feb 2004
In this case, you need to add a reference to the C# project to your VB
..NET project.

--
Neil Cowburn, MVP
Co-founder, OpenNETCF.org
Technologist, Content Master Ltd
Microsoft .NET Compact Framework MVP

www.opennetcf.org | www.contentmaster.com

Muhammad Arif wrote:
> Dear Milosz,
> Yup, I can add C# project to my solution but how i can use it? The C#
> namespace is not accessible in VB.Net project.
>
> Regards,
> Arif
>
> "Milosz - [playseven.com]" <(E-Mail Removed)> wrote in message news:<OAdlOf4#(E-Mail Removed)>...
>
>>You can also add the C# project to your Solution
>>
>>regards
>>
>>--
>>-> Milosz Weckowski
>>www.playseven.com
>>
>>private.php?do=newpm&u=
>>ICQ Number: 84867613
>>
>>Get the enhanced Progressbar and a fine Colorpicker for the Compact Framwork
>>for free:
>>http://www.playseven.com/11620/p7_Controls.html
>>
>>
>>"Muhammad Arif" <(E-Mail Removed)> schrieb im Newsbeitrag
>>news:(E-Mail Removed)...
>>
>>>Dear All,
>>>How I can call a method of C# class from VB.Net? Suppose I have a
>>>class SaveFile in C# having a method saveImageFile(). There is a form
>>>Form1 in VB.Net having an picturebox populated with an image. I want
>>>to call SaveFile.saveImageFile() method from Form1. How it will be
>>>done?
>>>
>>>Regares,
>>>Arif

 
Reply With Quote
 
Neil Cowburn [MVP]
Guest
Posts: n/a
 
      26th Feb 2004
Are you using the .NET CF version of mscorlib? It has a public key token
of 969db8053d3322ac.

--Neil

--
Neil Cowburn, MVP
Co-founder, OpenNETCF.org
Technologist, Content Master Ltd
Microsoft .NET Compact Framework MVP

www.opennetcf.org | www.contentmaster.com


Muhammad Arif wrote:
> Dear Neil,
> I have compiled my C# class library and add it to VB.Net project. When
> I rebuilt the solution of VB.Net project, I gave an error that
> application conflict with "mscorlib.dll". I dig out this file from my
> computer and placed it with my application and start the error was
> resolved.
> But when my other team member took the latest version of application
> and compiled VB.Net project, he also got the same error and it is not
> be resolved in any case.
> What would be the problem with this?
>
> Regards,
> Muhammad Arif
>
>
>
>
>
> "Neil Cowburn [MVP]" <(E-Mail Removed)> wrote in message news:<#lByD34#(E-Mail Removed)>...
>
>>Add your C# class to a class library project, compile it and then
>>reference the assembly from your VB .NET project. Very simple, yet
>>effective.
>>
>>HTH
>>Neil
>>
>>--
>> Neil Cowburn, MVP
>> Co-founder, OpenNETCF.org
>> Technologist, Content Master Ltd
>> Microsoft .NET Compact Framework MVP
>>
>> www.opennetcf.org | www.contentmaster.com
>>
>>
>>Muhammad Arif wrote:
>>
>>>Dear All,
>>>How I can call a method of C# class from VB.Net? Suppose I have a
>>>class SaveFile in C# having a method saveImageFile(). There is a form
>>>Form1 in VB.Net having an picturebox populated with an image. I want
>>>to call SaveFile.saveImageFile() method from Form1. How it will be
>>>done?
>>>
>>>Regares,
>>>Arif

 
Reply With Quote
 
Ravichandran J.V.
Guest
Posts: n/a
 
      26th Feb 2004
Quite simple. Compile your C# class into a Dll and Add Reference to it
from your VB project and then, declare a type of the C# class
programmatically and instantiate it.

Dim o as Class1
o=new Class1
o.saveImageFile()


with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
Muhammad Arif
Guest
Posts: n/a
 
      27th Feb 2004
Dear Neil,
I how i can judge that I am using .NET CF version of mscorlib?
Moreover, for what purpose this library is used?

-- Arif --


> Are you using the .NET CF version of mscorlib? It has a public key token
> of 969db8053d3322ac.
>
> --Neil
>
> --
> Neil Cowburn, MVP
> Co-founder, OpenNETCF.org
> Technologist, Content Master Ltd
> Microsoft .NET Compact Framework MVP
>
> www.opennetcf.org | www.contentmaster.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling n methods =?Utf-8?B?YjF1Y2VyZWU=?= Microsoft C# .NET 4 4th Oct 2007 06:39 AM
Re: Calling .Net 2.0 Methods from .Net 1.1 Ignacio Machin \( .NET/ C# MVP \) Microsoft Dot NET Framework 0 15th Dec 2006 08:11 PM
All calling methods John Bailo Microsoft Dot NET 2 15th Aug 2006 09:35 PM
Calling methods Jon Microsoft VB .NET 1 3rd Oct 2005 10:43 AM
Calling MC++ methods from VB.NET =?Utf-8?B?Um9i?= Microsoft VC .NET 4 15th Mar 2004 05:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:13 PM.