Calling functions from a c# dll in VB6

Posted on 2005-05-09
Last Modified: 2010-04-17

I have a C# dll with a number of functions.  

I have created by DLL and have created a public interface outside the class to allow VB6 to see the available functions.

I use regasm to register my DLL and create a type library which seems to be fine.

I then start with my very simple VB6 app.

dim a as myComponent.myInterface
dim myReturnString as sting

When it gets to the last line, it returns with an Object variable or with variable error (91).

What am I doing wrong?

Question by:sbennetts
    LVL 2

    Author Comment

    C# code something along the lines of:
    using System.EnterpriseServices;
    using System.Runtime.InteropServices;

    namespace myNameSpace
          public interface myInterface
                string myFunction(string AnyString);
          public class myClassName : ServicedComponent, myInterface
                public string myFunction(string CRC16String)
                      return "This is your return sting";
    LVL 48

    Accepted Solution

    You need to create myClassName instance, something like this:

    dim a as myComponent.myInterface
    a = new myClassName
    LVL 2

    Author Comment

    Thanks AlexFM, worked it out about ten mins ago.  Why is it always simple?!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    INTRODUCTION We all know how to code. But at times you simply want to insert a common code block into your existing code and amend it as per your requirements. This tool not only saves you time but also saves you the pain of typing it all out aga…
    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    734 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

    23 Experts available now in Live!

    Get 1:1 Help Now