gpt4 book ai didi

c# - 引用 Razor 类库中的类

转载 作者:行者123 更新时间:2023-12-04 16:57:10 36 4
gpt4 key购买 nike

我创建了一个新的 Razor 类库(使用“dotnet new razorclasslib”)。然后我在新库中创建了一个名为 Models 的文件夹,它包含一个具有以下测试代码的类:

using System;

namespace TestLibrary.Models
{
public class TestModel
{
public string TestMethod { get; set; }
}
}

但是,当我尝试从 Web 应用程序项目中使用这个类(通过将其称为 TestLibrary.Models.TestModel )时,我一直被告知 TestLibrary.Models 命名空间不存在。确切的错误是:

The type or namespace name 'Models' does not exist in the namespace 'TestLibrary' (are you missing an assembly reference?) [TestApplication]



我假设我错过了一些简单的东西,只是无法弄清楚是什么。

最佳答案

此问题与此处发布的问题有某种关系:Razor Class Library MSBuild MSB4062 Error During Compile .一旦解决了这个问题,这个问题就消失了。

关于c# - 引用 Razor 类库中的类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53601614/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com