I created a Class Library and NuGet package in order to share code to access our API. (This is my first time trying any of this). The Class Library was created using .NetStandard. I used the "Pack" feature in Visual Studio 2019 to create the NuGet package. I have installed the package in a new blank application to test. It seemed to all work well until I tried to use the models in a view. I first tried it in a Telerik grid:
@(Html.Kendo().Grid<iCANMVCSDK.Entities.Employee>() .Name("employeeGrid") .Columns(columns => { columns.Bound(c => c.EmployeeCompanyId); }))
I immediately received the error:
"The type 'Nullable<>' 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'. 1_Views_Home_Index.cshtml"
I then just tried putting the model directly on the view:
@using iCANMVCSDK;@model IEnumerable<iCANMVCSDK.Entities.Employee>@{ ViewBag.Title = "Home Page";}
I receive the same error. I did add .NetStandard to the project, but I still get the same error. I am assuming there is something I need to do in the Class Library before I pack it, but I do not know what.
This is what my Class Library project looks like. I'm not sure what anyone needs to see in order to help me.
Here is project XML:
<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup Label="Globals"><SccProjectName>SAK</SccProjectName><SccProvider>SAK</SccProvider><SccAuxPath>SAK</SccAuxPath><SccLocalPath>SAK</SccLocalPath></PropertyGroup><PropertyGroup><TargetFrameworks>netstandard2.0</TargetFrameworks><Authors>Rani Radcliff</Authors><Company>iCan</Company><GeneratePackageOnBuild>true</GeneratePackageOnBuild><Description>The client library that enables sharing and retrieving data with iCan Web Api</Description></PropertyGroup><ItemGroup><PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.2"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference><PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net472" Version="1.0.2"><PrivateAssets>all</PrivateAssets><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets></PackageReference><PackageReference Include="Newtonsoft.Json" Version="13.0.1" /><PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /></ItemGroup></Project>