For me I just had to uninstall Xamarin.Forms on my iOS project (the one the error indicated the method didn't exist for). Then re-install (the specific version I was looking for). This happened to me after I tried to roll back an update to Xamarin.Forms while trouble shooting errors with Bitrise.
99% This problem is because you copied some code from your other projects or other resources and just forgot to make all the necessary changes to fit your own project !
well, the most important thing is to consider .xaml file and its** .cs** C# code-behind are just different parts of one class and that's why in .cs you declare the page class as : public **partial** class PageNameCls : PageType
So when the code-behind.cs Runs: InitializeComponent(); it expects to find the other parts of the class in the same NameSpace .
you just have to check the x:Class attributes in your page .xaml to be the same as the namespace you are using in your .c code-behind file and make sure its saved so the C-sharper knows your changes even-though it has no difference when you debug your project because the build process is set to save all files by default (visual studio 2017 )
that's all.
hope it solve your problem
this solved the problem just correct the x:Class Attribute to be the same as the namespace
For me it was the wrong x:Name namespace I used in the xaml code of the page because I had changed namespace in code behind.After that I had to change build action of page in properties to Content and back to Embedded Resource again for the error to go away
The solution that WORKED was.
1. Make sure the x:Class name in the xaml file is spelled correctly as in the public partial class
2. The filename eg. OnboardingStyles.xaml must be the same name in the x:Class (i.e. OnboardingStyles) and the partial class (i.e OnboardingStyles)
Posts
For me I just had to uninstall Xamarin.Forms on my iOS project (the one the error indicated the method didn't exist for). Then re-install (the specific version I was looking for). This happened to me after I tried to roll back an update to Xamarin.Forms while trouble shooting errors with Bitrise.
Me too, in my case i renamed a xaml page....and i had the error... build was the solution! Thank you!
Add x:Class="Yourprojectname.Views.YourprojectPage" at the top of xml page above the Title. Hope this helps you
ex:
this solved the problem just correct the x:Class Attribute to be the same as the namespace
The namespace and class names need to match so they are both part of a partial class
namespace XXX
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow
{
//...
}
}
Press CTR + S, it saved my Xaml file, cleaned my project then built it and it worked.
For me it was the wrong x:Name namespace I used in the xaml code of the page because I had changed namespace in code behind.After that I had to change build action of page in properties to Content and back to Embedded Resource again for the error to go away
@Xigmond I know this is old, but you are a genius
The solution that WORKED was.
1. Make sure the x:Class name in the xaml file is spelled correctly as in the public partial class
2. The filename eg. OnboardingStyles.xaml must be the same name in the x:Class (i.e. OnboardingStyles) and the partial class (i.e OnboardingStyles)
THATS IT
Save the files and the error was gone.
I am facing the same problem even tried saving it in xml but cant resolve it please help