Xamarin.Forms:重新安装Visual Studio 2019 V 16.11.11预览1.0之后,在调试模式下运行错误程序。

发布于 2025-01-21 08:54:31 字数 1302 浏览 0 评论 0原文

Windows 10崩溃后,我不得不重新安装Visual Studio 2019。我的程序是根据VS 2019 16.9.3制定的,重新安装的版本为16.11.11预览1.0。 我已经在mono.android上遇到了问题,因为“社区”文件夹已被“ Preview”替换(此问题已在上一篇文章中固定,这要归功于Liyun Zhang)。

我现在有一个新问题以调试模式运行该程序。这是错误消息:

从“ c:\ users \ marce.nuget \ packages \ xamarin.forms \ 4.5.0.396 \ build \ net46 \ net46 \ xamarin.forms.build.tasks.dll”中实例化任务“ XAMLCTASK”。无法加载文件或汇编'Microsoft.build,版本= 15.1.0.0,Cultur =中性,publicKeyToken = B03F5F7F7F11D50A3A'或其依赖项之一。找不到指定的文件。 Memocourses.android C:\ Users \ Marce.nuget \ packages \ xamarin.forms \ 4.5.0.396 \ build build \ xamarin.forms.targets。

这是Xamarin.forms.targets中的代码:

<XamlCTask
        Assembly = "$(IntermediateOutputPath)$(TargetFileName)"
        ReferencePath = "@(ReferencePath)"
        OptimizeIL = "true"
        DebugSymbols = "$(DebugSymbols)"
        DebugType = "$(DebugType)"
        ValidateOnly = "$(_XFXamlCValidateOnly)"
        KeepXamlResources = "$(XFKeepXamlResources)" />

我卸载了Xamarin.Forms 4.5.0.396和重新安装的版本5.0.0.2401:重置失败。 但是,从4.5.0.396到5.0.0.2401的更新有效。但是在调试模式下运行我的应用程序总是会给我相同的错误和其他错误: “ XAMLCTASK”任务被声明或错误地使用,或者在施工过程中失败。检查任务名称和组件的拼写。 Memocourses.androidc:\ Users \ Marce.nuget \ packages \ xamarin.forms \ 4.5.0.396 \ build \ build \ xamarin.forms.targets114

问题可能是由于新版本所致?谢谢您的帮助。

I had to reinstall Visual Studio 2019 after a Windows 10 crash. My program was developed under VS 2019 16.9.3, and the reinstalled version is 16.11.11 preview 1.0.
I already had a problem with Mono.Android because the ‘Community’ folder has been replaced by ‘Preview’ (this issue was fixed in a previous post – thanks to Liyun Zhang).

I now have a new problem running the program in debug mode. Here is the error message:

Failed to instantiate task "XamlCTask" from "C:\Users\marce.nuget\packages\xamarin.forms\4.5.0.396\build\net46\Xamarin.Forms.Build.Tasks.dll". Could not load file or assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The specified file cannot be found.
MemoCourses.Android C:\Users\marce.nuget\packages\xamarin.forms\4.5.0.396\build\Xamarin.Forms.targets.

Here is the code in Xamarin.Forms.targets :

<XamlCTask
        Assembly = "$(IntermediateOutputPath)$(TargetFileName)"
        ReferencePath = "@(ReferencePath)"
        OptimizeIL = "true"
        DebugSymbols = "$(DebugSymbols)"
        DebugType = "$(DebugType)"
        ValidateOnly = "$(_XFXamlCValidateOnly)"
        KeepXamlResources = "$(XFKeepXamlResources)" />

I uninstalled Xamarin.Forms 4.5.0.396 and reinstalled version 5.0.0.2401: The reset failed.
However, the update from 4.5.0.396 to 5.0.0.2401 worked. But running in debug mode my application always gives me the same error and an additional error:
The "XamlCTask" task was declared or used incorrectly, or failed during construction. Check the spelling of the task name and assembly. MemoCourses.AndroidC:\Users\marce.nuget\packages\xamarin.forms\4.5.0.396\build\Xamarin.Forms.targets114

The problem is probably due to the new version which changes the name of the folders, but how to solve it? Thank you for helping me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

留一抹残留的笑 2025-01-28 08:54:32

在Visual Studio 2019中有太多问题,我卸载了它,并重新安装了Visual Studio 2022。
但是,以下代码行

Bitmap originalImage = BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length);

会给我错误:找不到类型或名称名称“位图”(您是否缺少使用指令或汇编引用?)
如果我单击“添加对mono.android.dll”的引用,则会在标题栏的顶部显示一条消息:
'csharpaddimportCodeFixProvider'遇到错误并被禁用。

