简体   繁体   English

C#/ Xamarin.Forms共享项目中的其他文件

[英]Miscellaneous files in C#/Xamarin.Forms Shared Project

All .cs file in my Xamarin project are Miscellaneous files http://prntscr.com/cp3q4w . Xamarin项目中的所有.cs文件都是其他文件http://prntscr.com/cp3q4w I have no Quick Actions and Refactorings support, and it seems like there is somehow missing reference to Xamarin.Forms http://prntscr.com/cp3qzr ,but i dont get compile error for not recognizing xamarin components. 我没有快速动作和重构支持,而且似乎在某种程度上缺少对Xamarin.Forms的引用http://prntscr.com/cp3qzr ,但是由于未识别xamarin组件而没有编译错误。 This is Xamarin.Forms Shared project. 这是Xamarin.Forms共享项目。

Tried with this solution: i) Clear the cache ii) Open the solution iii) Unload all projects iv) Load Android project and then fix nuget references v) Once the references were fixed, I loaded the shared project. 尝试过此解决方案:i)清除缓存ii)打开解决方案iii)卸载所有项目iv)加载Android项目,然后修复nuget引用v)修复引用后,我加载了共享项目。 Now everything seems to work. 现在一切似乎都正常了。 But, didn't succeed. 但是,没有成功。

Anyone had similar problem? 有人有类似的问题吗? Any suggestions for solution? 有解决方案的建议吗? Thanks. 谢谢。

First thing to try if your solution is checked in to source control: 如果您的解决方案已签到源代码管理,请尝试的第一件事:

If this fails, try this: 如果失败,请尝试以下操作:

  • Starting a new Visual C# -> Cross Platform -> Mobile App (Xamarin.Forms) solution in Visual Studio 2017. I recommend trying a ".NET Standard" project rather than a "Shared Project". 在Visual Studio 2017中启动新的Visual C#->跨平台->移动应用(Xamarin.Forms)解决方案。我建议尝试“ .NET Standard”项目而不是“ Shared Project”。

  • Make sure the solution compiles and runs to make sure you have all the necessary components for Xamarin Installed. 确保解决方案能够编译并运行,以确保您已安装Xamarin的所有必需组件。

  • Do a back up of this clean solution, or commit it to source control. 备份此干净的解决方案,或将其提交到源代码管理。

  • Upgrade all the NuGet packages if necessary 如有必要,升级所有NuGet软件包

  • Pull all the files in from your old solution and see if you get the same problem. 从旧的解决方案中拉入所有文件,看看是否遇到相同的问题。 Just remember to make sure that the files are added as the correct type of file. 只要记住确保将文件添加为正确的文件类型即可。 For example xaml files must be set to "Embedded resource". 例如,必须将xaml文件设置为“嵌入式资源”。

If you still have trouble, please post the error that you get, and upload your solution somewhere so we can have a look. 如果您仍然遇到问题,请张贴您收到的错误,然后将解决方案上载到某处,以便我们查看。

This also happened to me. 这也发生在我身上。 It still does every now and again. 它仍然时不时地这样做。

These steps work for me: 这些步骤对我有用:

  1. Close your solution. 关闭您的解决方案。
  2. Delete the packages folder from your solution folder or just rename it to packages.old 从解决方案文件夹中删除packages文件夹,或仅将其重命名为packages.old
  3. Open your solution and restore the NuGet packages. 打开您的解决方案并还原NuGet软件包。
  4. The new class will now show up correctly and your intellisense should work again. 现在,新班级将正确显示,您的智能提示将再次起作用。

Does anyone have an idea what could cause this though as I don't see any errors when building? 有谁知道是什么原因导致的,尽管在构建时我没有看到任何错误?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM