add multiple dll with their own customUI

90 views
Skip to first unread message

Mingcheng Qu

unread,
Sep 19, 2018, 10:40:47 AM9/19/18
to Excel-DNA

At first I tried to add child.dll as ExternalLibrary which did not have customUI, and they can work well together.


And then, I tried to add customUI in child.dll. There are the ribbon code for both child and parent.

namespace Child.Excel
{
    [ComVisible(true)]
    public class ChildRibbonHandler : ExcelRibbon, IDisposable
    {

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
        }
        public static ExcelDna.Integration.CustomUI.IRibbonUI myRibbon;
        public override string GetCustomUI(string RibbonID)
        {

            return @"
                <customUI xmlns='http://schemas.microsoft.com/office/2009/07/customui' loadImage='LoadImage' onLoad='ChildRibbon_onLoad'>
                  <ribbon>
                    <tabs>
                      <tab id='ChildTab' label='Child'>
                        <group id='TestGroup' label='Test'>
                          <button id='Test' label='Test' keytip='T' imageMso='AdpPrimaryKey' size='large' />
                        </group>
                      </tab>
                    </tabs>
                  </ribbon><backstage onShow='Backstage_onShow'/>
                </customUI>";
        }

    }
}

namespace Parent.Excel
{
    [ComVisible(true)]
    public class ParentRibbonHandler : ExcelRibbon, IDisposable
    {

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        protected virtual void Dispose(bool disposing)
        {
        }
        public static ExcelDna.Integration.CustomUI.IRibbonUI myRibbon;
        public override string GetCustomUI(string RibbonID)
        {

            return @"
                <customUI xmlns='http://schemas.microsoft.com/office/2009/07/customui' loadImage='LoadImage' onLoad='ParentdRibbon_onLoad'>
                  <ribbon>
                    <tabs>
                      <tab id='ParentTab' label='Parent'>
                        <group id='TesttGroup' label='Testt'>
                          <button id='Testt' label='Testt' keytip='E' imageMso='AdpPrimaryKey' size='large' />
                        </group>
                      </tab>
                    </tabs>
                  </ribbon><backstage onShow='Backstage_onShow'/>
                </customUI>";
        }

    }
}



This is my .dna file

<DnaLibrary Name="Parent Add-In" RuntimeVersion="v4.0">
  <ExternalLibrary Path="Parent.dll" LoadFromBytes="true" Pack="true" ExplicitExports="true" />
  <ExternalLibrary Path="Child.dll" LoadFromBytes="true" Pack="true" ExplicitExports="true" />
</DnaLibrary>



This is error I got, when I enable the addin

Initialization [Error] Method not registered - unsupported
signature
, abstract or generic: 'ArrayResizer.Resize'

ComAddIn [Error] The Ribbon/COM add-in helper required by
add
-in Parent Add-In could not be registered.


This is an unexpected error.


Error details: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException: Operation aborted (Exception from
HRESULT
: 0x80004004 (E_ABORT))


   --- End of inner
exception stack trace
---


   at
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[]
namedParameters
)


   at
System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder
binder
, Object target, Object[] providedArgs, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParams)


   at
ExcelDna.Integration.ExcelComAddInHelper.LoadComAddIn(ExcelComAddIn addIn) :
TargetInvocationException - Exception has been thrown by the target of an
invocation
.


ComAddIn [Error] The Ribbon/COM add-in helper required by
add
-in Parent Add-In could not be registered.


This is an unexpected error.


Error details: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException: Operation aborted (Exception from
HRESULT
: 0x80004004 (E_ABORT))


   --- End of inner
exception stack trace
---



Do you guys know how to correctly add multiple dll with their own customUIs? It is hard to find some sample similar with that. 


Thank you very much.

Govert van Drimmelen

unread,
Sep 19, 2018, 10:56:20 AM9/19/18
to exce...@googlegroups.com

I would expect this to work fine.

 

Could you make a little solution with the two projects, add-in etc. that I can just load and run to find the problem?

Easiest is if you put on GitHub someehere, but you can post .zip file here too.

 

-Govert

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

Excel-DNA: Free and easy .NET for Excel

Develop Excel Conference - London, 18 October 2018

