0

I'm trying to get a C# winforms DLL to work as a COM component.

All of my methods work fine, but the properties do not - I get the error

Object reference not set to an instance of an object.

All of the properties and methods in the interface below are marked public in the class that implements them.

[Guid("MY-GUID-IS-HERE")]
public interface IMyWinformsCOMComponent
{
    String clientID { get; }
    byte[] userID { get; }
    string language { get; set; }
    int productID { get; set; }
    uint version { get; }

    void thisWorksFine(string key, string value);
    uint getValue();
    void showTheForm();
}

Here is the vbscript sample that fails

Dim oMyWinformsCOMComponent
Set oMyWinformsCOMComponent = CreateObject("myNameSpace.MyWinformsCOMComponent")

'Works fine
Dim foo : foo = oMyWinformsCOMComponent.getValue()

'Works fine
oMyWinformsCOMComponent.thisWorksFine "myString", "myValue"

'Doesn't work
Dim lang : lang = oMyWinformsCOMComponent.language
user692942
  • 16,398
  • 7
  • 76
  • 175
John
  • 5,672
  • 7
  • 34
  • 52
  • 1
    Can you post the Class definition in the question as well?, prefer to check the implementation. – user692942 Jan 12 '17 at 22:40
  • 1
    Related [How to make properties visible to COM in a .NET DLL (Methods DO work)](http://stackoverflow.com/q/37207659/692942) - see comments. – user692942 Jan 12 '17 at 22:43
  • 2
    Turns out the class constructor wasn't being called and language was calling a non static method of a member object. – John Jan 12 '17 at 22:51
  • 1
    which we couldn't help with just from seeing the interface. – user692942 Jan 12 '17 at 22:53

0 Answers0