Solved

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

Posted on 2004-10-25
329 Views
Last Modified: 2010-04-15
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.

regards
0
Question by:OnlineNoob
    6 Comments
     
    LVL 19

    Expert Comment

    by:Desp
    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

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


    or without *using* keyword

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

    0
     
    LVL 1

    Author Comment

    by:OnlineNoob
    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.
    0
     
    LVL 7

    Expert Comment

    by:sukumar_diya
    Hi,
    Check this url http://www.codeproject.com/csharp/GBVB.asp
    It helps to convert vb.net code to c#.

    Cheers
    Sukumar
    0
     
    LVL 19

    Expert Comment

    by:Desp
    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
    0
     
    LVL 19

    Expert Comment

    by:Desp
    It would be possible in the upcoming version of VS.Net
    0
     
    LVL 6

    Accepted Solution

    by:
    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.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    The Complete Ruby on Rails Developer Course

    Ruby on Rails is one of the most popular web development frameworks, and a useful tool used by both startups and more established companies to build strong graphic user interfaces, and responsive websites and apps.

    In one of my recent projects, I was working with IP cameras, I need to take some pictures from the camera and do some processing on it. The first step, was to retrieve the image from camera into Image object. So that it can be displayed or …
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    In this Experts Exchange video Micro Tutorial, I'm going to show how small business owners who use Google Apps can save money by setting up what is called a catch-all email address in their Gmail accounts. By using the catch-all feature, small busin…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    877 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now