c# - 重命名操作被取消或无效

标签 c# visual-studio xamarin.forms

我在 Windows 10 操作系统版本 18362.207 上使用 Visual Studio 2019。

我正在尝试使用“Master-Detail”项目模板制作一个跨平台的 Xamarin 应用程序。

从模板创建项目后,我想重命名 <ProjectName>\Models\Item.cs类更有意义的东西。但是,任何使用 IDE 中内置的重构工具的尝试都会失败。

如果我输入名称代替类名,并尝试使用重构工具重命名类 Item任何其他(我试过 TestTestThingieConversation 等)并将鼠标悬停在新名称上并单击灯泡和

“将 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 )

为清楚起见,我的步骤是

  1. 打开 Visual Studio 2019
  2. 新项目
  3. Mobile App (Xamarin.Forms)
  4. 进入<ProjectName>\Models\Item.cs并尝试重命名 Item类,使用灯泡菜单在别处更改名称
  5. 失败了

我做错了什么吗?我希望不必在其他一千个地方重命名一个类!

最佳答案

这绝不是解决方案,但我相信这是使用 Xamarin Forms 时 VS 2019 中的一个错误,如果你安装了 VS 2017,你可以在那里重命名你的文件,它对我有用。

关于c# - 重命名操作被取消或无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56862275/

相关文章:

xamarin.forms - Xamarin Forms 数字键盘 - 启用空格和破折号按钮

c# - Prism.Forms Unity 应用程序中的导航页面未显示后退箭头?

javascript - Fullcalendar 不在客户端呈现事件

c# - 与linq的连接查询不同

c# - 在多个页面上打印流程文档滚动查看器

c# - 在 Observable Items 生成时处理它们

c - 如何调试超过 210 个元素的 char 数组

c# - Azure 应用服务在执行检索时抛出未找到数据库的错误

windows - docker -无法计算缓存键: not found - runs fine in visual studio

visual-studio - Visual Studio 云测试 : Deleting uwanted load tests