标签:net-standard net-standard-1-4 net-4-6-1 c net
我一直试图围绕.NET Framework,.NET Core和.NET Standard之间的差异进行总结.根据我的阅读,.NET Standard是最低的公分母,使用.NET Standard编写的库应该与使用其他框架编写的代码兼容.
但是,我已经创建了一个使用.NETStandard 1.4的类库和使用.NET Framework 4.6.1的应用程序的解决方案,看来该应用程序无法使用该库.
无论应用程序在哪里尝试使用类库中的类,我都会收到诸如以下的错误.
Error CS0012 The type ‘IEnumerator<>’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
Error CS0012 The type ‘Object’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.
Error CS1579 foreach statement cannot operate on variables of type ‘HtmlMonkey.HtmlNodeCollection’ because ‘HtmlMonkey.HtmlNodeCollection’ does not contain a public definition for ‘GetEnumerator’
有人可以帮助我完善对这些库的理解,以便我的应用程序可以使用我的类库吗?
解决方法:
这是有关netstandard 1.4及更低版本与.NET 4.6.1-4.7项目的兼容性的已知问题.追踪到.NET Standard GitHub repo作为问题#503 Referencing NETStandard.Library 2.0.0 in net461-net47 project and only using ns1.4 (or lower) libs doesn’t work
问题的描述和解决方法如下:
NETStandard.Library 2.0.0 package doesn’t install netstandard1.x packages in net461-net47 projects. This is because we expected the support package to always be present on net461 and later, but when that support was implemented we dialed it back to only turn on when a netstandard1.5 or later library was referenced.
As a result installing a netstandard1.0-1.4 library in a net461-47 project and referencing NETStandard.Library 2.0.0 package will have missing dependencies.
One workaround is to use the NETStandard.Library 1.6.1 package instead. This still has the dependencies on the individual library packages to bring in the facades.
An alternative workaround is to set ImplicitlyExpandNETStandardFacades=true in the project file. This will enable all the facades for ns2.0 assemblies.
标签:net-standard,net-standard-1-4,net-4-6-1,c,net
来源: https://codeday.me/bug/20191110/2015527.html
本站声明:
1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。