在Azure Functions中加载第三方DLL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Azure Functions中加载第三方DLL相关的知识,希望对你有一定的参考价值。

我在Azure函数中使用icu.net和2.1运行时。当我建立icu dlls(icuin59.dllicuio59.dllicutest59.dllicutu59.dllicuuc59.dllicudt59.dll)被复制到../netcoreapp2.1/lib/win-x64文件夹和../netcoreapp2.1/bin/runtimes/win7-x64/native文件夹。 icu.net.dll也被复制到../netcoreapp2.1/bin

我在Windows 10上本地运行。

当我的函数执行时,我得到:

[20/03/2019 16:09:14] Executed 'AnalyzeVocabulary' (Failed, Id=cb768548-dd06-4f95-b889-af244af716d1)
[20/03/2019 16:09:14] System.Private.CoreLib: Exception while executing function: AnalyzeVocabulary. icu.net: Can't load ICU library (version 0).
[20/03/2019 16:09:14] 926e7209782c408984ad827cc2744b2d: Function 'AnalyzeVocabulary (Activity)' failed with an error. Reason: System.IO.FileLoadException: Can't load ICU library (version 0)
[20/03/2019 16:09:14] File name: 'icuuc'
[20/03/2019 16:09:14]    at Icu.NativeMethods.LoadIcuLibrary(String libraryName)
[20/03/2019 16:09:14]    at Icu.NativeMethods.get_IcuCommonLibHandle()
[20/03/2019 16:09:14]    at Icu.NativeMethods.uloc_canonicalize(String localeID, IntPtr name, Int32 nameCapacity, ErrorCode& err)
[20/03/2019 16:09:14]    at Icu.Locale.<>c__DisplayClass44_0`1.<GetString>b__0(IntPtr ptr, Int32 length)
[20/03/2019 16:09:14]    at Icu.NativeMethods.GetString(Func`3 lambda, Boolean isUnicodeString, Int32 initialLength)
[20/03/2019 16:09:14]    at Icu.Locale.GetString[T](GetStringMethod`1 method, T localeId)
[20/03/2019 16:09:14]    at Icu.Locale.Canonicalize(String localeID)
[20/03/2019 16:09:14]    at Icu.Locale.op_Implicit(String localeId)
[20/03/2019 16:09:14]    at DigitalLinguistics.TextAnalytics.TextSegApiTokenizer.TextTokenizer.SegmentSentences(String sentence) in E:\DigitalLinguistics\Dev\ServerlessSentinel\DigitalLinguistics.TextAnalytics\TextTokenizer.cs:line 70
[20/03/2019 16:09:14]    at DigitalLinguistics.TextAnalytics.TextSegApiTokenizer.TextTokenizer.Tokenize(String sentence, String id) in E:\DigitalLinguistics\Dev\ServerlessSentinel\DigitalLinguistics.TextAnalytics\TextTokenizer.cs:line 82
[20/03/2019 16:09:14]    at DigitalLinguistics.TextAnalytics.DataStructures.Sentence.LineParse(String text, String id, TokenizerOptions tokenOpts) in E:\DigitalLinguistics\Dev\ServerlessSentinel\DigitalLinguistics.TextAnalytics\Sentence.cs:line 92

注意我已经从网络核心控制台应用程序成功运行这些,所以我猜这些库不在正确的文件夹中。

关于库需要在哪里以及我如何设置的任何建议,以便它们在VS 2017中作为构建的一部分进行部署和发布?

答案

我能够从GitHub的源代码中找出该位置必须是../netcoreapp2.1/bin/lib

以上是关于在Azure Functions中加载第三方DLL的主要内容,如果未能解决你的问题,请参考以下文章

无法在 Python 中加载共享对象文件 [重复]

如何在functions.php(wordpress)中加载引导脚本和样式?

C# 在 appdomain 调用方法中加载 dll,而不会再次加载 dll

为啥内存中加载的 DLL 与原始 DLL 文件不完全对应?

无法在 python 中加载 c++ DLL

在 Java 中加载 DLL - JNA