Trying to get the DnaComServer sample to work by modifying the Project file

91 views
Skip to first unread message

Corku

unread,
Sep 25, 2023, 7:06:04 AMSep 25
to Excel-DNA
Dear All..

I tried to build the DnaComServer sample by modifying the Excel-DNA properties in SDK-style project files.

But no matter where I put the TlbExp.exe file, I get "The system cannot find the file specified" error

DNA1269553310 Error.jpg

Will be nice to solve this puzzle. 
Thanks




Corku

unread,
Sep 25, 2023, 4:44:33 PMSep 25
to Excel-DNA
How is this property getting its value?

/// <summary>
/// Path to TlbExp.exe
/// </summary>
public string TlbExp { get; set; }

From the CreateExcelAddIn.cs file.

Thanks

Govert van Drimmelen

unread,
Sep 26, 2023, 4:49:50 AMSep 26
to Excel-DNA

--------------------------------------------------
Enjoying our project?

Consider supporting its continued development by becoming a GitHub Sponsor.

Your help ensures we can keep improving and assisting you.

--------------------------------------------------


I'm sorry you have to deal with this puzzle - the samples and documentation about this clearly need some updating.

The TlbExp path is set from that ExcelAddInTlbExp property. I suggest you start with the full path explicitly in the property - this worked for me:

  <PropertyGroup>
    <ExcelAddInTlbExp>C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbExp.exe</ExcelAddInTlbExp>
    <ExcelAddInTlbCreate>true</ExcelAddInTlbCreate>
    <ExcelAddInComServer>true</ExcelAddInComServer>
  </PropertyGroup>

If using the project path variable doesn't work, you might need some more detailed diagnostics from the build to see how the path is expanded.

You can also use DsCom (a replacement for TlbExp that runs under .NET core) to generate the .tlb file.
Try it like this in your project file:

  <ItemGroup>
    <PackageReference Include="ExcelDna.Addin" Version="1.7.0-rc6" />
    <PackageReference Include="dSpace.Runtime.InteropServices.BuildTasks" Version="0.23.4" />
  </ItemGroup>

  <PropertyGroup>
    <ExcelAddInTlbCreate>true</ExcelAddInTlbCreate>
    <ExcelAddInComServer>true</ExcelAddInComServer>
  </PropertyGroup>

-Govert


Corku

unread,
Sep 26, 2023, 6:44:39 AMSep 26
to Excel-DNA
Dear Govert,

Thanks for the assistance. Very much appreciated.
I tried both the orig com and the dscom versions and l still get the same error.
com version.jpg

and 

dscom version.jpg
The fun continues ..
Drawing blank on what to do next..

Corku

unread,
Sep 26, 2023, 7:13:00 AMSep 26
to Excel-DNA
Dear Govert,

looks like the DsCom version returns an empty string for the type library path..

dscom version empty string.jpg

Govert van Drimmelen

unread,
Sep 26, 2023, 7:31:30 AMSep 26
to exce...@googlegroups.com
I think that's expected - the DsCom is alternative to TlbExp.

-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 on the web visit https://groups.google.com/d/msgid/exceldna/67008aa5-1776-4967-b6a3-e0af6bbc7249n%40googlegroups.com.

Corku

unread,
Sep 26, 2023, 2:29:37 PMSep 26
to Excel-DNA
This a part of the diagnostics report.. 

