我正在尝试为Raspberry Pi 2编译UWP C#解决方案。 这是 project.json :
{
"dependencies": {
"Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0",
},
"frameworks": {
"uap10.0": {
"imports": [
]
}
},
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
}
}
问题是我引用(通过dll,我不能通过对项目的正常引用添加它)到另一个项目,它使用System.Threading进行某些线程操作。这是 project.json :
{
"version": "1.0.0-*",
"dependencies": {
"ELMSDefinitionsCore": "1.0.0-*",
"NETStandard.Library": "1.6.1",
"System.ComponentModel.Primitives": "4.2.0",
"System.Xml.XmlSerializer": "4.2.0",
"UniversalSerialPort": "1.0.0-*",
"System.Security.Cryptography.Algorithms": "4.0.0",
"System.Threading.Thread": "4.3.0"
},
"frameworks": {
"netcoreapp1.1":
{
"imports": "dnxcore50",
"dependencies":
{
"Microsoft.NETCore.App":
{
"type": "platform",
"version": "1.1.0"
}
}
},
"netstandard1.4":
{
"imports": "dnxcore50"
},
"net462": {
"dependencies": {
}
}
}
}
编译时,我会收到多个警告:
C:\ Program Files(x86)\ MSBuild \ Microsoft.NetNative \ ARM \ ilc \ IlcInternals.targets(936,5):警告:ILTransform_0003:方法'GroupSelect.StartGroupLoop(byte [])'将始终抛出由于缺少方法'ThreadStart..ctor(object,IntPtr)'而导致异常。可能有一个组装缺失。
所有警告都与引用的库有关。
我尝试过这个主题的解决方案,但没有任何帮助: Can't find System.Threading 4.0.10 on Raspberry Pi on Windows 10 IoT
答案 0 :(得分:0)
我解决了问题。
首先 - 在UWP项目引用的每个项目中,拥有UWP配置(例子)很好:
"uap10.0": {
"imports": "dnxcore50",
"runtimes": {
"win10-arm": {},
"win10-arm-aot": {},
"win10-x86": {},
"win10-x86-aot": {},
"win10-x64": {},
"win10-x64-aot": {}
},
"dependencies": {"System.Threading.Thread": "4.0.10.0" }
}
第二件事 - 您无法在UWP应用中使用线程。您必须将您的主题重写为异步,等待,然后使用任务。