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)

Developer technologies .NET Other
Developer technologies C#
{count} votes

Accepted answer
  1. RLWA32 49,536 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 47,436 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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.