1>  Using "CreateExcelAddIn" task from assembly "C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\net452\ExcelDna.AddIn.Tasks.dll".
1>  Task "CreateExcelAddIn"
1>    Task Parameter:CompressResources=True
1>    Task Parameter:TlbCreate=True
1>    Task Parameter:ComServer=True
1>    Task Parameter:Xll32FilePath=C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\\net6.0-windows7.0\ExcelDna.xll
1>    Task Parameter:TlbExp=C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\TlbExp.exe
1>    Task Parameter:PackIsEnabled=True
1>    Task Parameter:OutDirectory=bin\Debug\net6.0-windows\
1>    Task Parameter:TargetFileName=DnaComServer.dll
1>    Task Parameter:Xll64FilePath=C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\\net6.0-windows7.0\ExcelDna64.xll
1>    Task Parameter:TlbDscom=True
1>    Task Parameter:TemplateDnaPath=C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\content\ExcelDna-Template.dna
1>    Task Parameter:Create32BitAddIn=True
1>    Task Parameter:ProjectName=DnaComServer
1>    Task Parameter:IntegrationDllPath=C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\\net6.0-windows7.0\ExcelDna.Integration.dll
1>    Task Parameter:PackedFileSuffix=-packed
1>    Task Parameter:FileSuffix64Bit=64
1>    Task Parameter:Create64BitAddIn=True
1>    Task Parameter:
1>        FilesInProject=
1>            Properties\launchSettings.json
1>                    CopyToOutputDirectory=Never
1>    ExcelDnaBuild: Running CreateExcelAddIn MSBuild Task
1>    ExcelDnaBuild: ----Arguments----
1>    ExcelDnaBuild: FilesInProject: 1
1>    ExcelDnaBuild:   Properties\launchSettings.json
1>    ExcelDnaBuild: OutDirectory: bin\Debug\net6.0-windows\
1>    ExcelDnaBuild: Xll32FilePath: C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\\net6.0-windows7.0\ExcelDna.xll
1>    ExcelDnaBuild: Xll64FilePath: C:\Users\corku\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\\net6.0-windows7.0\ExcelDna64.xll
1>    ExcelDnaBuild: Create32BitAddIn: True
1>    ExcelDnaBuild: Create64BitAddIn: True
1>    ExcelDnaBuild: FileSuffix32Bit:
1>    ExcelDnaBuild: FileSuffix64Bit: 64
1>    ExcelDnaBuild: -----------------
1>    ExcelDnaBuild: Number of files in project: 1
1>    MSBUILD : ExcelDnaBuild error DNA126955310: The system cannot find the file specified
1>    MSBUILD : ExcelDnaBuild error DNA126955310: System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
1>    MSBUILD : ExcelDnaBuild error DNA126955310:    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
1>    MSBUILD : ExcelDnaBuild error DNA126955310:    at ExcelDna.AddIn.Tasks.Utils.ProcessRunner.Run(String fileName, String arguments, String appName, IBuildLogger log)
1>    MSBUILD : ExcelDnaBuild error DNA126955310:    at ExcelDna.AddIn.Tasks.CreateExcelAddIn.TryCreateTlb()
1>    MSBUILD : ExcelDnaBuild error DNA126955310:    at ExcelDna.AddIn.Tasks.CreateExcelAddIn.Execute()
1>  Done executing task "CreateExcelAddIn" -- FAILED.
1>Done building target "ExcelDnaBuild" in project "DnaComServer.csproj" -- FAILED.

All seems to be ok.. to my newbie eyes.. but since all seems to be working well for you,, I might be doing something wrong!
The fun continues!

Govert van Drimmelen

unread,
Sep 26, 2023, 3:07:16 PMSep 26
to Excel-DNA
I found some sources of confusion.
* I had the "dscom" tool installed on my machine (as a "dotnet tool") and that made some things work here that might not work for you.
I have uninstalled the tool now.

* If you are targeting .NET 6 (which you are), TlbExp would never be used and ExcelAddInTlbExp bill be ignored.
Instead, if you have <ExcelAddInTlbCreate>true</ExcelAddInTlbCreate> set, then the build will attempt to just run "dscom" as a spawned process. That's the file not being found on your machine, but which worked on mine because I had the "dscom" tool installed.

