本文介绍了当前上下文 Xamarin 中不存在名称资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class MainActivity : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
EditText val1 = FindViewById<EditText>(Resource.Id.txtuser1);
EditText val2 = FindViewById<EditText>(Resource.Id.txtuser2);
错误:
名称Resource"在当前上下文中不存在.
推荐答案
我今天在我的 Xamarin
应用程序中遇到了同样的问题.我尝试了以下事情
I was facing the same issue today in my Xamarin
application. I tried the following things
- 清理解决方案并重建
- 关闭 Visual Studio 并再次打开
- 删除
obj
和bin
文件夹并重建项目
- Clean the solution and rebuild
- Close Visual Studio and open again
- Delete the
obj
andbin
folder and rebuild the project
以上这些都不适合我.真正的问题是因为文件 Resource.Designer.cs
已从我的项目中排除,并将其包含在解决方案中为我解决了该问题.
None of the above things worked for me. The real issue was because of that the file Resource.Designer.cs
was excluded from my project and including that to the solution fixed the issue for me.
希望能帮到你
这篇关于当前上下文 Xamarin 中不存在名称资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!