[PS 3.1.23] Default assemblies from path fails

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 10 years and 7 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.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

[PS 3.1.23] Default assemblies from path fails

Post by Bosparan »

Hello,

I would like to add another assembly to the default assemblies that are loaded for every new opened script to provide intellisense.

However, the assembly in question is not stored and detected where all the others are, it is placed in a path in its "C:\Program Files\..." subfolder. When I add it to the default assemblies by navigating to the path and selecting it, adding it works just fine. However, whenever the default assemblies are loaded, each script it is loaded for throws an error:

Code: Select all

Could not load file or assembly 'Microsoft.Exchange.WebServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The System can't find the indicated file.
(last line is a rough translation. Original error is in German, same as OS: "Das System kann die angegebene Datei nicht finden.")

Am I doing something wrong or is this a bug?

Regards,
Fred
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: [PS 3.1.23] Default assemblies from path fails

Post by davidc »

The generated script tries to load the assembly from the Global Assembly Cache (GAC). Typically if you provide a local path, the script will likely fail when ran on another machine. Right now you will have to add it in the GAC or using Add-Type in your script to ensure that it is loaded.

David
David
SAPIEN Technologies, Inc.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

Re: [PS 3.1.23] Default assemblies from path fails

Post by Bosparan »

Hi david,

actually, I am always manually loading all assemblies I use (it happens that autoloading fails on some machines). I tried adding a local non-GAC assembly for intellisense purposes only. Importing it into the script by code works just fine, but does not provide intellisense coding support. As I only code on the local machine thus far, having this available would help a lot for development purposes, as each time I touch an EWS script I have to manually add the assembly (Home > Edit > Assemblies).

Regards,
Fred
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: [PS 3.1.23] Default assemblies from path fails

Post by davidc »

If you are not getting PrimalSense try casting variables into the type:

[System.SomeType]$var = ...

The PrimalSense should work as long as the assembly loaded successfully and the type is exportable (public). A good way to check is if the Type is listed in the .NET Object Browser Panel.

I added the non-GAC dll support for the generated scripts to the wish list.


David
David
SAPIEN Technologies, Inc.
Bosparan
Posts: 290
Last visit: Fri Oct 08, 2021 11:59 am

Re: [PS 3.1.23] Default assemblies from path fails

Post by Bosparan »

hi David,

either I am misunderstanding you or you are misunderstanding me (I really am not sure which way it is).
I have no problem getting PrimalSense working. If I add the assembly manually it works just fine.
My problem is that I can't get it to do so automatically, by adding it to the default assemblies (Options > Editor > Default Assemblies).

Cheers, and sorry for the trouble,
Fred
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: [PS 3.1.23] Default assemblies from path fails

Post by davidc »

Similar issue. PowerShell Studio only stores the assembly name and tries to load it from the GAC. The reason it works when you add it to a file is that the pff stores the file path of the assembly.

We will look at adding the path when you save as a default assembly.

David
David
SAPIEN Technologies, Inc.
This topic is 10 years and 7 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.