編譯時遇到兩個報警,這里記錄一下:
報警信息:
The current .NET SDK does not support targeting .NET Standard 2.0. Either target .NET Standard 1.6 or lower, or use a version of the .NET SDK that supports .NET Standard 2.0.
解決方案:
https://dotnet.microsoft.com/download/dotnet-core
到以上網址下載.NET Core 2.0(目前2.0已經停止支持,截至成文,最先版本是3.1)
報警信息:
unable to locate repository containing directory during dotnet build or publish
在dotnet構建或發布期間無法定位包含目錄的存儲庫
解決方案:
選中S7net項目--右鍵--Edit S7.net.csproj--注釋掉下面兩行
相關問題可以看這篇回答中Paul的回復:https://stackoverflow.com/questions/53696116/unable-to-locate-repository-containing-directory-during-dotnet-build-or-publish
使用S7.netplus可以用Nuget,也可以到GitHub下載源碼自己編譯。這里我用的是第二種方式,原因是在使用第一種方法引用S7.net.dll后,調用plc.ReadBytes()方法,該方法返回一個byte[],沒有在dll中找到能夠將S7數據類型轉換成C#數據類型的方法。但想到ReadBytes()方法是其他Read方法的基礎,通過查看S7.netplus源碼,發現這些方法其實是有的,都保存在Types文件夾中,所以考慮自己編譯源碼來進行引用。