Ben
Ben

Reputation: 2523

Visual Basic "COM Class" counterpart in C#?

We are trying to develop a Plugin for an application, and have unfortunately not received any actual instruction on what to use, how to use, and what is available for the development API. So far our direction has been "Can be developed in VB and C#", and "Watch these videos". However, the videos are not so much on how to develop Plugins, just what you can do with the API.

One of the apparently essential parts of the development is the use of the VB COM Class (primarily due to the "free" GUIDs generated in the class). This would be fine, apart from the fact that my VB knowledge is outdated by roughly a decade. My C# knowledge however, while still incomplete, is far more up-to-date.

So; is there a COM counterpart in C#, or do I need to manage this another way?

EDIT: To clarify, the COM Class is used to compile the project as a .dll (obviously), so it can be loaded into the application as a plugin. The reference material I have reviewed simply states that this can be created, and there is no existing COM Class that needs to be imported in any way. For reference; the application is a DMS called "Adept".

Upvotes: 1

Views: 139

Answers (1)

Matt Styles
Matt Styles

Reputation: 611

COM isn't strictly language-specific as much as it is framework-specific. So the simple answer is that you can do COM in C# as much as you can do it in VB.

I won't copy-paste an entire MSDN article, but here is a quick example: https://msdn.microsoft.com/en-us/library/c3fd4a20.aspx

However, I am slightly confused by your question - are you being asked to create a COM class, or use an existing one?

The article above describes making a COM class. If you need to use an existing COM class library (e.g. an existing .dll), then it is often as simple as adding a Reference to the .dll in your project.

The question is tagged 'vba' but the question mentions VB? The two are similar in many ways, but also at times very different.

Instructions for adding a Reference in Visual Studio are at https://msdn.microsoft.com/en-us/library/wkze6zky.aspx.

If you are developing VBA, as opposed to VB, if you could let us know what you're developing in (e.g. Excel?), we might be able to offer more advice.

Upvotes: 2

Related Questions