MichaelGrafnetter / DSInternals

Directory Services Internals (DSInternals) PowerShell Module and Framework
https://www.dsinternals.com
MIT License
1.63k stars 253 forks source link

Cannot Load File or Assembly 'DSInternals.Replication.Interop.dll' #77

Closed cappel2007 closed 5 years ago

cappel2007 commented 5 years ago

Hello,

I installed DSInternals today in a test environment (via Install-Module DSInternals -Force) and cannot run get-adreplaccount command. I have .Net framework version 4.7 and Powershell 5.1 installed. I set execution policy to unrestricted. I also checked to see if file was blocked. Could there be anything else I am missing? I would love to get this to work so I can test password quality.

image

MichaelGrafnetter commented 5 years ago

Thanks @cappel2007 for reporting this. What OS do you have? Could you please try installing Visual C++ Runtime 2017 on that machine? It is bundled with DSInternals, but I might have missed a file.

cappel2007 commented 5 years ago

Hi @MichaelGrafnetter .... that worked!! I can now run Get-ADReplAccount and Test-PasswordQuality against a password list file.

I am running Windows 2008 R2 (old, I know but want to mimic production).

Thank you so much for the reply and the help!

MichaelGrafnetter commented 5 years ago

Great that at least the workaround has worked for you, @cappel2007 . Just to be sure, you just installed Microsoft Visual C++ Redistributable for Visual Studio 2017 x64? I will try to fix the issue in a future release.

MichaelGrafnetter commented 5 years ago

One more thing, @cappel2007 , could you please run the following on that computer and post the result?

$m1 = Get-Process powershell | select -ExpandProperty Modules
Import-Module DSInternals
$m2 = Get-Process powershell | select -ExpandProperty Modules
Compare-Object -ReferenceObject $m1.FileName -DifferenceObject $m2.FileName

It should be something like

InputObject                                                                                            SideIndicator
-----------                                                                                            -------------
C:\Program Files\WindowsPowerShell\Modules\DSInternals\3.2.1\AMD64\DSInternals.Replication.Interop.dll =>
C:\Program Files\WindowsPowerShell\Modules\DSInternals\3.2.1\AMD64\VCRUNTIME140.dll                    =>
C:\Program Files\WindowsPowerShell\Modules\DSInternals\3.2.1\AMD64\MSVCP140.dll                        =>
cappel2007 commented 5 years ago

@MichaelGrafnetter Below are the results of the compare. Also, yes, I can confirm it was the x64 version of Microsoft Visual C++ Redistributable for Visual Studio 2017 from the link you sent. Thanks again for the help!

image

MichaelGrafnetter commented 5 years ago

The problem was caused by missing Universal C Runtime (KB2999226), which is normally distributed through Windows Update and it is also a part of the Visual C++ Redistributable Package. It is unfortunately not possible to pack it together with DSInternals. But the error message could have been more meaningful.

cappel2007 commented 5 years ago

Thanks again @MichaelGrafnetter. I appreciate the help and the followup. Apologies for not ensuring my test server was fully patched.

umar-ulabs commented 1 year ago

I am having the same error in .NET C# System.IO.FileNotFoundException: 'Could not load file or assembly 'DSInternals.Replication.Interop, Version=4.7.0.0, Culture=neutral, PublicKeyToken=af7e77ba04a3c166'. The system cannot find the file specified.'

MichaelGrafnetter commented 1 year ago

@umar-ulabs Will some more info to be able to help you.

umar-ulabs commented 1 year ago

@MichaelGrafnetter Thanks. I have a question. For the DirectoryReplicationClient to work remotely, meaning connecting to DC remotely, is there anything that needs to be enable on DC. DirectoryReplicationClient is working fine if I run the code on DC itself. Thanks

MichaelGrafnetter commented 1 year ago

@umar-ulabs Please open a new thread for unrelated questions, so that we do not get lost in the discussion. The DirectoryReplicationClient needs MS-DRSR connectivity to the DC (TCP port 135 + an RPC ephemeral port).