Calling functions from a c# dll in VB6

Hi

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
myReturnString=a.myfunction("Hello")

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

What am I doing wrong?

Thanks
Simon.
LVL 2
sbennettsAsked:
Who is Participating?
 
AlexFMCommented:
You need to create myClassName instance, something like this:

dim a as myComponent.myInterface
a = new myClassName
...
0
 
sbennettsAuthor Commented:
C# code something along the lines of:
--------------------------------------------
using System.EnterpriseServices;
using System.Runtime.InteropServices;

namespace myNameSpace
{
      [GuidAttribute("12345678-CFE8-3333-0000-B59212345678")]
      public interface myInterface
      {
            string myFunction(string AnyString);
      }      
      public class myClassName : ServicedComponent, myInterface
      {
            public string myFunction(string CRC16String)
            {
                  return "This is your return sting";
            }
      }
}
0
 
sbennettsAuthor Commented:
Thanks AlexFM, worked it out about ten mins ago.  Why is it always simple?!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.