Plugin EmbeddedReferences versioning?  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Plugin EmbeddedReferences versioning?

Postby neil.interactit » Tue Mar 30, 2021 12:56 pm

Hi guys,

An issue has cropped up related to plugin EmbeddedReferences.

I have a plugin that uses Microsoft.Office.Interop.Excel.dll, Microsoft.Office.Interop.Word.dll, and Microsoft.Office.Interop.Outlook.dll as EmbeddedReferences. This has all worked fine for a number of years with the whole team on Office15. One user (happens to be the CFO!) has upgraded to Office16 and the plugin now fails …

picture.png
picture.png (9.89 KiB) Viewed 9930 times

If I update the EmbeddedReference, all the other users will get the error.

Eventually they will update the whole team, but in the meantime, is there any way to be clever in the plugin architecture and somehow version the EmbeddedReferences?

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Plugin EmbeddedReferences versioning?  Topic is solved

Postby Mike.Sheen » Tue Mar 30, 2021 2:19 pm

neil.interactit wrote:is there any way to be clever in the plugin architecture and somehow version the EmbeddedReferences?


Not using embedded references, no.

We've had peculiar libraries we've wanted to use before that didn't like being embedded references - so we made them simply document attachments to the plugin instead and the plugin code would look for the presence of the file in the file system and if absent save the document attachment to the file system and then load that.

It would mean you'd have to use a late-binding approach of invoking the library, which means the plugin editor won't autocomplete and the like, but it's not such a big deal.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Plugin EmbeddedReferences versioning?

Postby SBarnes » Tue Mar 30, 2021 4:07 pm

Could possibly setting an assembly resolver based upon who the user is to a different directory resolve the issue?

The just have two different directories somewhere with the interop DLLs.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Plugin EmbeddedReferences versioning?

Postby Mike.Sheen » Tue Mar 30, 2021 4:18 pm

SBarnes wrote:Could possibly setting an assembly resolver based upon who the user is to a different directory resolve the issue?

The just have two different directories somewhere with the interop DLLs.


Interesting idea... might work - might have trouble with the plugin maintenance form on first compile / save as the custom AssemblyResolve handler won't be invoked until the next login - but other than that it's just crazy enough to work!
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Plugin EmbeddedReferences versioning?

Postby SBarnes » Tue Mar 30, 2021 4:23 pm

who-you-calling-crazy.jpg
who-you-calling-crazy.jpg (57.53 KiB) Viewed 9925 times
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Plugin EmbeddedReferences versioning?

Postby neil.interactit » Tue Mar 30, 2021 5:00 pm

Sounding promising. Any chance of a minimal plugin demoing this concept?
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Plugin EmbeddedReferences versioning?

Postby Mike.Sheen » Tue Mar 30, 2021 5:10 pm

neil.interactit wrote:Sounding promising. Any chance of a minimal plugin demoing this concept?


Sure... but before that are we sure that the problem is to do with a different version of Office?

The message actually says "Access Denied", not assembly not found or anything indicating it's looking for or loading an unexpected assembly - it might be the Office version is a red herring.

Check also that your CFO has installed the 32 bit - not the 64 bit - version of Office.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807

Re: Plugin EmbeddedReferences versioning?

Postby SBarnes » Tue Mar 30, 2021 5:35 pm

For Assembly Resolver I usually use the following, which is based upon an example Mike gave ages ago.


Code: Select all
    public static class AssemblyResolver
    {
        private static string jiwaApplicationPath;
        public static void SetRevoler(string path = @"C:\Program Files (x86)\Jiwa Financials\Jiwa 7")
        {
            jiwaApplicationPath = path;
            AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;
        }

        static System.Reflection.Assembly AssemblyResolve(object sender, ResolveEventArgs e)
        {
            //string jiwaApplicationPath = @"C:\Program Files (x86)\Jiwa Financials\Jiwa 7";
            System.Reflection.Assembly resolvedAssembly = null;

            // NOTE: sometimes e.Name is the assembly FullName, sometimes it may be a path - depending on how the assembly is attempted to be loaded - the below will handle both cases
            string filename = e.Name.Split(new Char[] { ',' })[0].Replace(@"\\", @"\");
            string filenameAndPath = System.IO.Path.Combine(jiwaApplicationPath, filename) + ".dll";

            if (System.IO.File.Exists(filenameAndPath))
            {
                resolvedAssembly = System.Reflection.Assembly.LoadFrom(filenameAndPath);
            }

            return resolvedAssembly;
        }
    }
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191

Re: Plugin EmbeddedReferences versioning?

Postby neil.interactit » Wed Mar 31, 2021 10:17 am

Thanks guys,

I have knocked up an assembly resolver to see if that works. I have also queried whether 32/64 bit Office is installed.

Cheers,
Neil
neil.interactit
Kohai
Kohai
 
Posts: 232
Joined: Wed Dec 03, 2014 2:36 pm
Topics Solved: 6

Re: Plugin EmbeddedReferences versioning?

Postby SBarnes » Sat Apr 03, 2021 10:31 am

It may also be worthwhile having a look at this https://github.com/NetOfficeFw/NetOffice
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1696
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 191


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 0 guests