'Class.function' 在使用自制的 NuGet 包时在当前上下文中不存在

'Class.function' doesn't exist in current context while using a self made NuGet Package

我在 .NetCore class 库上创建了一个 NuGet 包,并从另一个 .net 核心 class 库访问它。即使检测到 class 名称,我也无法从 public 和静态 class 调用我的 public 和静态方法。

需要说明的一点是,该包可以在控制台应用程序上正常运行,但我无法访问 class 库中的函数。

为了创建一个包,我去了 属性->Package->Create Package on build 和 nuget.exe 方法。两者都导致同样的事情

包和新项目都是.net core 3.1 class库

谁能帮帮我

NuGet 包代码

using System;
using System.Collections.Generic;
using System.Text;

namespace TrailCorePackage.helper
{
    public static class Utility
    {
        public static void print(string value)
        {
            Console.WriteLine(value);
            Console.ReadKey();
        }
    }
}

在另一个 class 库中调用函数时的代码

using System;
using TrailCorePackage.helper;

namespace ClassLibrary5
{
    public class Class1
    {
        Utility.print("value");
    }
}

错误

Severity    Code    Description Project File    Line    Suppression State
Error   IDE1007 The name 'Utility.print' does not exist in the current context. ClassLibrary5   C:\Users\---\ClassLibrary5\Class1.cs    Active

由于我还不能发表评论,我会添加它作为答案。您是否已将对包的引用添加到您的控制台应用程序中?

UPD.

我刚刚注意到您在 class 体内调用函数。它不会工作。这样的事情可能会奏效。

using System;
using TrailCorePackage.helper;

namespace ClassLibrary5
{
    public class Class1
    {
        public void AnyMethod() 
        {
            Utility.print("value");
        }   
    }
}