细节:
System.ArgumentException:无法找到此文件的适当参考类型:“ C:\ Program Files \ Microsoft Visual Studio \ 2022 \ 2022 \ Community \ common7 \ common7 \ ideenceNenceAssemblies \ Microsoft \ Microsoft \ Framework \ Framework \ Framework \ Monoandroid \ Monoandroid \ V9.0 \ v9.0 \ mono.android。 dll”。
在Microsoft.visualstudio.projectsystem.vs.implementation.package.automation.oavsreferences.add(字符串Bstrath)
在Microsoft.visualstudio.languageservices.implementation.projectsystem.visualstudioworkspaceimpl.applymetadatarencareferenceadded(ProjectID ProjectID,MetadAtareAreference)
在Microsoft.codeanalysis.workspace.applyprojectchanges(ProjectChanges ProjectChanges)
在Microsoft.codeanalysis.workspace.tryapplychanges(解决方案新闻,IprogressTracker progressTracker)
在microsoft.visualstudio.languageservices.implementation.projectsystem.visualstudioworkspaceimpl.trapplychanges(解决方案新闻解决方案,iProgressTracker progressTracker))
在Microsoft.codeanalysis.codeactions.applychangesoperation.trapplyasync(Workspace Workspace,iProgressTracker progressTracker,concellationToken concellation token)
在async microsoft.codeanalysis.editor.implementation.codeactions.codeactionedithishandlerservice.processoperationsasync()()
在system.runtime.exceptionservices.exceptiondispatchinfo.throw()
在async microsoft.codeanalysis.editor.implementation.codeactions.codeactionedithishandlerservice.applyasync()
在system.runtime.exceptionservices.exceptiondispatchinfo.throw()
在Microsoft.visualstudio.telemetry.windowserrreporting.watsonreport.getclrwatsonexceptioninfo(异常异常)
在system.runtime.exceptionservices.exceptiondispatchinfo.throw()
在async microsoft.codeanalysis.editor.implementation.suggestions.suggestedaction.invokeworkererasync()
在system.runtime.exceptionservices.exceptiondispatchinfo.throw()
在async microsoft.codeanalysis.extensions.iextensionManageRextensions.porformactionAsync()。

但是,如果我使用位图语句创建一个新程序,则添加参考作品。
因此,我决定从一个空项目开始,复制项目的所有页面并修改现有页面(这是一项巨大的工作!)。
我非常遗憾的是,微软无法确保在这种情况下的兼容性。
无论如何,感谢所有向我提出建议的人。

Having too many issues with Visual Studio 2019, I uninstalled it and reinstalled Visual Studio 2022.
But the following line of code

Bitmap originalImage = BitmapFactory.DecodeByteArray(imageData, 0, imageData.Length);

gives me the error: The type or namespace name 'Bitmap' could not be found (are you missing a using directive or an assembly reference?).
If I click on 'Add Reference to Mono.Android.dll', a message appears at the top of the title bar:
'CSharpAddImportCodeFixProvider' encountered an error and was disabled.'

The detail:
System.ArgumentException : Unable to find an appropriate reference type for this file: "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\Mono.Android.dll".
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.Automation.OAVSReferences.Add(String bstrPath)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.ApplyMetadataReferenceAdded(ProjectId projectId,MetadataReference metadataReference)
at Microsoft.CodeAnalysis.Workspace.ApplyProjectChanges(ProjectChanges projectChanges)
at Microsoft.CodeAnalysis.Workspace.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.VisualStudioWorkspaceImpl.TryApplyChanges(Solution newSolution,IProgressTracker progressTracker)
at Microsoft.CodeAnalysis.CodeActions.ApplyChangesOperation.TryApplyAsync(Workspace workspace,IProgressTracker progressTracker,CancellationToken cancellationToken)
at async Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ProcessOperationsAsync()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.CodeActions.CodeActionEditHandlerService.ApplyAsync()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Editor.Implementation.Suggestions.SuggestedAction.InvokeWorkerAsync()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.CodeAnalysis.Extensions.IExtensionManagerExtensions.PerformActionAsync().

However, if I create a new program with the Bitmap statement, adding Reference works.
So I decided to start from an empty project, copy all the pages of my project and modify the existing pages (it's a huge job!).
I very much regret that Microsoft did not ensure compatibility in this situation.
Thank you anyway to all those who made suggestions to me.

乙白 2025-01-28 08:54:32

通常,由Xamarin.Forms版本引起的问题与已安装的Nuget软件包不兼容/匹配。

右键单击项目解决方案以打开Nuget软件包管理器以安装Forms Project和Android平台的匹配Xamarin.Forms版本。

Normally, the issue caused by the Xamarin.Forms version is not compatible/matching with your NuGet package which you have installed.

Right click the project solution to open the NuGet Package Manager to install the package and the matching Xamarin.Forms version for the Forms project and android platform.

enter image description here

为你拒绝所有暧昧 2025-01-28 08:54:32

编辑该项目(长达数百页)从未工作。
我在

结论:解决此问题的唯一方法是重新安装相同版本,该版本用于开发解决方案。

Editing the project (several hundred pages long) never worked.
I found at https://my.visualstudio.com/ the way to download Visual Studio 16.11.13 and installed it.
I opened my project and had no mistakes. Execution in debug mode was successful from the first time. There is therefore an incompatibility between version 16.11 and newer versions, such as preview, 17.1 and later.

Conclusion: The only way to resolve this issue is to reinstall the same version that was used to develop the solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文