【问题标题】:How to reference CefSharp inside Azure function?如何在 Azure 函数中引用 CefSharp?
【发布时间】:2019-04-26 20:16:54
【问题描述】:

我创建了两个项目:第一个是典型的 HTTP 触发 Azure 函数,第二个只是 CefSharp.MinimalExample.OffScreen 应用程序的示例。 Azure 函数引用 CefSharp proj 来制作屏幕截图。此引用在本地完美运行,但在 Azure 中却不行。发布日志流实用程序后显示加载程序集“CefSharp.Core.DLL”的问题

2019-04-26T19:09:57.132 [Info,Function1] Function started (Id=1824ad19-be9e-4fd1-a3a4-17e770967164)
2019-04-26T19:09:57.132 [Info,Function1] Executing 'Function1' (Reason='This function was programmatically called via the host APIs.', Id=1824ad19-be9e-4fd1-a3a4-17e770967164)
2019-04-26T19:09:57.132 [Info,Function1] C# HTTP trigger function processed a request.
2019-04-26T19:09:57.148 [Error] A ScriptHost error has occurred
2019-04-26T19:09:57.148 [Error] Could not load file or assembly 'CefSharp.Core.DLL' or one of its dependencies. The specified module could not be found.
2019-04-26T19:09:57.194 [Error,Function1] Exception while executing function: Function1
2019-04-26T19:09:57.194 [Error,Function1] Could not load file or assembly 'CefSharp.Core.DLL' or one of its dependencies. The specified module could not be found.
2019-04-26T19:09:57.194 [Error,Function1] Function completed (Failure, Id=1824ad19-be9e-4fd1-a3a4-17e770967164, Duration=73ms)
2019-04-26T19:09:57.210 [Error,Function1] Executed 'Function1' (Failed, Id=1824ad19-be9e-4fd1-a3a4-17e770967164)
2019-04-26T19:09:57.210 [Error,Function1] Could not load file or assembly 'CefSharp.Core.DLL' or one of its dependencies. The specified module could not be found.
2019-04-26T19:09:57.210 [Error,Function1] Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '1824ad19-be9e-4fd1-a3a4-17e770967164'
2019-04-26T19:09:57.210 [Error,Function1] Could not load file or assembly 'CefSharp.Core.DLL' or one of its dependencies. The specified module could not be found.
2019-04-26T19:09:57.210 [Error] {"id":"42f419f5-9cc7-4c90-bd6b-92836626c25f","requestId":"213b53eb-ee2c-475e-8094-a9e2ebcb6665","statusCode":500,"errorCode":0,"message":"An error has occurred. For more information, please check the logs for error ID 42f419f5-9cc7-4c90-bd6b-92836626c25f"}
2019-04-26T19:09:57.210 [Error] Could not load file or assembly 'CefSharp.Core.DLL' or one of its dependencies. The specified module could not be found.
2019-04-26T19:09:57.132 [Info] Function started (Id=1824ad19-be9e-4fd1-a3a4-17e770967164)
2019-04-26T19:09:57.132 [Info] C# HTTP trigger function processed a request.
2019-04-26T19:09:57.194 [Error] Function completed (Failure, Id=1824ad19-be9e-4fd1-a3a4-17e770967164, Duration=73ms)

我的项目结构和 FTP dll

  • 我使用的是 Release |用于发布的 x64 (net461) 配置,因为 x86 (System.BadImageFormatException) 构建失败 bla, bla..
  • 我稍微修改了 nuget CefSharp.OffScreen.targets 文件并将 bin 文件夹添加为 CefSharpTargetDir,因为一半的程序集不在 bin 文件夹中
  • 我检查了 kudu 和 ftp,确认 D:\home\site\wwwroot\bin> 包含 cefsharp 启动所需的所有文件。

有趣的是,如果 Azure Webjob (AuthWebjob.csproj) 引用 Cefsharp 一切正常!可能我错过了项目结构或 Azure VM 的应用程序设置中的某些内容。

【问题讨论】:

  • 您使用的是哪个版本的 azure 函数? v1 适用于 .net 框架。 v2 适用于 .net 核心
  • @Thomas AzureFunctionsVersion v1,TargetFramework net461,我认为它是 VS2017 的默认 Functure proj 模板
  • 你能在azure门户上查看应用设置FUNCTIONS_EXTENSION_VERSION = ~1吗?
  • @Thomas 是的,正是你所说的 FUNCTIONS_EXTENSION_VERSION = ~1,x64 平台。如果需要,我可以将我的解决方案发送给您进行测试。

标签: c# azure-functions azure-webjobs cefsharp.offscreen


【解决方案1】:

由于 CefSharp.Core 是一个原生 C++ 库,您可以尝试将您的函数切换到 V2 并通过 FTP 将二进制文件复制到 wwwroot\ 文件夹。如果这不起作用,那么恐怕它可能还不被支持。我遇到了 github 问题 hereherehere,这表明它的功能已被请求但尚未采用。

【讨论】:

    猜你喜欢
    • 2019-11-22
    • 2021-01-30
    • 2020-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-05
    • 1970-01-01
    • 2019-07-17
    相关资源
    最近更新 更多