在 Azure Function Visual Studio 预览中使用自定义 Dll

Using Custom Dlls in Azure Function Visual Studio Preview

如何将自定义 class 库导入 Visual Studio 中的 Azure 函数?我目前已经构建了 class 库并将其添加到 Azure Function 项目中的 bin 文件夹中。我在 run.csx.

中添加了对 class 的引用

run.csx:

#r "../bin/ClassLibrary1.dll"

using System;
using ClassLibrary1;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
     log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
     dynamic class1 = new Class1();
}

这会在函数设置计时器后引发错误,说明其缺失 System.Runtime。我试图添加 System.Runtime 但没有成功。 class 库是 .net 核心,但我还将引用 .net 4.6 class 库

达科他州,

依赖项通常 deployed/referenced 与 .NET Core 应用程序或库,通常是通过引用适当的 NuGet 包。因此,您需要引用所需的包或将程序集的依赖项复制到同一文件夹中。

此外,似乎是这样,但请确保您的 .NET Core 库最多针对 Netstandard 1.3。

希望对您有所帮助!

此处从 C# 函数引用我的自定义 class 库时出现类似问题,初始错误为:

"The type 'Attribute' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"

问题是我在我的项目中以 NetStandard 2.0 为目标(默认情况下),一旦我降级到 1.3,它就可以工作了。