Simon Mourier's Avatar
Simon Mourier's blog (1807 answers on StackOverflow) about Microsoft technologies C#, C/C++, .NET, WinRT, WinUI3, AOT, P/Invoke, COM, Interop, DirectX, Direct2D, Windows, ...
  • 🔎︎ Search
  • Categories
  • Archives
  • About Me
  • .net
  • c#
  • com
  • interop
  • winapi

CoCreateInstance exact match in .NET?

Apr 13, 2013 See the question and my original answer on StackOverflow

You could also do this:

[ComImport]
[Guid(YourGuidGoesHere)]
private class MyClass
{
}

and create an instance of the COM Object like this:

  IYourInterface myClass = (IYourInterface)(new MyClass());

Without using p/invoke.

  • SmoBlog © 2010-2026 Simon Mourier. All rights reserved.
  • Privacy & Terms