升級(jí)vs或者裝了.Net 7.0后, 工程框架用 net6 的 dotnet watch 出錯(cuò) 'Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0'
環(huán)境
(win/linux都一樣報(bào)錯(cuò))
工程框架
<TargetFramework>net6.0</TargetFramework>
錯(cuò)誤
dotnet watch ?? Started
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
? at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
? at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
? at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
? at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
? at System.StartupHookProvider.ProcessStartupHooks()
臨時(shí)解決方案:?工程目錄下建立 global.json 文件指定編譯框架
{
? "sdk": {
? ? "version": "6.0.403"
? }
}
知識(shí)共享許可協(xié)議
本作品采用?知識(shí)共享署名-非商業(yè)性使用-相同方式共享 4.0 國際許可協(xié)議?進(jìn)行許可狠鸳。歡迎轉(zhuǎn)載舷暮、使用牧挣、重新發(fā)布思喊,但務(wù)必保留文章署名AlexChow(包含鏈接:?https://github.com/densen2014?)粱侣,不得用于商業(yè)目的涯鲁,基于本文修改后的作品務(wù)必以相同的許可發(fā)布锋边。如有任何疑問疯坤,請(qǐng)與我聯(lián)系?。
AlexChow