我在 Windows 10 操作系统版本 18362.207 上使用 Visual Studio 2019。
我正在尝试使用“Master-Detail”项目模板制作一个跨平台的 Xamarin 应用程序。
从模板创建项目后,我想重命名 <ProjectName>\Models\Item.cs
类更有意义的东西。但是,任何使用 IDE 中内置的重构工具的尝试都会失败。
如果我输入名称代替类名,并尝试使用重构工具重命名类 Item
任何其他(我试过 Test
, TestThingie
, Conversation
等)并将鼠标悬停在新名称上并单击灯泡和
“将 Item
重命名为 Conversation
”
我立即收到一条错误消息,指出重命名操作已取消或无效。我无法想象为什么……下面是我收到的有关此错误的日志。
=====================
7/2/2019 10:34:46 PM
Recoverable
System.ArgumentNullException: Value cannot be null.
Parameter name: relativeSourceFilePath
at Microsoft.Requires.NotNull[T](T value, String parameterName)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.HandleBeforeRefactorFailure(Int32 promptContinueOnFail, String relativeSourceFilePath, String errorMessage, HashSet`1 failedFiles)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass744_0.<<HandleBeforeRefactorNotify>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
at Microsoft.VisualStudio.Threading.JoinableTask`1.CompleteOnCurrentThread()
at Microsoft.VisualStudio.ProjectSystem.ProjectMultiThreadedService.ExecuteSynchronously[T](Func`1 asyncAction)
at Microsoft.VisualStudio.ProjectSystem.VS.Implementation.Package.ProjectNode.<>c__DisplayClass577_0.<HrInvoke>b__0()
at Microsoft.VisualStudio.ProjectSystem.VS.HResult.Invoke(Func`1 action, IServiceProvider vsShellServiceProvider, IProjectFaultHandlerService projectFaultHandlerService, UnconfiguredProject project)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.VisualStudio.ProjectSystem.CommonProjectSystemTools.Rethrow(Exception ex)
at Microsoft.VisualStudio.ProjectSystem.ProjectErrorReporting.<>c__DisplayClass6_0.<SubmitErrorReport>b__0()
at Microsoft.VisualStudio.ProjectSystem.ExceptionFilter.<>c__DisplayClass2_0.<Guard>g__action|0()
at GuardMethodClass.GuardMethod(Func`1 , Func`2 , Func`2 )
为清楚起见,我的步骤是
- 打开 Visual Studio 2019
- 新项目
-
Mobile App (Xamarin.Forms)
- 进入
<ProjectName>\Models\Item.cs
并尝试重命名Item
类,使用灯泡菜单在别处更改名称 - 失败了
我做错了什么吗?我希望不必在其他一千个地方重命名一个类!
最佳答案
这绝不是解决方案,但我相信这是使用 Xamarin Forms 时 VS 2019 中的一个错误,如果你安装了 VS 2017,你可以在那里重命名你的文件,它对我有用。
关于c# - 重命名操作被取消或无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56862275/