0

I have written my code in c#, and build dll. When I m creating object in vfp, Im getting error.

I am using below code in vfp

SET LIBRARY TO bt_print.tlb
hh=CREATEOBJECT("bt_print.bt")

My c# code is

I have checked "Register for COM interop" check box.

Please correct me , what i am doing wrong.

Thanks in advance.

chetan
  • 129
  • 1
  • 2
  • 12
  • I am going to guess your operating system is 64-bit this means because VFP does not and will never support a 64-bit operating system, you must force your application to be a 32-bit application. Of course without the error we cannot confirm this is the case. – Security Hound Aug 20 '12 at 10:49

1 Answers1

3

Checkmark the "Make the Assembly COM-Visible" - Project Settings, Application Page, Assembly Information.

In C#, add the ClassInterface and ProgId.

using System;
using System.Runtime.InteropServices;

namespace bt_print

{
    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ProgId("bt_print.bt")]
    public class bt
    {
        public void search_bt()
        {
        }

        public void sendfile(String fl)
        {
        }
    }
}

In VFP, use the NEWOBJECT() function.

hh = NEWOBJECT("bt_print.bt")
Frank Perez
  • 993
  • 8
  • 18