-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
option to disable machine hive (i.e. assume always non-elevated) + pre-register ribbon [in installer] #685
Comments
Hi @jmkinzer - we've already implemented step 1 with the optional machine hive check (only when running as admin) for the next version 1.8.0. Maybe you can try the current pre-release version 1.8.0-alpha3 and confirm that it works right for you. Step 2 is a bit more tricky - It can be done with the current library, but you need to configure the ribbon a bit differently:
Each of these needs a bit more explanation. I've published a test add-in with the below code here https://github.com/govert/TestRibbonRegistration but you have to do the registration steps yourself.
<ExcelAddInComServer>true</ExcelAddInComServer> Then your ribbon class would not derive from using System;
using System.Runtime.InteropServices;
using ExcelDna.Integration;
using ExcelDna.Integration.CustomUI;
using Microsoft.Office.Interop.Excel;
namespace TestRibbonRegistration
{
internal class ComConstants
{
// Choose your own ProgId and a new Guid here
public const string RibbonProgId = "TestRibbonRegistration.MyCustomRibbon";
public const string RibbonGuid = "E595901B-903E-4FE7-8D06-6E7F3D5A2C4F";
// This is the Guid for the IRibbonExtensibility interface - don't change this
public const string IRibbonExtensibilityGuid = "000C0396-0000-0000-C000-000000000046";
}
[ComVisible(true)]
[ComImport]
[Guid(ComConstants.IRibbonExtensibilityGuid)]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
internal interface IRibbonExtensibility
{
[DispId(1)]
string GetCustomUI(string RibbonID);
}
[ProgId(ComConstants.RibbonProgId)]
[Guid(ComConstants.RibbonGuid)]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class MyCustomRibbon : ExcelComAddIn, IRibbonExtensibility
{
public string GetCustomUI(string RibbonID)
{
return
@"<customUI xmlns='http://schemas.microsoft.com/office/2006/01/customui'>
<ribbon>
<tabs>
<tab id='tab1' label='My Tab' >
<group id='group1' label='My Group'>
<button id='button1' label='My Button' onAction='OnButtonPressed' />
</group >
</tab>
</tabs>
</ribbon>
</customUI>";
}
public void OnButtonPressed(IRibbonControl control)
{
var app = (Application)ExcelDnaUtil.Application;
app.StatusBar = "Button Pressed!";
}
}
}
In my test I just run from a (non-admin) command line:
using ExcelDna.Integration;
using Microsoft.Office.Core;
using Microsoft.Office.Interop.Excel;
namespace TestRibbonRegistration
{
public class AddIn : IExcelAddIn
{
public void AutoOpen()
{
// It's better if we don't load other add-ins during the AutoOpen method
// So we schedule the ribbon load to run after the add-in is initialized,
// when Excel is idle again.
ExcelAsyncUtil.QueueAsMacro(() => RegisterRibbon());
}
public void AutoClose()
{
}
public void RegisterRibbon()
{
var app = (Application)ExcelDnaUtil.Application;
var progId = ComAPI.RibbonProgId;
// Enumerate the registered add-ins, and load the one with the right ProgId
foreach (COMAddIn addIn in app.COMAddIns)
{
if (addIn.ProgId == progId)
{
addIn.Connect = true;
break;
}
}
}
}
} |
@govert - This is fantastic! I really appreciate your taking the time to put this together. I have upgraded to 1.8.0a3 and will now give this approach a try. Thanks again. |
@govert - I confirm this approach resolves the issues. Thanks again! The one major headache I had revolved around Wix (which I've decided I hate) and COM server registration. This was related to the fact that while I could easily get the DllRegisterServer approach to work, when using Wix that failed in the installer for some reason while trying to just replicate the registry entries never worked out. I skimmed articles about running heat and harvesting reg entries but I couldn't master the arcane Wix incantations so to end the pain quickly I just whipped up a self-contained .net app that performs all the various registrations and can be called out from Wix or just run standalone. Not sure if this is a totally kosher approach but it seems to work flawlessly in my environment (and at least I can troubleshoot it). Attaching the various helpers in case it's useful.
(Note I was only concerned with x64 installs but it could be extended easily to support both) |
And fwiw if one decides to make a standalone exe to be called by Wix the following should help. It would definitely be better to have this as just part of the CA but as noted I had difficult-to-debug issues with the ComServer registration with that approach...
|
The ribbon portion of the addin causes excel to crash on various corporate machine running 365. It's related to the ribbon registration although it's hard to say what the root-cause is (after monkeying around the error tends to vanish and then cannot be re-introduced). I believe this suggestion however is along the lines need to resolve it:
#317 (comment)
These two steps would probably prevent any possible problems here:
The text was updated successfully, but these errors were encountered: