如何告诉我的 C# 项目在哪里寻找 DLL?

问题描述 投票:0回答:1

我目前正在尝试通过 JUST.Net 使用自定义函数。

我在一个名为

Foo.JUST.CustomFunctions
的项目中创建了这个函数:

using Newtonsoft.Json.Linq;

namespace CustomFunctions;

public class Normalizer
{
    public static object TryUnquote(object value) =>
        value is string quotedValue
            ? JToken.Parse(quotedValue)
            : value;
}

我正在尝试注册它:

// FIXME: Use Dependency Injection!
JUSTContext context = new();

context.RegisterCustomFunction("Enpal.JUST.CustomFunctions", "CustomFunctions.Normalizer", "TryUnquote", "tryunquote");

但是系统抛出了这个异常:

System.IO.FileNotFoundException:'无法加载文件或程序集 'C:\projects\SalesforceEventListenerService\Salesforce.EventListener\Foo.JUST.CustomFunctions.dll'。 系统找不到指定的文件。'

这非常有道理,因为 Visual Studio 在构建项目时并没有把它放在那里,而是可以在

"C:\projects\SalesforceEventListenerService\Salesforce.EventListener\bin\Debug\net6.0-windows8.0"

中找到它

如何确保系统看起来在正确的位置?

我还需要做什么(如果有的话)来确保它在进入 Azure DevOps CI/CD 管道时也能正常工作?

c# dll dllimport dllregistration
1个回答
0
投票

我能够像这样工作:

_ = Assembly.GetAssembly(typeof(Normalizer));

JUSTContext context = new();
context.RegisterCustomFunction("Enpal.JUST.CustomFunctions", "CustomFunctions.Normalizer", "TryUnquote", "tryunquote");
© www.soinside.com 2019 - 2024. All rights reserved.