SCRT-HQ / PSGSuite

Powershell module for Google / G Suite API calls wrapped in handy functions. Authentication is established using a service account via P12 key to negate the consent popup and allow for greater handsoff automation capabilities
https://psgsuite.io/
Apache License 2.0
234 stars 66 forks source link

[Bug] Unable to load Google.Apis.Urlshortener.v1.dll in PSGSuite version 2.35.1 #258

Closed ZamElek closed 4 years ago

ZamElek commented 4 years ago

Hello, I have troubles with module version 2.35.1:

Summary: PSGSuite (version 2.35.1) stop working on Microsoft Windows Server 2019 Standard. To resolve the issue need to upgrade Google.Apis.Urlshortener.v1.dll to Version=1.42.0.0 (but I don't see one at https://www.nuget.org). Probably need rollback *.dlls to version 1.41.1.0

Debugging info: When I run the command: Import-Module PSGSuite (2.35.1) the errors occurred:

Message: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. StackTrace: at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) at System.Reflection.Assembly.GetTypes() at Microsoft.PowerShell.Commands.AddTypeCommand.LoadAssemblyFromPathOrName(List`1 generatedTypes) at Microsoft.PowerShell.Commands.AddTypeCommand.EndProcessing() at System.Management.Automation.CommandProcessorBase.Complete() LoaderExceptions: System.IO.FileNotFoundException: Could not load file or assembly 'Google.Apis, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of i ts dependencies. The system cannot find the file specified. File name: 'Google.Apis, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab'

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. System.IO.FileNotFoundException: Could not load file or assembly 'Google.Apis, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' or one of its dependencies. The system cannot find the file specified. File name: 'Google.Apis, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab' .....

Digging further I have found that it can't load net45/Google.Apis.Urlshortener.v1.dll due to it requires Google.Apis Version=1.41.1.138, but version Google.Apis, Version=1.42.0.0 was installed: See Fusion logs (https://port135.com/2018/05/17/how-to-enable-assembly-binding-logging-debugging-net-applications/) for more details:

=== Pre-bind state information === LOG: DisplayName = Google.Apis, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab (Fully-specified) LOG: Appbase = file:///C:/Windows/System32/WindowsPowerShell/v1.0/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = powershell.exe Calling assembly : Google.Apis.Urlshortener.v1, Version=1.41.1.138, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab.

LOG: This bind starts in LoadFrom load context. WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load(). LOG: Using application configuration file: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config. LOG: Post-policy reference: Google.Apis, Version=1.41.1.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab LOG: GAC Lookup was unsuccessful. LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/Google.Apis.DLL. LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/Google.Apis/Google.Apis.DLL. LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/Google.Apis.EXE. LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/Google.Apis/Google.Apis.EXE. LOG: Attempting download of new URL file:///C:/Program Files/WindowsPowerShell/Modules/PSGSuite/2.35.1/lib/net45/Google.Apis.DLL. LOG: Assembly download was successful. Attempting setup of file: C:\Program Files\WindowsPowerShell\Modules\PSGSuite\2.35.1\lib\net45\Google.Apis.dll LOG: Entering run-from-source setup phase. LOG: Assembly Name is: Google.Apis, Version=1.42.0.0, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: The assembly reference did not match the assembly definition found. ERR: Run-from-source setup phase failed with hr = 0x80131040. LOG: Attempting download of new URL file:///C:/Program Files/WindowsPowerShell/Modules/PSGSuite/2.35.1/lib/net45/Google.Apis/Google.Apis.DLL. LOG: Attempting download of new URL file:///C:/Program Files/WindowsPowerShell/Modules/PSGSuite/2.35.1/lib/net45/Google.Apis.EXE. LOG: Attempting download of new URL file:///C:/Program Files/WindowsPowerShell/Modules/PSGSuite/2.35.1/lib/net45/Google.Apis/Google.Apis.EXE. LOG: All probing URLs attempted and failed.

scrthq commented 4 years ago

hey @ZamElek - Good catch! The URL Shortener API was actually shut down by Google last year, so those should really be pulled out of the module altogether.

Keeping this open until they're pulled out!

ZamElek commented 4 years ago

Thanks for quick response. I've just replaced *. dll from previous versions :)

scrthq commented 4 years ago

Got it @ZamElek ! I'll get this pulled out in the next release =]

ZamElek commented 4 years ago

Thank you!