TL; DR:
だから、ちょうどこのアセンブリを見つけるとMongoDriverと同じフォルダに追加する必要があります。私はビジュアルスタジオのコンソールアプリケーションを作成し、それをNugetのドライバを追加して見つけました。 interopアセンブリはpackagesディレクトリにあります。
https://www.nuget.org/packages/mongocsharpdriver/2.5.0/
研究:
ここで概説としてログの融合を有効にする:
https://www.hanselman.com/blog/BackToBasicsUsingFusionLogViewerToDebugObscureLoaderErrors.aspx
今、あなたはリクのようなものが表示されるはずですMongoClient
Add-Type -Path "C:\temp\Mongo\MongoDB.Bson.dll"
Add-Type -Path "C:\Temp\Mongo\MongoDB.Driver.dll"
$mongoClient = New-Object MongoDB.Driver.MongoClient
を初期化しますフュージョンログのE:
*** Assembly Binder Log Entry (12/29/2017 @ 1:50:26 PM) ***
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: DisplayName = System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(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 : MongoDB.Driver.Core, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null.
===
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: No application configuration file found.
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Publisher policy file is not found.
LOG: Post-policy reference: System.Runtime.InteropServices.RuntimeInformation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: Attempting download of new URL file:///C:/Windows/System32/WindowsPowerShell/v1.0/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: Attempting download of new URL file:///C:/Temp/Mongo/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/Temp/Mongo/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.DLL.
LOG: Attempting download of new URL file:///C:/Temp/Mongo/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: Attempting download of new URL file:///C:/Temp/Mongo/System.Runtime.InteropServices.RuntimeInformation/System.Runtime.InteropServices.RuntimeInformation.EXE.
LOG: All probing URLs attempted and failed.
だから誤差に基づいて、それはアセンブリMongoDB.Driver.Core
をロードしていますし、例外がスローされている場所つまり。
このアセンブリを見つけて、MongoDriverと同じフォルダに追加するだけです。私はビジュアルスタジオのコンソールアプリケーションを作成し、それをNugetのドライバを追加して見つけました。 interopアセンブリはpackagesディレクトリにあります。
https://www.nuget.org/packages/mongocsharpdriver/2.5.0/
あなたは.NET 4.0 CLR(PowerShellの3.0以降)上で動作するのPowerShellのバージョンを使用していることを確認してください。 '$ PSVersionTable'の出力をあなたの質問に投稿してください –
PSVersion:5.0.10586.962 CLRVersion:4.0.30319.42000 私は上記のバージョンpowershellを使用しています –
解決方法はありますか?私は同じ問題を抱えています。 –