* This project works for me (now without the dscom tool installed), but I have to build twice (I think that's a bug).
I updated the dsCom PackageReference version, not sure if this is needed:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
</PropertyGroup>

  <ItemGroup>
    <PackageReference Include="ExcelDna.Addin" Version="1.7.0-rc6" />
    <PackageReference Include="dSPACE.Runtime.InteropServices.BuildTasks" Version="1.2.0" />
  </ItemGroup>
  <PropertyGroup>
    <ExcelAddInComServer>true</ExcelAddInComServer>
  </PropertyGroup>
</Project>

* The first time I build, I see in the build output that the TyepLib is not packed , but that it is generated after the packing step.
When I then rebuild, the .tlb file is already present when the packing step runs, and it is packed (I presume the one from the previous build) and then the tlb is generated again.

We'll investigate the build sequence a bit, but you might be able to get it working like this.

-Govert

Corku

unread,
Sep 27, 2023, 5:39:13 AMSep 27
to Excel-DNA
Thanks again.. It worked!
Have an awesome day!

Corku

unread,
Sep 27, 2023, 6:43:10 AMSep 27
to Excel-DNA
Dear Govert..

Looks like the fun continues..
The TypeLib is not being generated.. on my machine.
The late bound VBA code works but I cannot Tools - Reference the  **AddIn-packed.xll file

Do I need to install the DsCom tool for this to work?

Thanks..

Govert van Drimmelen

unread,
Sep 27, 2023, 7:05:19 AMSep 27
to exce...@googlegroups.com

I can get the .tlb to be created (seemingly correctly) and packed into the .xll.

But when I Tools -> Reference the .xll in VBA it doesn’t show an error, but doesn’t get added as a reference either.

So there are definitely some tricks I don’t get yet.

 

Anyway, your first problem may be that you are running into one problem I mentioned in my previous response

 

* The first time I build, I see in the build output that the TyepLib is not packed , but that it is generated after the packing step.

When I then rebuild, the .tlb file is already present when the packing step runs, and it is packed (I presume the one from the previous build) and then the tlb is generated again.

 

We'll investigate the build sequence a bit, but you might be able to get it working like this.

 

You can see in the build output whether the ExcelDnaPack task is putting the TypeLib into the .xll or not.

It looks like the build process is only making the typelib after the packing, so you have to build twice to get the typelib into the packed .xll.

You’ll then see this:

 

1>  Task "PackExcelAddIn"

1>    PackExcelAddIn: Running PackExcelAddIn Task

1>    PackExcelAddIn: Using base add-in bin\Debug\net6.0-windows\NewComServer-AddIn64.xll

1>    PackExcelAddIn:   ~~> ExternalLibrary path NewComServer.dll resolved to bin\Debug\net6.0-windows\NewComServer.dll.

1>    Assembly loaded during TaskRun (ExcelDna.AddIn.Tasks.PackExcelAddIn): NewComServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (location: , MVID: de144b3f-b9e9-4f33-9c50-96e365b1a85c, AppDomain: [Default])

1>    PackExcelAddIn:   ~~> ExternalLibrary typelib path  resolved to bin\Debug\net6.0-windows\NewComServer.tlb.

1>    PackExcelAddIn:   ->  Updating typelib: Type: TYPELIB, Index: 1, Length: 2796

1>    PackExcelAddIn:   ->  Updating resource: Type: DNA, Name: __MAIN__, Length: 597

1>    PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: NEWCOMSERVER, Length: 4170

1>    PackExcelAddIn: Completed Packing bin\Debug\net6.0-windows\publish\NewComServer-AddIn64-packed.xll.

1>  Done executing task "PackExcelAddIn".

 

Even after that, I’m not sure it will work . . .

 

I’ll check further as I get a chance.

 

-Govert

 

 

From: exce...@googlegroups.com <exce...@googlegroups.com> On Behalf Of Corku
Sent: Wednesday, September 27, 2023 12:43 PM
To: Excel-DNA <exce...@googlegroups.com>
Subject: [ExcelDna] Re: Trying to get the DnaComServer sample to work by modifying the Project file

 

Dear Govert..

 

Looks like the fun continues..

The TypeLib is not being generated.. on my machine.

The late bound VBA code works but I cannot Tools - Reference the  **AddIn-packed.xll file

 

Do I need to install the DsCom tool for this to work?

 

Thanks..

 

 

On Wednesday, September 27, 2023 at 12:39:13 PM UTC+3 Corku wrote:

Thanks again.. It worked!

Have an awesome day!

 

 

On Tuesday, September 26, 2023 at 1:44:39 PM UTC+3 Corku wrote:

Dear Govert,

 

Thanks for the assistance. Very much appreciated.

I tried both the orig com and the dscom versions and l still get the same error.

 

and 

 


The fun continues ..

 

Will be nice to solve this puzzle. 

Thanks

 

 

 

 

--

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.

Govert van Drimmelen

unread,
Sep 27, 2023, 7:22:41 AMSep 27
to Excel-DNA
Ah - I see that in the VBA Tools -> Reference you need to Browse to the .xll, then it adds it to the list but does not 'check' it, so you have to find the library on the list and 'check' it.
Then it works as expected.

-Govert

Corku

unread,
Sep 27, 2023, 8:11:19 AMSep 27
to Excel-DNA
Looks like the Type Library is not being generated at all so the .xll file reference just throws an error.
This is how that section of my build output looks like..

 PackExcelAddIn: Running PackExcelAddIn Task
1>    PackExcelAddIn: Using base add-in bin\Debug\net6.0-windows\DnaComServer-AddIn64.xll
1>    PackExcelAddIn:   ~~> ExternalLibrary path DnaComServer.dll resolved to bin\Debug\net6.0-windows\DnaComServer.dll.
1>    Assembly loaded during TaskRun (ExcelDna.AddIn.Tasks.PackExcelAddIn): DnaComServer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null (location: , MVID: c95582a3-5023-4c19-8bf0-cac8cacc4dca, AppDomain: [Default])
1>    PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: DNACOMSERVER, Length: 2073
1>    Assembly loaded during TaskRun (ExcelDna.AddIn.Tasks.PackExcelAddIn): dSPACE.Runtime.InteropServices, Version=1.0.0.0, Culture=neutral, PublicKeyToken=55bd5922db0a12f2 (location: , MVID: 9c0a3157-f511-4cbf-93e1-c8968bb7da1c, AppDomain: [Default])
1>    PackExcelAddIn:   ->  Updating resource: Type: DNA, Name: __MAIN__, Length: 574
1>    PackExcelAddIn:   ->  Updating resource: Type: ASSEMBLY_LZMA, Name: DSPACE.RUNTIME.INTEROPSERVICES, Source: Managed deps.json, Length: 42343
1>    PackExcelAddIn: Completed Packing bin\Debug\net6.0-windows\publish\DnaComServer-AddIn64-packed.xll.

1>  Done executing task "PackExcelAddIn". 

Govert van Drimmelen

unread,
Sep 27, 2023, 11:20:55 AMSep 27
to exce...@googlegroups.com

The first time I build (with a clean output directory) I also don’t get the .tlb packed. But it does create the .tlb in a task a bit later.

That part looks like this:

 

1>Target ExcelDnaDscomIntegration:

1>Target DsComExportTypeLibraryAfterBuild:

1>  Building target "DsComExportTypeLibraryAfterBuild" completely.

1>  Output file "C:\Temp\NewComServer\bin\Debug\net6.0-windows\\NewComServer.tlb" does not exist.

1>  Task "Message"

1>    Calling dscom.exe to export type library

1>  Done executing task "Message".

1>  Task "Message"

1>    Using arguments '      tlbexport --asmpath "C:\Users\GovertvanDrimmelen\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\net452"   C:\Temp\NewComServer\bin\Debug\net6.0-windows\NewComServer.dll  --out "C:\Temp\NewComServer\bin\Debug\net6.0-windows\\NewComServer.tlb"' to call dscom

1>  Done executing task "Message".

1>  Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

1>  Task "Exec"

1>    C:\Users\GovertvanDrimmelen\.nuget\packages\dspace.runtime.interopservices.buildtasks\1.2.0\build\..\tools\x64\dscom.exe       tlbexport --asmpath "C:\Users\GovertvanDrimmelen\.nuget\packages\exceldna.addin\1.7.0-rc6\build\..\tools\net452"   C:\Temp\NewComServer\bin\Debug\net6.0-windows\NewComServer.dll  --out "C:\Temp\NewComServer\bin\Debug\net6.0-windows\\NewComServer.tlb"

1>  Done executing task "Exec".

1>  Task "Warning" skipped, due to false condition; (!Exists('$(_DsComExportTypeLibraryTargetFile)')) was evaluated as (!Exists('C:\Temp\NewComServer\bin\Debug\net6.0-windows\\NewComServer.tlb')).

 

Then in the output directory I can see the .tlb.

The next time I build, it then packs it in the .xll.

 

Can you see whether that DsComExportTypeLibraryAfterBuild runs on your side?

Corku

unread,
Sep 28, 2023, 6:37:29 AMSep 28
to Excel-DNA
Dear Govert,

Am glad to report that it finally worked.
Like you, I had to build twice for the .tlb file to be packed.
This is how my project file looks like.
 
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0-windows</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>

    <PackageReference Include="dSPACE.Runtime.InteropServices.BuildTasks" Version="1.2.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="ExcelDna.AddIn" Version="1.7.0-rc6" />

  </ItemGroup>

  <PropertyGroup>
    <ExcelAddInComServer>true</ExcelAddInComServer>
  </PropertyGroup>

</Project>

Thanks again.. for a NewB ..this has been a fun ride..




Govert van Drimmelen

unread,
Sep 28, 2023, 2:49:08 PMSep 28
to exce...@googlegroups.com

I’m glad you have it working.

Do you need the extra settings on the dSpace package reference – I removed that without obvious consequences.

Corku

unread,
Sep 29, 2023, 4:16:23 AMSep 29
to Excel-DNA
No,  the extra settings on the dSpace package reference are not needed – I also removed them without obvious consequences.
We still need to rebuild twice before the typelib gets packed.

Its been a real deep fun ride..
Thanks

Govert van Drimmelen

unread,
Oct 7, 2023, 7:05:39 PMOct 7
to Excel-DNA
With version 1.7.0-rc7 of the ExcelDna.AddIn package we adjust the build dependencies, so the double build is no longer needed.

-Govert
Reply all
Reply to author
Forward
0 new messages