1

I have written a COM interface in C#. I then tried to write a simple application that references it so that I can test the COM interface, however Visual Studio does not allow COM interfaces to be referenced if they have been written in C#.

Is there any way to get around this? If not, which language is likely to be the easiest for me to accomplish my task?

Nicholas Hill
  • 306
  • 2
  • 18
  • How about the Excel VBA editor? You can add it as a reference there, and test out the interface. – Baldrick Apr 30 '14 at 09:24
  • _Visual Studio does not allow COM interfaces to be referenced if they have been written in C#._ Really? Perhaps you did not register the type library correctly? In that case you will not be able to test your COM object no matter which tool you decide to use. – Martin Liversage Apr 30 '14 at 09:26
  • @MartinLiversage: It *might* be possible to work around it, but by default it doesn't seem to be possible out of the box. See this answer: http://stackoverflow.com/questions/4614625/can-not-add-reference-a-com-in-com-client – Baldrick Apr 30 '14 at 09:28
  • I second Excel VBA. It's common, fast, and very straightforward. If you're struggling to come up with a plan to do this then Excel is probably a good idea. – J... Apr 30 '14 at 09:32

1 Answers1

3

I would suggest the Excel VBA editor for this.

Open Excel, hit Alt + F11 to invoke the VBA editor.

Create a new module, go to Tools -> References, find your COM object in the list, and check the box.

You should then be able to create an object, and test your interface is working.

Baldrick
  • 11,712
  • 2
  • 31
  • 35