在Powershell中运行

在Powershell中运行,powershell,cefsharp,Powershell,Cefsharp,我需要显示从Powershell脚本运行的CefSharp(WPF或Winforms)Webbrowser控件。我从nuget软件包中提取了x84 dll,并尝试这样添加它们: try{ Add-Type -Path $PSScriptRoot/CefSharp.Core.dll Add-Type -Path $PSScriptRoot/CefSharp.BrowserSubprocess.Core.dll Add-Type -Path $PSScriptRoot/Cef

我需要显示从Powershell脚本运行的CefSharp(WPF或Winforms)Webbrowser控件。我从nuget软件包中提取了x84 dll,并尝试这样添加它们:

try{
    Add-Type -Path $PSScriptRoot/CefSharp.Core.dll
    Add-Type -Path $PSScriptRoot/CefSharp.BrowserSubprocess.Core.dll
    Add-Type -Path $PSScriptRoot/CefSharp.dll
    Add-Type -Path $PSScriptRoot/CefSharp.WinForms.dll
}
catch{

$_.Exception.Message
}
我收到错误消息:

无法加载文件。。。或依赖。模块 没有找到


有没有办法使用Powershell?

我的错误和你的一样

我通过将CEF redist包添加到与CefSharp dll相同的文件夹中来解决此问题:

有关基金的官方资料:

我为其他人发布示例代码:

[System.Reflection.Assembly]::LoadFile("$AssPath\CefSharp.Core.dll")
[System.Reflection.Assembly]::LoadFile("$AssPath\CefSharp.WinForms.dll")
[System.Reflection.Assembly]::LoadFile("$AssPath\CefSharp.dll")

Add-Type -AssemblyName System.Windows.Forms

# WinForm Setup
$mainForm = New-Object System.Windows.Forms.Form
$mainForm.Font = "Comic Sans MS,9"
$mainForm.ForeColor = [System.Drawing.Color]::White
$mainForm.BackColor = [System.Drawing.Color]::DarkSlateBlue
$mainForm.Text = "CefSharp"
$mainForm.Width = 960
$mainForm.Height = 700

[CefSharp.WinForms.ChromiumWebBrowser] $browser = New-Object CefSharp.WinForms.ChromiumWebBrowser "www.google.com"
$mainForm.Controls.Add($browser)

[void] $mainForm.ShowDialog()

您正在尝试在64位进程中加载x86 dll吗?在这里发布之前,您是否搜索了您收到的错误?我使用的是正确的位版本请包含整个错误消息,哪个调用失败?您是否确认指定的文件路径正确?