ImageMSO addin not working in Office365

339 views
Skip to first unread message

Jake

unread,
Mar 15, 2021, 6:51:33 AM3/15/21
to Excel-DNA
Hello,

I am trying to get an Excel Addin that allows you to export Excel icons (ImageMsos) to work. The project is hosted in CodePlex: https://archive.codeplex.com/?p=imagemso

The addin is built using Excel DNA and is using .NET 2.0. The addin loads fine in Excel 2013, but it fails without showing any error in Excel 365. I tried to update it to the latest version of Excel DNA by replacing the following files with the updated versions from your GitHub distribution folder: 
ExcelDna.dna
ExcelDna64.dna
ExcelDna.xll
ExcelDna64.xll
ExcelDnaPack.exe 

After using the updated dlls, I saw that I also had to update the projects to use at least .NET 4.5 which I did. The rebuilt xll file works fine in Excel 2013 and this time in Excel 365 it shows this error message instead of failing silently:

Initialization [Warning] Assembly SYSTEM.XMLSERIALIZERS could not be loaded from resources.
Initialization [Error] DnaLibrary AutoOpen Error : TargetInvocationException - Exception has been thrown by the target of an invocation.

Do you have any idea what I can do to get this working? I am not really all that familiar with ExcelDNA.

On a side note, CodePlex, where this is hosted, says that it is shutting down on July 1st. It would be good if someone could re-host this on GitHub if they can get it working on Office365. I am sure that being able to export ImageMso's would be useful for all Excel developers.

Thanks for your help.


Govert van Drimmelen

unread,
Mar 15, 2021, 8:31:05 AM3/15/21
to exce...@googlegroups.com

Hi Jake,

 

I’ve updated the Excel-DNA parts of the project and pushed to GitHub here: https://github.com/govert/ImageMso

 

It compiles but gives an error when running.

Maybe you’d like to have a look now, or I can try to go a bit further later.

 

-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/aec70e00-7d43-47fb-84d5-545341c3f337n%40googlegroups.com.

Jake

unread,
Mar 15, 2021, 7:26:28 PM3/15/21
to Excel-DNA
Hi Govert,

Thanks for your reply. I think you must have setup your repo as private because the link doesn't work and 404s (you can test in an incongnito browser). I would appreciate if you could also look into it further as I was not able to  successfully attach the debugger. Also, I tried wrapping the code in AutoOpen in a try/catch and putting a MessageBox.Show as the first function call in AutoOpen and I get the same TargetInvocationException error and the message box never shows so it is like AutoOpen is never even called since its first line of code never executes (in Excel 365).

Thanks,
Jake

Govert van Drimmelen

unread,
Mar 16, 2021, 1:27:12 AM3/16/21
to Excel-DNA
Hi Jake,

Sorry - I thought I had made it public but evidently not.
It should now be accessible to you.

-Govert

Govert van Drimmelen

unread,
Mar 16, 2021, 1:51:54 AM3/16/21
to exce...@googlegroups.com

Hi Jake,

 

I’ve also pushed an update that now skips the missing images – that seemed to crash the loading before.

And I’ve updated to the preview version of Excel-DNA.

 

It now loads, but very slowly.

It might be worth trying to virtualize the ListView with the many images.

Jake

unread,
Mar 16, 2021, 8:52:11 AM3/16/21
to Excel-DNA
Thank you very much Govert, there are a few issues where the wrong images are shown after making your changes because the names array wasn't updated to remove the null images. The code below fixes them:

private string[] names;
private ListViewItem[] listViewItems;

....

public Gallery()
{
    ...

    Icons.BeginUpdate();

    var smallImageList = new List<Bitmap>();
    var largeImageList = new List<Bitmap>();
    var namesList = new List<string>();
    var listViewItemList = new List<ListViewItem>();

    foreach (var name in imageMso.Names)
    {
        var smallImage = imageMso[name, 16, 16];
        var largeImage = imageMso[name, 32, 32];
        if (smallImage != null && largeImage != null)
        {
            namesList.Add(name);
            smallImageList.Add(smallImage);
            largeImageList.Add(largeImage);
            listViewItemList.Add(new ListViewItem(name, namesList.Count - 1));
        }
    }

    names = namesList.ToArray();
    listViewItems = listViewItemList.ToArray();
    Icons.SmallImageList.Images.AddRange(smallImageList.ToArray());
    Icons.LargeImageList.Images.AddRange(largeImageList.ToArray());
    Icons.Items.AddRange(listViewItems);
    Icons.EndUpdate();

    ...
}

private void SetFilters_LostFocus(object sender, EventArgs e)
{
    SetFilters.Text = SetFilters.Text.Trim();
    if (!SetFilters.AutoCompleteCustomSource.Contains(SetFilters.Text))
        SetFilters.AutoCompleteCustomSource.Add(SetFilters.Text);
    if (SetFilters.Text != pattern)
    {
        pattern = SetFilters.Text;
        Clear.Enabled = SetFilters.Text.Length > 0;
        Filter.Checked = SetFilters.Text.Length > 0;
        // Comma separated array of keyword groups which are in turn space separated arrays of keywords.
        var filter = Array.ConvertAll(pattern.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries),
            search => search.Trim().Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries));

        Icons.BeginUpdate();
        Icons.Items.Clear();
        // Find all names where there exists a keyword group in the filter such that the name contains
        // all the keywords in the group, convert all names found to listview items and add as a range.
        if (filter.Length > 0) Icons.Items.AddRange(Array.ConvertAll(Array.FindAll(names,
            name => Array.Exists(filter, group => Array.TrueForAll(group,
                keyword => name.ToLowerInvariant().Contains(keyword.ToLowerInvariant().Trim())))),
                name => new ListViewItem(name, Array.IndexOf(names, name))));
        else Icons.Items.AddRange(listViewItems);
        if (Icons.Items.Count > 0) Icons.FocusedItem = Icons.Items[0];
        Icons.EndUpdate();
Reply all
Reply to author
Forward
0 new messages