2

I am trying to access C# method by using C# DLL from XOJO Tool.

I have follow the procedure Jim have define in the following post:

https://forum.xojo.com/7079-using-c-classes-in-xojo

and everything is configure correctly but when i execute the program, it gives me error NilObjectException was not handled, even when i am passing proper parameter.

Below is the C# code:

using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace XojoStuff
{
    [Guid("DB038D2E-BD4D-44A7-BE64-4844FF07F870")]
    [InterfaceType(ComInterfaceType.InterfaceIsDual)]
    public interface IManagedInterface {[DispId(1)] int PrintHi(string name); }
    [Guid("AB46D07F-6920-4114-924B-5E37BED3A65E")]
    [ClassInterface(ClassInterfaceType.None)]
    public class InterfaceImplementation : IManagedInterface
    {
        public int PrintHi(string name)
        { MessageBox.Show(name); return 1; }
    }
}

Below is the calling from Xojo:

dim o as New XOJOCSDLL.InterfaceImplementation
Call o.PrintHi("Hello")

It should show message box when the execution file is run with the message of Hello

Ammad Ahmed
  • 100
  • 1
  • 8
  • Shouldn't the PrintHi function be declared as static? And what is the value of "o" in Xojo? Is it nil? Then you have somehow not installed the dll correctly, or named it wrong. If it's non-nil, it's more likely that PrintHi can't be found. – Thomas Tempelmann Oct 10 '19 at 12:09
  • No, because then we cant pass the parameter from Xojo if we declare Static. "o" is not Nil, it has class name "XOJOCSDLL.InterfaceImplementation", the error occur when it tries to calls "PrintHi" method – Ammad Ahmed Oct 10 '19 at 12:27

0 Answers0