VB.Net and C-Sharp

Posted on 2006-03-29
Medium Priority
Last Modified: 2010-04-23

I have a problem in VB.Net that can only be solved in C# (problem with casting). I have made a C# class (from an example), is it possible to link this class into my VB application ? Or how can I use this class ?

Question by:ACAE
  • 2
  • 2
LVL 34

Expert Comment

ID: 16320229
Complie the class and add a reference to it.

Author Comment

ID: 16320283
I can't seem to get it working. I added my class to my project (right-click on project --> Add --> Add existing item), selected the class (cs file), and build the project. But now i cannot add a line like

DIM localclass AS NEW csharpclass

this gives the error Type 'csharpclass' is not defined

Perhaps I used the wrong definition for 'class', it is a source file not a project
LVL 34

Accepted Solution

flavo earned 500 total points
ID: 16320500
Create a new C# class library solution, build the solution.

Now in your VB solution, in the solution Explorer, right click on "References" -> Select "Add Reference" browse to your file and add it (I'll assume your solution was called myClassLib and the class is called myClass)

Now you can use

Dim c as myClassLib.myClass 'etc......


Author Comment

ID: 16320774

Thx for your help, it works fine for me now.


Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question