rodneyviana / ODSyncUtil

MIT License
14 stars 5 forks source link

Cannot load ODSyncLib.dll with powershell #12

Closed mwalter027 closed 6 months ago

mwalter027 commented 7 months ago

Hey rodney.

If i try to load the dll within Powershell, i get the message,

Import-Module : Could not load file or assembly 'file:///[PATH REMOVED]\ODSyncLib.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
At line:1 char:1
+ Import-Module .\ODSyncLib.dll
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
    + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand"

If i use the ps1 File, i get this error Message:

Exception calling "GetODSyncStatus" with "4" argument(s): "Unable to load DLL 'ODSyncLib.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
At [Path removed]\Get-ODStatus.ps1:42 char:5
+     $HRESULT = [ODSyncLib]::GetODSyncStatus($IgnoreQuota, $Result, $M ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DllNotFoundException

Any idea?

Cheers Mike

rodneyviana commented 7 months ago

mwalter,

  1. Make sure you unblocked the zip before unzip it or unblock the ps1 file and DLL if you had already unzipped
  2. Both ps1 and DLL must be in the same folder to work
  3. For good mesure, go to the folder before running the ps1 file
mwalter027 commented 7 months ago

Hey Rodney,

I have unlock the zip, go into the folder and start your ps1. No effect ^^

PS C:\Users\DE119599\Downloads\ODSyncLib64> .\Get-ODStatus.ps1
MaxSize: 4096 / Type: uint64
Exception calling "GetODSyncStatus" with "4" argument(s): "Unable to load DLL 'ODSyncLib.dll': The specified module
could not be found. (Exception from HRESULT: 0x8007007E)"
At C:\Users\DE119599\Downloads\ODSyncLib64\Get-ODStatus.ps1:42 char:5
+     $HRESULT = [ODSyncLib]::GetODSyncStatus($IgnoreQuota, $Result, $M ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DllNotFoundException

C:\Users\DE119599\Downloads\ODSyncLib64\Get-ODStatus.ps1 : Call to GetODSyncStatus failed. HRESULT:
At line:1 char:1
+ .\Get-ODStatus.ps1
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ODStatus.ps1

C:\Users\DE119599\Downloads\ODSyncLib64\Get-ODStatus.ps1 : Size: 0
At line:1 char:1
+ .\Get-ODStatus.ps1
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ODStatus.ps1

            Status = "Error"
            HRESULT = $HRESULT
            Size = $Size

PS C:\Users\DE119599\Downloads\ODSyncLib64>

Maybe it is helpful, that the machine is a Windows 10 machine upgraded with IPU to Windows 11.

mwalter027 commented 7 months ago

Hey Rodney I have also test your script on a native Windows 11 23H2 Device and get the same result.

Cheers Mike

rodneyviana commented 7 months ago

Could you elaborate on the steps you took?

  1. Which zip file you downloaded?
  2. Did you unblock the file before unzip it?
  3. Are you using the official version with .ps1 + .exe or the beta with .ps1 + .dll?
  4. Did you test the .exe alone?
  5. Did you try the .exe alone with -d and then with -d -s output.txt ?
  6. What’s the output of odsyncutil.exe -h ?

From: mwalter027 @.> Sent: Thursday, March 7, 2024 1:30:41 AM To: rodneyviana/ODSyncUtil @.> Cc: Comment @.>; Subscribed @.> Subject: Re: [rodneyviana/ODSyncUtil] Cannot load ODSyncLib.dll with powershell (Issue #12)

Hey Rodney I have also test your script on a native Windows 11 23H2 Device and get the same result.

Cheers Mike

— Reply to this email directly, view it on GitHubhttps://github.com/rodneyviana/ODSyncUtil/issues/12#issuecomment-1982744048 or unsubscribehttps://github.com/notifications/unsubscribe-auth/AGT5MATKJMH5XW3ULQZFVPDYXAJSDBFKMF2HI4TJMJ2XIZLTSOBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLLDTOVRGUZLDORPXI6LQMWWES43TOVSUG33NNVSW45FGORXXA2LDOOJIFJDUPFYGLKTSMVYG643JORXXE6NFOZQWY5LFVE3TKMBQGM3TOMZUQKSHI6LQMWSWS43TOVS2K5TBNR2WLKRSGE3DGNJSG4ZTAMFHORZGSZ3HMVZKMY3SMVQXIZI. You are receiving this email because you commented on the thread.

Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mwalter027 commented 7 months ago

Hey Rodney. to 1. the latest Version Zip to 2. yes to 3. both to 4. Yes, the exe works as expected. to 5. Yes. to 6: Output:

ODSyncUtil - OneDrive Synchronization Utility Version 1.0.5.5000
Copyright (c) 2024 Rodney Viana (https://github.com/rodneyviana/ODSyncUtil)
MIT License

Usage: ODSyncUtil [options]
  -h                Show this help message
  -s <filename>     Save the output to file (UTF-8 unicode based on locale code page)
  -d                Debug the application
  -q                Ignore quota information (avoid crash situations)

I would primary use the dll Version while i need it as part of Powershell with XAML script.

CHeers Mike

rodneyviana commented 7 months ago

On terms of results, using the script that uses the .EXE and the one using the DLL are the same. Anyway, if the .EXE is working, there is no reason the DLL is not. You may have a DLL that is somehow corrupted, I've seen this happens because of antivirus. To check this, use PowerShell to calculate the Hash. It should match the results that I have:

Get-FileHash .\ODSyncLib.dll -Algorithm SHA256 | Select Hash

Hash                                                            
----                                                            
C301D41A6640FE2D8FA7F9A8039BC42465196B99D6408E11CFFD5D54AE7D6083
rodneyviana commented 6 months ago

Closing for inactivity