Exposing NET 7 classes as COM for Excel VBA (and vb6)

EuroEager2008 171 Reputation points
2023-02-14T08:17:47.96+00:00

I have a .net 7 class library with GUID and ComVisible attributes defined. Also added EnableComHosting tag in csproj.
After registering (regsvr32) the comhost.dll it is usable from e.g. Excel VBA, but only as late bound.

Anyone able to guide me further on how to make it early bound? (guess I have to generate a tlb some way, but have no clue how)

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,346 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,203 questions
{count} votes

Accepted answer
  1. RLWA32 40,021 Reputation points
    2023-02-14T13:42:13.0366667+00:00

    There is a comprehensive sample that includes creating and registering a type library for both in-process and out-of-process COM servers created using .Net that was recently updated for .Net 7.

    https://github.com/dotnet/samples/tree/main/core/extensions/OutOfProcCOM

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Olaf Helper 40,656 Reputation points
    2023-02-14T08:56:13.03+00:00

    But you can add your library as reference in VBA/VB6? Then early binding should work.


  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more