473,543 Members | 2,455 Online
Bytes | Software Development & Data Engineering Community
+ 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
[ComImportAttrib ute()]
[GuidAttribute(" 000214E6-0000-0000-C000-000000000046")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown)]
//helpstring("ISh ellFolder interface")
private interface IShellFolder
{
void ParseDisplayNam e(
IntPtr hwndOwner,
IntPtr pbcReserved,
[MarshalAs(Unman agedType.LPWStr )] string lpszDisplayName ,
out int pchEaten,
out IntPtr ppidl,
out int pdwAttributes);

void EnumObjects(
IntPtr hwndOwner,
[MarshalAs(Unman agedType.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 1865
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***@discussi ons.microsoft.c om> wrote in message
news:31******** *************** ***********@mic rosoft.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
[ComImportAttrib ute()]
[GuidAttribute(" 000214E6-0000-0000-C000-000000000046")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIUnknown)]
//helpstring("ISh ellFolder interface")
private interface IShellFolder
{
void ParseDisplayNam e(
IntPtr hwndOwner,
IntPtr pbcReserved,
[MarshalAs(Unman agedType.LPWStr )] string lpszDisplayName ,
out int pchEaten,
out IntPtr ppidl,
out int pdwAttributes);

void EnumObjects(
IntPtr hwndOwner,
[MarshalAs(Unman agedType.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***@discussi ons.microsoft.c om> 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
1999
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 and trying some things. I wanted to build an XML web service that would interface to my existing data and classes. But most of the examples are...
7
3093
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 those parts of the code which are different on desktop and smart device projects 2. How can I actually share the same .cs source code files between...
6
1565
by: Vaclav Jedlicka | last post by:
Hi all Is it possible to create an ASP.NET project from code? Thanks in advance Vaclav
6
2182
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? Here are some specifics: 1) The code, project/solution files are in MS Visual Source Safe
88
7980
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
2776
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 efficient navigating within Visual Studio 2005. Let's say your project (or solution) has dozens of forms and hundreds or even thousands of routines. ...
16
2591
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 where someone suggested to me I was spending too much time writing error messages, and that I was therefore missing the benefit of using a scripting...
6
2194
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 easier. So what's your process? Do you stick everything in one Class file? Do you have a separate class file for each "type" of function.. i.e. one...
3
2711
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 the solution and project files worked fine. Today, I tried to add new controls to an existing web form. The markup doesn't show any errors, but...
0
7341
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7584
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7729
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7677
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5880
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4884
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1809
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 we have to send another system
1
952
muto222
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.