https://developexcel.wordpress.com/

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

--
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.

Mingcheng Qu

unread,
Sep 19, 2018, 11:44:37 AM9/19/18
to Excel-DNA
I tried to make a new parent skeleton code again, and it works well. I think it is something wrong with my code for parent. 

But I still have an other question. Is that possible to have the child addin to add some buttons in parent UI tab? Right now I can only create separate tabs. 

Govert van Drimmelen

unread,
Sep 19, 2018, 11:50:16 AM9/19/18
to exce...@googlegroups.com

Yes – you can add buttons etc. to other tabs.

Look at the SharedGroup examples here: https://github.com/Excel-DNA/ExcelDna/tree/master/Distribution/Samples/Ribbon

Mingcheng Qu

unread,
Sep 19, 2018, 4:51:46 PM9/19/18
to Excel-DNA
Thank Govert for quick replying.

I fixed the error above which because of excel dna functions does not support option parameter.

I tried the example you above. By using both idMso="TabAddIns", I am able to merge both of addin UI together in one tab. However, I don't want the default group and button in TabAddIns.
However, it did not work so well, It still only show one button in the tab, and second did not appear.

Do you have any examples for tab using idQ, or some other ways to get rid of default groups and buttons in TabAddIns ?

Thank you very much for the help.

Govert van Drimmelen

unread,
Sep 21, 2018, 3:02:08 AM9/21/18
to exce...@googlegroups.com
Could you post the changes you've made to the SharedGroup samples which don't behave as you expect?

-Govert


From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of Mingcheng Qu [qmc...@gmail.com]
Sent: 19 September 2018 10:51 PM
To: Excel-DNA

Mingcheng Qu

unread,
Sep 21, 2018, 10:29:48 AM9/21/18
to Excel-DNA
Shared group 1
<tabs>
                      <tab idMso='TabAddIns' label='My Tab'>
                        <group idQ='x:Contoso' label='Contoso'>
                          <button id='C1' label='Child' imageMso='AdpPrimaryKey' size='large' />
                        </group>
                      </tab>
                    </tabs>

Shared Group 2

<tabs>
                      <tab idMso='TabAddIns' label='My Tab'>
                        <group idQ='x:Contoso' label='Contoso'>
                          <button id='C2' label='Parent' imageMso='AdpPrimaryKey' size='large' />
                        </group>
                      </tab>
                    </tabs>

This the result. It is good that two button is under same group and same tab from two addin. However, I don't want the default buttons there.
Capture.PNG




I also tried with use tab idQ, but it will not show up any tabs in excel. 
If I use same tab id, it will create two same tab.
do you any ways that I can merge two tabs nicely without the default buttons?
To post to this group, send email to exc...@googlegroups.com.

Mingcheng Qu

unread,
Sep 21, 2018, 10:33:02 AM9/21/18
to Excel-DNA

theTabs.PNG


I posted the wrong capture, this is the right one.

Govert van Drimmelen

unread,
Sep 21, 2018, 10:40:42 AM9/21/18
to exce...@googlegroups.com
You are overriding the built-in AddIns tab by setting idMso='TabAddIns' and that's why you're see the ribbon pieces from another add-in in the same tab.

Rather make your own tab (in both xml parts):

    <tab idQ='x:Contoso' label='My Tab'>

and go on from there.

-Govert



Sent: 21 September 2018 04:29 PM

Mingcheng Qu

unread,
Sep 21, 2018, 11:22:11 AM9/21/18
to Excel-DNA
Thanks, it looks working now.
<tab idQ='x:ContosoTab' label='My Tab'>
                        <group idQ='x:Contoso' label='Contoso'>
                          <button id='C2' label='Parent' imageMso='AdpPrimaryKey' size='large' />
                        </group>
                      </tab>

<tab idQ='x:ContosoTab' label='My Tab'>
                        <group idQ='x:Contoso' label='Contoso'>
                          <button id='C1' label='Child' imageMso='AdpPrimaryKey' size='large' />
                        </group>
                      </tab>

But the tab idQ and group idQ have to be different. Then it shows well.

Thanks you very much

Reply all
Reply to author
Forward
0 new messages