您可以看到我已经通过nuget引用了它,但仍在抱怨.它位于嵌入式视图组件中的 4.6.1框架类库中.我还使用框架asp核心Web应用程序.我在尝试使剃须刀工作时遇到了很多问题,但这是一个新问题.MenuViewPage继承RazorPage,并且位于另一个程序集中.我想我应该只安装 core 2和aspnetcore.all;)\
you can see that I have referenced it through nuget, but is still complaining. This is in a 4.6.1 framework class library in an embedded view component. I'm also using a framework asp core web app. I'm having a bunch of issues trying to get razor to work, but this one is a new one. MenuViewPage inherits RazorPage and is located in another assembly. I think I should just install core 2, and aspnetcore.all ;)\
任何人都知道为什么会这样吗?
Anyone have any ideas why this is happening?
推荐答案
因此,经过数小时的尝试来解决此问题后,我得出了一个解决方案:
So after hours of trying to sort this issue out I've come to a solution:
在创建网络类库时,无论是将其用作应用程序部件还是使用基类创建核心项目,我建议您将其从普通的类库转换为支持Web的库strong>.
When creating a web class library, whether you are using it for application parts or you are creating your core project with base classes I advise you covert it from a normal class library to a web enabled one.
要将其转换为Web类库,您需要更改项目以使用以下.csproj,然后确保运行dotnet restore.
To convert it to a web class library you need to change the project to use the following .csproj, then make sure to run dotnet restore.
<Project Sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <OutputType>Library</OutputType> </PropertyGroup> <PropertyGroup> <TargetFramework>net461</TargetFramework> <RuntimeIdentifier>win7-x86</RuntimeIdentifier> <PreserveCompilationContext>true</PreserveCompilationContext> <ApplicationIcon /> <OutputTypeEx>library</OutputTypeEx> <StartupObject /> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <DocumentationFile></DocumentationFile> <NoWarn>1701;1702;1705;1591</NoWarn> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" /> <PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" /> <PackageReference Include="Microsoft.AspNetCore.Razor"> <Version>1.1.2</Version> </PackageReference> <PackageReference Include="Microsoft.AspNetCore.Razor.Runtime"> <Version>1.1.2</Version> </PackageReference> <PackageReference Include="System.Net.Http" Version="4.3.2" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" /> </ItemGroup> </Project>确保将输出类型设置为库.我遇到了程序集信息文件的问题,它似乎是在构建期间生成的,因此我通过双击属性"来注释了assembly.info的内容
Make sure you are making the output type a library. I ran into issues with the assembly info file, it seems to be generated during build now, so I commented out the assembly.info stuff by double clicking "Properties"
我希望这对以后的人有所帮助.
I hope this helps someone in the future.
更多推荐
已安装NuGet程序包,Visual Studio声称未引用程序集
发布评论