473,545 Members | 2,094 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 1866
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
2001
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
2183
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
7981
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
2778
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
2594
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
7467
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7656
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. ...
1
7419
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7756
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
5971
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
4944
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
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
703
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.