"Repeated Function Name" warning with ExcelDna.Registration.VisualBasic PerformDefaultRegistration()

1,087 views
Skip to first unread message

Daniel T

unread,
Nov 27, 2016, 10:34:08 PM11/27/16
to Excel-DNA
Steps to reproduce:
  • Create new Class project
  • Install packages:
PM>Install-Package ExcelDNA.Addin
PM
>
Install-Package ExcelDNA.Registration.VisualBasic

  • Test code:
Imports ExcelDna.Integration
Imports ExcelDna.Registration.VisualBasic

Public Module Module1
    <ExcelFunction>
    Public Function SayHello(Optional aName As String = "Bill")
        Return "Hello" & aName
    End Function
End Module

Public Class MyAddin
    Implements IExcelAddIn

    Public Sub AutoOpen() Implements IExcelAddIn.AutoOpen
        PerformDefaultRegistration()
    End Sub

    Public Sub AutoClose() Implements IExcelAddIn.AutoClose
    End Sub

End Class

When I open in Excel, it produces a Diagnostic Display warning:

Registration [Error] Repeated function name: 'SayHello' - previous registration will be overwritten.


If I comment out `PerformDefaultRegistration()` then the warning disappears but the optional argument default values don't work any more.

I'm guessing that registration is being performed twice, once the "normal" way and once the ExcelDna.Registration.VisualBasic way, but I can't figure out how to disable the "normal" registration.

Any help appreciated.

Daniel T

unread,
Nov 28, 2016, 1:01:49 AM11/28/16
to Excel-DNA
I found a couple of workarounds; any of the following work:

(1) add to each <ExcelFunction()> definition:
ExplicitRegistration:=True,

(2) add to each <ExcelFunction()> definition:
SuppressOverwriteError:=True

(3) add ExplicitRegistration='true' to the .dna file eg

<ExternalLibrary Path='MyAddin.dll' LoadFromBytes='true' Pack='true' ExplicitExports='true' ExplicitRegistration='true' />


The last option appears to be the best; any potential side-effects?  Perhaps this should be either automated as part of Install-Package ExcelDNA.Registration.VisualBasic, or added to the ExcelDNA.Registration.VisualBasic documentation?  I see it's already included in https://github.com/Excel-DNA/Registration/blob/master/Source/Samples/Registration.Sample.VisualBasic/Registration.Sample.VisualBasic-AddIn.dna.


Govert van Drimmelen

unread,
Nov 28, 2016, 4:05:26 AM11/28/16
to exce...@googlegroups.com

Hi Daniel,

 

Everything you’ve said is correct. It’s a bit clumsy due to the historical evolution of the library, and me wanting to maintain backward compatible behaviour.

 

The intention, for normal use, is option (3), where you set ExplicitRegistration=true in the .dna file when using the Registration extension, if you will be doing the default processing – this is reflected in the Registration sample projects.

It would indeed be nice to have that applied by the NuGet package, or at least have some usage guidelines…

 

By default, a function marked with an [ExcelFunction] will be registered (i.e. it will have ExplicitRegistration=false for that function. However, the [ExcelAsyncFunction] attribute in the Registration extension overrides this default property value, and sets ExplicitRegistration=true. I think I did this because we expect such functions to have a compatible signature with Excel (e.g. return “double”), but to be registered explicitly with the generated async wrapper. So the apparent discrepancy is intended, but nothing too strange is going on.

 

-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 post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Daniel T

unread,
Nov 28, 2016, 6:38:20 AM11/28/16
to Excel-DNA
Thanks Govert, love your work.

I'm afraid the nuspec stuff is beyond me but if I get time I'll add something to https://github.com/Excel-DNA/Registration/blob/master/README.md.

Daniel

Govert van Drimmelen

unread,
Nov 28, 2016, 7:38:31 AM11/28/16
to exce...@googlegroups.com

Hi Daniel,

 

Thank you – updating the Readme would already help the next person in your position.

 

Regards,

Daniel T

unread,
Nov 28, 2016, 8:51:48 AM11/28/16
to Excel-DNA


On Monday, November 28, 2016 at 10:38:31 PM UTC+10, Govert van Drimmelen wrote:

Hi Daniel,

 

Thank you – updating the Readme would already help the next person in your position.

 

Regards,

Govert

 

Govert van Drimmelen

unread,
Nov 28, 2016, 11:13:28 AM11/28/16
to exce...@googlegroups.com

Thanks Daniel – I’ve added the comment.

 

-Govert

 

From: exce...@googlegroups.com [mailto:exce...@googlegroups.com] On Behalf Of Daniel T
Sent: 28 November 2016 15:52
To: Excel-DNA <exce...@googlegroups.com>
Subject: Re: [ExcelDna] Re: "Repeated Function Name" warning with ExcelDna.Registration.VisualBasic PerformDefaultRegistration()

 

--

Fabian

unread,
Dec 7, 2016, 3:55:19 PM12/7/16
to Excel-DNA
I've been having similar issues with Registration v0.33.9; 
just to confirm, setting ExplicitRegistration="true" ExplicitExports="true" in the .dna should override any of the [ExcelFunction]-attributes' values for ExplicitRegistration, right?

My .dna file begins as follows,

<DnaLibrary Name="etcetc" ExplicitRegistration="true" ExplicitExports="true" RuntimeVersion="v4.0">

however all my functions marked with [ExcelFunction] attributes do seem to be registered automatically before I do the manual registration. Only adding ExplicitRegistration = true to the ExcelFunction-Attributes does successfully prevent automatic registration.

My impression was setting this on the attributes shouldn't be necessary due to the .dna setup - or is this expected behavior?
This is under Excel 2013 64-bit. 

Govert van Drimmelen

unread,
Dec 7, 2016, 4:02:04 PM12/7/16
to exce...@googlegroups.com
Hi Fabian,

You need to set ExplicitRegistration='true' on the <ExternalLibrary ... /> tag(s), and not the root <DnaLibrary ...> tag.
There were some reasons for this, but I can't recall right now.

-Govert



From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Fabian [f.me...@gmail.com]
Sent: 07 December 2016 10:55 PM
To: Excel-DNA

Fabian

unread,
Dec 7, 2016, 4:06:07 PM12/7/16
to Excel-DNA
Ah, thanks Govert. Completely missed that - works very well now.

Thanks
Fabian
To post to this group, send email to exc...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages