Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Excel DNA with .NET 8

334 views
Skip to first unread message

Chintu

unread,
Oct 28, 2024, 2:20:23 PM10/28/24
to Excel-DNA
Hi

I am migrating my C# project currently in .NET framework 4.8 to .NET 8. I have however just been made aware that .NET 8 doesn't support the type library exporter (TLBEXP). Can someone please point me to an example C# code that runs on .NET 8 using Excel-DNA to be able to  directly reads/write data from excel and VBA. 

I am using VS2022.

Thanks in advance.

Raj

Govert van Drimmelen

unread,
Oct 28, 2024, 2:59:32 PM10/28/24
to exce...@googlegroups.com

Hi Raj,

 

You can try out this repository.

govert/TestComServer18 (github.com)

 

It uses the dSPACE COM tools (dspace-group/dscom: dscom, a toolkit for creating and registering type libraries (tlb) and additional interop helper methods for COM (github.com)) to make the .tlb file.

One difference from the real tlbexp is that it does not support AutoDual interfaces.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/exceldna/4f366d97-4ce6-4575-996e-ab9c7164abefn%40googlegroups.com.

Message has been deleted

Chintu

unread,
Oct 29, 2024, 1:49:36 PM10/29/24
to Excel-DNA
Hi Govert, thanks for this. 

I have tried adding a reference to the package "dspace.runtime.interopservices.buildtasks (1.11.1) into my project. I am, however, getting an error (MSB3073) saying that the dscom.exe tlbexport exited with code 1. Any idea what I might be doing wrong?

Also, I use ClassInterfaceType.AutoDual a lot in my solution. If dscom doesn't support AutoDual interfaces, what are my options?

Regards

Raj

Govert van Drimmelen

unread,
Oct 30, 2024, 6:31:58 AM10/30/24
to Excel-DNA
Does the test project work on your side?

If so, you can try to simplify your project to see what the error is, or install dscom as a global tool and run it directly to see if you can get a verbose output.
If AutoDual is the only reason why dscom doesn't work in your project, then you should consider 
* refactoring the project to remove AutoDual (see  .NET host objects need to use deprecated AutoDual attribute · Issue #517 · MicrosoftEdge/WebView2Feedback for some ideas and links) or 
* generate .NET Framework compatible code from your code with which that you can run the 'real' tlbexp with (not so bad, since AutoDual means you _really) should not be changing your interfaces)
* add AutoDual support to dscom, either by contribution or a fork.

-Govert

Chintu

unread,
Oct 30, 2024, 8:53:22 AM10/30/24
to Excel-DNA
Hi Govert, thanks for this. 

I have tried adding a reference to the package "dspace.runtime.interopservices.buildtasks (1.11.1) into my project. I am, however, getting an error (MSB3073) saying that the dscom.exe tlbexport exited with code 1.

Any idea what I might be doing wrong?

Raj

Chintu

unread,
Oct 31, 2024, 2:12:46 PM10/31/24
to Excel-DNA
Hi Govert, the test project works for me. The error was due to me missing out on removing the AutoDual attribute in one of the lines in my code, so my solution compiles now. 

The problem I however have is that I have lost intellisense, which I can't do without. One of my colleagues has suggested using NetStandard2.0 to create a Typelibrary file for early binding and intellisense. Are NetStandard2.0 and ExcelDNA compatible with each other? 

Many thanks

Raj

Govert van Drimmelen

unread,
Oct 31, 2024, 2:50:26 PM10/31/24
to exce...@googlegroups.com

Do you mean you’ve lost IntelliSense in the VBA, or for the UDFs when entering formulas in the sheet?

 

-Govert

--

You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.

Chintu

unread,
Oct 31, 2024, 6:36:27 PM10/31/24
to Excel-DNA
I have lost IntelliSense in VBA. 

I am basically migrating my application from .NET Framework 4.8 to .NET 8 and would like to have early binding and IntelliSense (in VBA). But the fact that TypeLibrary has been discontinued is not helping me. I would like to carry on using ExcelDNA. 

Raj

Govert van Drimmelen

unread,
Nov 1, 2024, 9:43:50 AM11/1/24
to Excel-DNA
Hi Raj,

Once you have dsCOM working right to make a type library, your IntelliSense in VBA will work as before if you define the right interfaces in the code.
Just removing the "ClassInterface.AutoDual" will mean you only have dispatch interfaces (that's because ClassInterface.AutoDispatch is the default).
So you have to define an interface explicitly and then set that as the ComDefaultInterface.

Then you get VBA IntelliSense - see the sample project I sent the link to earlier
ComIntelliSense.png

-Govert  

Chintu

unread,
Nov 12, 2024, 3:45:53 PM11/12/24
to Excel-DNA
Hi Govert, 

I am trying to replicate your methodology in the sample project you sent in my own code and I am getting a 'Class not registered' error in VBA when I try to initialise the managed object. I am pretty sure I am doing exactly what you are doing. Not been able to find the issue yet. Any suggestions? 

Many thanks

Raj

Govert van Drimmelen

unread,
Nov 12, 2024, 3:49:39 PM11/12/24
to exce...@googlegroups.com

Hi Raj,

 

Does it work right with the sample project when running on your machine?

 

If so, but your own project is still problematic, then you might need to make sure the various COM Guids are changed.

I think sometimes VBA cached type library information, and if you update your types VBA does not pick it up.

 

-Govert

 

 

From: exce...@googlegroups.com <exce...@googlegroups.com> On Behalf Of Chintu
Sent: 12 November 2024 22:46
To: Excel-DNA <exce...@googlegroups.com>
Subject: Re: [ExcelDna] Excel DNA with .NET 8

 

Hi Govert, 

 

I am trying to replicate your methodology in the sample project you sent in my own code and I am getting a 'Class not registered' error in VBA when I try to initialise the managed object. I am pretty sure I am doing exactly what you are doing. Not been able to find the issue yet. Any suggestions? 

 

Many thanks

 

Raj

On Friday, November 1, 2024 at 1:43:50PM UTC Govert van Drimmelen wrote:

Hi Raj,

 

Once you have dsCOM working right to make a type library, your IntelliSense in VBA will work as before if you define the right interfaces in the code.

Just removing the "ClassInterface.AutoDual" will mean you only have dispatch interfaces (that's because ClassInterface.AutoDispatch is the default).

So you have to define an interface explicitly and then set that as the ComDefaultInterface.

Then you get VBA IntelliSense - see the sample project I sent the link to earlier

 

-Govert  

Chintu

unread,
Nov 15, 2024, 1:33:08 PM11/15/24
to Excel-DNA
Hi Govert

Yes, your project runs fine on my machine. 

But anything new I create, doesn't work. I tried creating two separate new projects, but in both cases, i get the "Class not registered" error message.

Raj

Reply all
Reply to author
Forward
0 new messages