Embedded Reference only working once  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Re: Embedded Reference only working once

Postby sh_jackland » Wed Jan 04, 2023 5:00 pm

I think I know what's happening. The error message I'm getting is it can't find Version=6.22.0, but .dll version I'm using is 6.25.1

In the Visual Studio project, I first installed Microsoft.Identity.Client which then installed version 6.22.0 of Microsoft.IdentityModel.Abstractions as a dependency.
I then updated Microsoft.IdentityModel.Abstrations to version 6.25.1. Microsoft.Identity.Client says it can use versions >=6.22.0 and verified this in the project.

I then used these .dll files for Embedded Reference.

In the Microsoft.Identity.Client.dll, it's References has the version of Microsoft.IdentityModel.Abstrations specified as 6.22.0

When it searches for the assembly, it must also be checking the version but instead of doing a >=, it's just doing ==.
Although it's strange that everything works the first time.

It seems the solution is to use the exact version.
sh_jackland
I'm new here
I'm new here
 
Posts: 7
Joined: Thu Oct 06, 2022 12:18 pm
Topics Solved: 1

Re: Embedded Reference only working once

Postby SBarnes » Wed Jan 04, 2023 5:37 pm

You may be correct but the interesting thing is Jiwa's original call to load embedded references uses System.Reflection.Assembly.LoadFile and the resolver is using System.Reflection.Assembly.LoadFrom.

Mike any thoughts on the different calls?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Embedded Reference only working once

Postby Mike.Sheen » Wed Jan 04, 2023 5:50 pm

SBarnes wrote:You may be correct but the interesting thing is Jiwa's original call to load embedded references uses System.Reflection.Assembly.LoadFile and the resolver is using System.Reflection.Assembly.LoadFrom.

Mike any thoughts on the different calls?


It's been a while since I had to sort out the intricacies, but the Plugin business logic uses LoadFile to obtain the embedded reference full name (but not actually load it) we then use Assembly.Load(FullName) to actually load the assembly.

LoadFile is used because we don't want any ambiguity on where to find the assembly. We know exactly where it is, but we don't actually load that assembly - we then use Assembly.Load(FullName) because another assembly might have already loaded the same exact assembly from another plugin folder location - so by using FullName it prevents trying to load the same assembly twice into the application domain which would cause an error.

I've not been able to repro the OP's issue - so I'm a bit in the dark as to why it was presenting a problem.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Embedded Reference only working once

Postby SBarnes » Wed Jan 04, 2023 6:03 pm

So here is an interesting question what happens if two plugins were using the same third party library but different versions something like say two versions of Newtonsoft can both exist in the same app domain given the use of the full name?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Embedded Reference only working once

Postby Mike.Sheen » Wed Jan 04, 2023 6:05 pm

SBarnes wrote:So here is an interesting question what happens if two plugins were using the same third party library but different versions something like say two versions of Newtonsoft can both exist in the same app domain given the use of the full name?


I would need to test this to be sure, but my belief is if the full name is the same, then it won't load it a second time, it uses the one previously loaded into the application domain.
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: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Embedded Reference only working once

Postby SBarnes » Wed Jan 04, 2023 6:39 pm

I had assumed you would say that and that would be the actual case but it appears we are both wrong 7.2.1 will load two plugins one with 13.01 and one with 13.02 of Newtonsoft and happily deserialize JSon.

Start up reports both plugins as loaded and no exceptions and under programdata there are the correct versions in each directory. :o
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Previous

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 25 guests