[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 354
  • Last Modified:

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.
0
sbennetts
Asked:
sbennetts
  • 2
1 Solution
 
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
 
AlexFMCommented:
You need to create myClassName instance, something like this:

dim a as myComponent.myInterface
a = new myClassName
...
0
 
sbennettsAuthor Commented:
Thanks AlexFM, worked it out about ten mins ago.  Why is it always simple?!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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