You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using VS2022 and .Net 7 (C#) https://github.com/dotnet/samples/tree/main/core/extensions/COMServerDemo shows an in-proc COM server with one method, no properties. This may be registered and used late-bound from VBA by CreateObject().
I combined this one and https://github.com/dotnet/samples/tree/main/core/extensions/OutOfProcCOM to make an in-proc server with one property in addition to the single method.
Then I edited the .idl file and compiled it with midl just fine and got a typelibrary (.tlb).
Added true to a PropertyGroup in csproj for msbuild
and a in an ItemGroup to embed the typelibrary into the comhost assembly.
Finally regsvr32 on th comhost and the library can nor be referenced from VBA and used early-bound.
All is working from VBA designer/code, intellisense on the server object, method may be run, property value may be read, but if I single step and watch the server object by the Watch window in the VBA debugger and expand the graph, the property does not show up, only the "placeholder text" " as shown below.
I may write server.Pi (the property name) in the watch window and it shows correct value, but without intellisense, but it seems like this is the normal for other "normal" libraries as well.
This makes debugging the VBA code more cumbersome (and I suspect other faults may show up later perhaps).
EDIT: VB6 (sure , unsopported for "centuries", but still working) shows the exact same problems.
I tried very similar things using .Net full framework 8.1 (which handles COM much easier, dont need to make an idl file and run midl etc, all is done automagically) and it works like a charm.
Is this due to a bug or some missing implementation in my code, midl.exe, msbuild, .Net 7 or whatever?
The text was updated successfully, but these errors were encountered:
Using VS2022 and .Net 7 (C#)
https://github.com/dotnet/samples/tree/main/core/extensions/COMServerDemo shows an in-proc COM server with one method, no properties. This may be registered and used late-bound from VBA by CreateObject().
I combined this one and https://github.com/dotnet/samples/tree/main/core/extensions/OutOfProcCOM to make an in-proc server with one property in addition to the single method.
Then I edited the .idl file and compiled it with midl just fine and got a typelibrary (.tlb).
Added true to a PropertyGroup in csproj for msbuild
and a in an ItemGroup to embed the typelibrary into the comhost assembly.
Finally regsvr32 on th comhost and the library can nor be referenced from VBA and used early-bound.
All is working from VBA designer/code, intellisense on the server object, method may be run, property value may be read, but if I single step and watch the server object by the Watch window in the VBA debugger and expand the graph, the property does not show up, only the "placeholder text" " as shown below.
I may write server.Pi (the property name) in the watch window and it shows correct value, but without intellisense, but it seems like this is the normal for other "normal" libraries as well.
This makes debugging the VBA code more cumbersome (and I suspect other faults may show up later perhaps).
EDIT: VB6 (sure , unsopported for "centuries", but still working) shows the exact same problems.
I tried very similar things using .Net full framework 8.1 (which handles COM much easier, dont need to make an idl file and run midl etc, all is done automagically) and it works like a charm.
Is this due to a bug or some missing implementation in my code, midl.exe, msbuild, .Net 7 or whatever?
The text was updated successfully, but these errors were encountered: