Exception troubles with ExcelDna.Doc

73 views
Skip to first unread message

Johan A

unread,
Jul 7, 2020, 8:39:02 AM7/7/20
to Excel-DNA
Hello,

I'm using ExcelDna in one of my Office Addin projects. I have upgraded to the latest versions of the needed ExcelDna modules

-ExcelDna 1.1.1
-ExcelDna Integration 1.1.0
-ExcelDna Intellisense 1.3.0
-ExcelDna Interop 1.4.0.1
-ExceDna Registration 1.1.0
-ExcelDna Doc 0.2.3

The project is using .Net Framework 4.8 and building for AnyCpu.

However, I can't get the ExcelDna.Doc to build properbly. This is the output in final part of the build

creating HTML Help content in C:\VS\Source\Repos\MyProj\MyProj_ExcelDNA\bin\Debug\HelpContent
5>  ExcludeHidden: False, SkipCompile: False, Async: False
5>  
5>  using local template : ProjectFileTemplate.cshtml
5>  
5>  Unhandled Exception: System.Reflection.AmbiguousMatchException: Multiple custom attributes of the same type found.
5>     at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
5>     at ExcelDnaDoc.Utility.ModelHelper.CreateFunctionModel(MethodInfo method, String defaultCategory)
5>     at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
5>     at System.Linq.Enumerable.<SelectManyIterator>d__17`
2.MoveNext()
5>     at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
5>     at System.Linq.Lookup`
2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
5>     at System.Linq.GroupedEnumerable`3.GetEnumerator()
5>     at System.Linq.Enumerable.WhereSelectEnumerableIterator`
2.MoveNext()
5>     at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
5>     at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
5>     at ExcelDna.Documentation.Models.AddInModel.<get_Functions>d__13.MoveNext()
5>     at System.Linq.Enumerable.WhereEnumerableIterator`
1.MoveNext()
5>     at CompiledRazorTemplates.Dynamic.dbadfeecadeade.Execute()
5>     at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
5>     at RazorEngine.Razor.Parse[T](String razorTemplate, T model)
5>     at ExcelDnaDoc.Templates.ViewBase`1.Publish()
5>     at ExcelDnaDoc.HtmlHelp.Create(String dnaPath, String helpSubfolder, Boolean excludeHidden, Boolean skipCompile, Boolean runAsync)
5>     at ExcelDnaDoc.Program.Main(String[] args)
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(5258,5): error MSB3073: The command ""C:\VS\Source\Repos\packages\ExcelDnaDoc.1.1.0-beta2\tools\ExcelDnaDoc.exe" "C:\VS\Source\Repos\MyProj\MyProj_ExcelDNA\bin\Debug\MyProj_ExcelDNA-AddIn.dna" /Y" exited with code -532462766.



As you can see in the output, I have also tried to upgrade to the latest pre-release version of ExcelDnaDoc, but with same result.

Please, can someone give me a clue whats wrong. This has worked fine before.

Br,
Johan


C. Augusto Proiete

unread,
Jul 7, 2020, 8:45:23 AM7/7/20
to exce...@googlegroups.com
Hi Johan,

You need to install the latest version of ExcelDnaDoc (currently pre-release 1.1.0-beta2) which is compatible with the latest ExcelDna.Integration
ExcelDnaDoc 0.2.3 is an old version that depends on ExcelDna.AddIn 0.33.9.

Install-Package ExcelDnaDoc -Pre

Cheers,
C. Augusto Proiete
https://augustoproiete.net


--
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/1b35daea-18b0-4b1f-917d-175a29266e38o%40googlegroups.com.

Johan A

unread,
Jul 7, 2020, 9:22:56 AM7/7/20
to C. Augusto Proiete, exce...@googlegroups.com
Thanks Augusto Proiete,

Maybe I didn't clearly mention it, but I already did that i.e upgrade to  ExcelDnaDoc 1.1.0-beta2.
The output is after installing the pre-release version.

Br,
Johan

C. Augusto Proiete

unread,
Jul 7, 2020, 11:54:45 AM7/7/20
to exce...@googlegroups.com
Sorry Johan, I stopped reading after you said you were using the latest versions and mentioned ExcelDnaDoc 0.2.3 at the top.

My first guess is that you might have assemblies referencing an old version of the ExcelDna.Documentation assembly or the ExcelDna.Integration assembly, and multiple versions of the same attributes (e.g. ExcelFunction) are being found by ExcelDnaDoc. Or perhaps something in your build process is copying old versions of these assemblies to the output folder. 

Are you able to reproduce this error in a project you can share?

Johan A

unread,
Jul 8, 2020, 11:05:55 AM7/8/20
to C. Augusto Proiete, exce...@googlegroups.com
Hello again Augusto Proiete,

I did as you mentioned, and made a shell project with just ExcelDna and the additional packages I have used. I just made a dummy class and some functions and used the ExcelFunctionDoc attribute to document it. 

The post build event went fine this time (ExcelDnaDoc.exe ..) and it produced a *.chm file in the target directory.

But the *.chm file is empty. I'm suspecting something still doesn't work as it should. It doesn't contain the dummy functions I made.

This is one of the function signatures

using ExcelDna.Documentation;
namespace ExcelDnaTest
{
    using ExcelDna.Integration;
    public class MyClass
    {
        [ExcelFunctionDoc(Name = "MyFunc", Description = "Returns somerthing!", Category = "Funny", Remarks = "This function can handle any double!", HelpTopic = "MyHelpFile.chm!100")]
        public double MyFunc(
            [ExcelArgument(Name = "a", Description = "is a a")] double a,
            [ExcelArgument(Name = "b", Description = "is a b")] double b,
            [ExcelArgument(Name = "c", Description = "is a c")] double c)
        {



Br,
Johan




Govert van Drimmelen

unread,
Jul 8, 2020, 11:35:52 AM7/8/20
to exce...@googlegroups.com

Hi Johan,

 

I did a quick test and all seemed OK.

The function did make it into the .chm file and everything hooked up correctly.

My build output had this part at the bottom, related to the ExcelDnaDoc – maybe you can compare:

 

1>PostBuildEvent:

1>  "C:\Test\TestDnaDocs\packages\ExcelDnaDoc.1.1.0-beta2\tools\ExcelDnaDoc.exe" "C:\Test\TestDnaDocs\bin\Debug\TestDnaDocs-AddIn.dna" /Y

1>  Started: 2020/07/08 17:34:50

1>  creating HTML Help content in C:\Test\TestDnaDocs\bin\Debug\HelpContent

1>  ExcludeHidden: False, SkipCompile: False, Async: False

1> 

1>  using local template : ProjectFileTemplate.cshtml

1>  using local template : TableOfContentsTemplate.cshtml

1>  using local template : MethodListTemplate.cshtml

1>  using local template : CategoryTemplate.cshtml

1>  using local template : FunctionTemplate.cshtml

1>  using local template : helpstyle.css

1> 

1>  creating chm file

1>  Microsoft HTML Help Compiler 4.74.8702

1> 

1> 

1> 

1>  Compiling c:\Test\TestDnaDocs\bin\Debug\HelpContent\TestDnaDocs-AddIn.chm

1> 

1> 

1> 

1> 

1> 

1>  Compile time: 0 minutes, 0 seconds

1> 

1>  3       Topics

1> 

1>  8       Local links

1> 

1>  0       Internet links

1> 

1>  0       Graphics

1> 

1> 

1> 

1> 

1> 

1>  Created c:\Test\TestDnaDocs\bin\Debug\HelpContent\TestDnaDocs-AddIn.chm, 12,198 bytes

1> 

1>  Compression increased file by 4,338 bytes.

1> 

1>  finished creating HTML Help File

1> 

1>  C:\Test\TestDnaDocs\bin\Debug\HelpContent\TestDnaDocs-AddIn.chm was moved to C:\Test\TestDnaDocs\bin\Debug\TestDnaDocs-AddIn.chm.

1> 

1>  Finished: 2020/07/08 17:34:51

1>  Successful

1>

 

-Govert

C. Augusto Proiete

unread,
Jul 8, 2020, 12:51:54 PM7/8/20
to exce...@googlegroups.com
Same here.

@Johan, make sure the function is marked as `static` otherwise neither ExcelDna or ExcelDnaDoc will find them - that's why your CHM is empty.

image.png

If you're able to reproduce in a sample project, please attach it to issue 28 on the GitHub repo:

Cheers,
C. Augusto Proiete
https://augustoproiete.net


Johan A

unread,
Jul 8, 2020, 3:19:38 PM7/8/20
to C. Augusto Proiete, exce...@googlegroups.com
Hi! 

I have finally found the culprit. 

I have in a couple of functions used the ExcelAsyncUtil.Run feature.

In the signature header I have put both ExcelFunctionDoc and ExcelAsyncFunction. For example below:

[ExcelFunctionDoc(Name = "zGasMixPReDewCurve", Description = "Returns Dew curve data for a specified gas mixture using Peng-Robinson equation of state", Category = "Chemistry", HelpTopic = "Tlib4xl.chm!2071")]
[ExcelAsyncFunction(Name = "zGasMixPReDewCurve", Description = "Returns Dew curve data for a specified gas mixture using Peng-Robinson equation of state", Category = "Chemistry", HelpTopic = "Tlib4xl.chm!2071")]
public static object zGasMixPReDewCurve(

Commenting out these functions, produces the *.chm. 

I need to just use one attribute.

Thanks for the help guys! ExcelDna rocks!

Br,
Johan


C. Augusto Proiete

unread,
Jul 8, 2020, 8:45:22 PM7/8/20
to exce...@googlegroups.com
Great! Glad you found the culprit and thanks for following-up with repro steps.


Cheers,
C. Augusto Proiete
https://augustoproiete.net


Reply all
Reply to author
Forward
0 new messages