473,473 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

use C# code in vb.net project

I found some C# code on the web that I want to use in my vb.net project.
How can I do this without translating the C# to VB.net?

It's pretty nasty looking or I'd translate it myself
stuff like
#region COM Interop for IShellFolder
[ComImportAttribute()]
[GuidAttribute("000214E6-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)]
//helpstring("IShellFolder interface")
private interface IShellFolder
{
void ParseDisplayName(
IntPtr hwndOwner,
IntPtr pbcReserved,
[MarshalAs(UnmanagedType.LPWStr)] string lpszDisplayName,
out int pchEaten,
out IntPtr ppidl,
out int pdwAttributes);

void EnumObjects(
IntPtr hwndOwner,
[MarshalAs(UnmanagedType.U4)] ESHCONTF grfFlags,
ref IEnumIDList ppenumIDList
);

void BindToObject(
IntPtr pidl,
IntPtr pbcReserved,
ref Guid riid,
ref IShellFolder ppvOut);

thanks
mike w

Nov 21 '05 #1
3 1859
You would have to put it into its own project and compile it as its own dll.
Then reference it from your VB project.

Chris

"mike w." <mi***@discussions.microsoft.com> wrote in message
news:31**********************************@microsof t.com...
I found some C# code on the web that I want to use in my vb.net project.
How can I do this without translating the C# to VB.net?

It's pretty nasty looking or I'd translate it myself
stuff like
#region COM Interop for IShellFolder
[ComImportAttribute()]
[GuidAttribute("000214E6-0000-0000-C000-000000000046")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceI sIUnknown)]
//helpstring("IShellFolder interface")
private interface IShellFolder
{
void ParseDisplayName(
IntPtr hwndOwner,
IntPtr pbcReserved,
[MarshalAs(UnmanagedType.LPWStr)] string lpszDisplayName,
out int pchEaten,
out IntPtr ppidl,
out int pdwAttributes);

void EnumObjects(
IntPtr hwndOwner,
[MarshalAs(UnmanagedType.U4)] ESHCONTF grfFlags,
ref IEnumIDList ppenumIDList
);

void BindToObject(
IntPtr pidl,
IntPtr pbcReserved,
ref Guid riid,
ref IShellFolder ppvOut);

thanks
mike w

Nov 21 '05 #2
"mike w." <mi***@discussions.microsoft.com> schrieb:
I found some C# code on the web that I want to use in my vb.net project.
How can I do this without translating the C# to VB.net?


Add a C# project of type "Class Library" to your solution, then insert the
code into the C# project and add a reference to the C# project in your
VB.NET project. It's not possible to mix different programming languages in
a single project.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
And don't than forget in the added C# Project to set the general properties
"output type" to Class Library and do a build for that before you set the
reference in your VB project.

I hope this helps?

Cor

ps. Herfried I had this from an other message half an hour ago.
Nov 21 '05 #4

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

Similar topics

8
by: Russ | last post by:
Hello. I have a very large business application written all in VC++ and MFC. Now I want to interface some of it to the web. I have VS.NET2003 and have been studing walkthroughs and documentation...
7
by: Dan | last post by:
I'd like to have a set of more-or-less common code which I want to use for both desktop and smart device projects. I have two questions: 1. How can I set up conditional compile directives for...
6
by: Vaclav Jedlicka | last post by:
Hi all Is it possible to create an ASP.NET project from code? Thanks in advance Vaclav
6
by: Peter Row | last post by:
Hi, Can someone give me a set of steps for an ASP.NET project (well actually its just a VB.NET class DLL that implements HttpHandler) that will work when moved to another developers machine? ...
88
by: Peter Olcott | last post by:
Cab you write code directly in the Common Intermediate language? I need to optimize a critical real-time function.
16
by: Rex | last post by:
Hi All - I have a question that I think MIGHT be of interest to a number of us developers. I am somewhat new to VIsual Studio 2005 but not new to VB. I am looking for ideas about quick and...
16
by: lawrence k | last post by:
I've made it habit to check all returns in my code, and usually, on most projects, I'll have an error function that reports error messages to some central location. I recently worked on a project...
6
by: Larry Bud | last post by:
Been working with .net 2 since January, and am in the middle of my first large project. It's becoming obvious that one must organize their code well in a large project to make maintenance...
3
by: Iluvatar | last post by:
Hi, last week our project upgraded from vs.net 2005 to vs.net 2008. Our project still uses framework 2.0, because the deployment servers are not 3.x ready yet. Everything so far while migrating...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.