Unable to add assemblies with same name but different version

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
whiggs2
Posts: 38
Last visit: Fri May 13, 2022 11:03 am

Unable to add assemblies with same name but different version

Post by whiggs2 »

To help you better we need some information from you.

*** Please fill in the fields below. If you leave fields empty or specify 'latest' rather than the actual version your answer will be delayed as we will be forced to ask you for this information. ***

Product, version and build: SAPIEN PowerShell Studio 2017 Version 5.4.145
32 or 64 bit version of product: 64 bit
Operating system: windows 10 version 1703
32 or 64 bit OS: 64

*** Please add details and screenshots as needed below. ***
Ok. So this might be a unique issue, but I am working on a project which requires the use of many external assemblies (that I was hoping to integrate into the project with the assemblies feature). There is one assembly in particular (Newtonsoft.Json) which the project requires that two different versions of the same assembly be imported from into the running session (need version 10.0.3 which I obtain via nuget, and 9.0.1 which is included in the dot net core sdk). However, it would appear that powershell studio will not allow to import both versions of the assembly due to the fact that they have the same name, which essentially means that I cannot use powershell studio as I was hoping to and embedding the assemblies in the script. I understand that the product was probably designed this way in order to prevent users from adding duplicate assemblies to the same project, but I would very, very, very, very, very, very much recommend that the version of the assemblies be considered when the product determines duplicate assemblies and either adds or does not add them to the project.

DO NOT POST SUBSCRIPTIONS, KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Unable to add assemblies with same name but different version

Post by Alexander Riedel »

I am not sure if that even can be done. In general, when you try to use two different versions of the same assembly at the same time you are creating a huge problem for yourself. In any language.
This is not an easy task even in C#, and practically not possible if both versions use the same namespace (very likely) and/or use a different .NET runtime (also quite likely). I suspect that this is not a PowerShell Studio limitation but simply something that the underlying .NET framework will not allow you to do. I will inquire with the development team, but you should provide some information if these two assembly versions use the same namespace and/or if there are different .NET runtime requirements.

Last but not least, I would also be curious why you even want to do that. The newer version of that assembly *should* work for everything that the older version does or the vendor screwed something up.
So if you could provide some more information on this as well, it would be appreciated. Maybe we can help you in some other fashion if we know more.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
whiggs2
Posts: 38
Last visit: Fri May 13, 2022 11:03 am

Re: Unable to add assemblies with same name but different version

Post by whiggs2 »

I am pretty sure it can be done. Believe me, I tried using specifically just one version of the assembly. Both times I encountered errors because both versions ARE REQUIRED to run the project. This is not a problem I am having with the script. When I import all of the assemblies myself, it works beautifully. This is to report, and hopefully get resolved, an issue with powershell studio. I was under the impression that powershell studio was a power tool that simplified the process of writing powershell scripts, and I would like to facilitate that ideology by reporting issues which make it the opposite. Not looking for feedback about what constitutes good practice vs what does not. Looking to see if the issue will be resolved or not. Simple as that, as I have done my research and know what I am doing.
Without version 9.0.0
Image
Without version 10.0.0
Image
With Both versions of the assemblies
Image
User avatar
whiggs2
Posts: 38
Last visit: Fri May 13, 2022 11:03 am

Re: Unable to add assemblies with same name but different version

Post by whiggs2 »

Furthermore, like I said in original post, while these assemblies have different names, they come from entirely different sources (the 9.0.0 version came from the dot net core sdk installation and the 10.0.0 version came from nuget). My thinking is that, while they may have the same name, they do not contain the same contents and functionality, one being released by Microsoft (which has a digital signature) and one being released by jamesnk on nuget (which does not have a digital signature).
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Unable to add assemblies with same name but different version

Post by Alexander Riedel »

Thank you for that additional information. I will make sure it gets forwarded to the appropriate place.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Unable to add assemblies with same name but different version

Post by davidc »

For clarification, where are you referring to these assemblies? Have you tried using the Add-Type cmdlet directly in your script?
David
SAPIEN Technologies, Inc.
This topic is 6 years and 2 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.