[英]NativeCallableAttribute missing in .Net Core application
我在github上的coreclr存儲庫中找到了NativeCallableAttribute的實現。 它看起來像是2年前添加的,並且您可以找到顯示它與.Net Framework的非托管導出一樣的單元測試。
我創建了一個新的.Net core 2.0項目,並且System.Runtime.InteropServices
命名空間中沒有NativeCallableAttribute
。 是否需要添加一些nuget包才能使用此類? 我嘗試過nuget包System.Runtime.InteropServices
但仍然缺少該屬性。
NativeCallableAttribute
駐留在System.Private.CoreLib
程序NativeCallableAttribute
。 只需從您的項目中引用它,然后為System.Runtime.InteropServices
命名空間添加using
指令即可。
更新:
在哪里可以獲得System.Private.CoreLib? 在nuget上找不到它,並且Visual Studio中的.Net Core項目沒有它。
我在ReSharper中添加了程序集參考。 您可以通過將以下部分添加到csproj文件中來執行相同的操作:
<ItemGroup>
<Reference Include="System.Private.CoreLib">
<HintPath>C:\Program Files\dotnet\shared\Microsoft.NETCore.App\1.0.5\System.Private.CoreLib.dll</HintPath>
</Reference>
</ItemGroup>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.