• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

call procedure in vb.net form class from c# class?

hi all,

I don't code in c# and know little about it, but I have a library of code that I'm using.   Primarily I code in vb.net.   I have added error handling within many of the functions and procedures of the c# library classes.   I would like to call a procedure that is in my vb.net form from within my c# code.   Can someone please show me how I can do this?   The procedure is just a one liner name, no parameters to pass or anything.   also, the vb.net form is already open.

1 Solution
Fahad MukhtarDistinguished EngineerCommented:
if you meant to say that you have a class library written in C# then you can easily use that DLL in your VB.NET Code. Just click *Project-> Add Reference* menu and browse for the C# DLL.  Then you can easily use the classes in that DLL by using either

myCSharpClass c  = new myCSharpClass();

or without *using* keyword

MYCSHARPDLL.myCSharpClass c  = new MYCSHARPDLL.myCSharpClass();

OnlineNoobAuthor Commented:
I have sevearl C# classes uncompiled in my solution, along with my vb.net project.   I would like to call public procedure in the vb.net form class from within my c# class.
Check this url http://www.codeproject.com/csharp/GBVB.asp
It helps to convert vb.net code to c#.

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Fahad MukhtarDistinguished EngineerCommented:
you can put your C# code in a dll and then acces in vb.net application easily...
I dont think you can use both C# classes in vb.net it in the same application
Fahad MukhtarDistinguished EngineerCommented:
It would be possible in the upcoming version of VS.Net
So the VB.Net project is a Windows application. Is the C# project also a Widnows application? Or is the C# project .dll?

Anyways, please remember that an .EXE application has an application domain which makes its bounderies clear: its members are for itself. That means, it is impossible to let a C# project access the members of a VB.Net application project. But you can let the VB.Net application project access the members of the C# project.

What you can do is to create a VB.Net .dll that defines the member you wanted to share to other projects. You can then use this .dll in both your VB.Net app and your C# .dll.

Have fun.

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now