InitializeComponent does not exist - xaml

InitializeComponent();
This code line appeared in all my Xaml pages' constructors in code behind.
It throws the following error:
InitializeComponent does not exist.
Now I cannot debug any page in my project although I have commented out this line.
How can I fix this?
Any help would be greatly appreciated.
Note: I'm using Xamarin Forms Portable project.
Update: When I comment out this line and run the pages, only an empty screen shows up in both IOS and Android although my pages were working correctly without error before.
Update 2: now the InitializeComponent lines are disappeared but the pages that I debug are still totally blank.
I have asked a question about this new problem on here.

I had also the same problem in Xamarin Forms Application.I fixed it by changing the Build Action to:
Embedded resource
for .xaml and .cs file both using property window.
Hope it may help you.

Change something in the page, then save it. Scarily this resolves the issue sometime.
If that doesn't work.
Update your nugget packages so Xam Forms is the latest.
"Clean" your project
Go to your project dir and delete the bin and obj from your projects via File Explorer.
Rebuild it.
Good luck.

Be sure that your Xaml page has property Custom Tool set to MSBuild:UpdateDesignTimeXaml

'Its not an issue. You can try to build your solution. Hopefully it will bulid perfectly. Most of the time I also get red under line on InitializeComponent(); like you same. Its a problem of Xamarin studio and Visual studio'

Is it the first XAML page you create in the project? or you created other pages and they don't contain this problem?
you can Check the comments here: http://forums.xamarin.com/discussion/17638/initializecomponent-does-not-exist/p4

Have you renamed your page? All XAML pages have a viewable partial class (the one you enter your logic code in to) and a hidden, system generated partial class.
If you renamed the class but did not use the VS rename macro, your system generated partial class no longer matches your editable partial class.
Try running 'Clean Solution' and 'Rebuild Solution' (both in the 'Build' menu) to see if VS can automatically detect and fix this for you.
If that doesn't work, make sure your pages are set as partial classes e.g. public partial class MyPage : Page
If you still have no luck, manually delete the 'obj' folder in your project's root folder, then rebuild again.

Simple trick:
Just edit your Xaml code..(Put space also enough..But need editing)
After edit the xaml page save project..
Now check error disappears..

In my case this was a result of intermediate build paths being too long for Windows. Moving my solution to just off the drive root C:\dev{solution} in my case solved the problem.

I had this problem because the namespace of my .xaml file did not match the namespace of the .xaml.cs file. Fixing the namespaces so they matched corrected the problem.

Related

Putting form into namespace causes MissingManifestResourceException

I created a form which worked just fine. Then I moved the form to the namespace Global.My.NameSpace by adding a namespace statement to the vb and designer.vb file (so everything is still in the same project, but in different namespaces). After that I got the MissingManifestResourceException at runtime complaining that form's resources should be properly embedded into the root namespace of my application.
I checked several solutions here at SO like suggested here, but nothing worked.
Any idea what to do to solve the problem?
Sascha
NEVER modify VS-generated files (*.Designer.vb). It will cause lot of problems.

Xamarin Forms InitializeComponent does not exist

I am learning Xamarin Forms for Visual Studio 2015 and trying to create a simple Shared project using Xaml but I keep getting InitializeComponent does not exist (as well as any reference to Xaml controls in cs classes).
It is my understanding that in the latest versions of Xamarin, Xaml works in Shared Xamarin Forms Projects (and not only in PCL projects). I've tried running the latest betas that got released less than a month ago but still no luck.
Any advice is greatly appreciated.
Turns out I had to manually change the properties for all Xaml files like so:
Build Action: Embedded resource
Custom Tool: MSBuild:UpdateDesignTimeXaml
For some reason adding new Xaml forms files doesn't set these by default in VS2015 with latest Xamarin.
I had the same issue. And it turned out to be that fully qualified Class Name (x:Class attribute in the main node) in the XAML file must match exactly the xaml.cs file's name. I corrected the namespace casing and it worked!!
This happens when your XAML markup is invalid. There is a background compilation task that parses the XAML file and generates a code file (this is normally hidden from the developer) which declares those control references. If your XAML is not valid then this task will fail silently, and your first hints are the symptoms you describe.
Comment out the contents of your XAML file using standard XML comment syntax (wrap it with <!-- and -->), then rebuild your project to clear out all of the errors. You may also need to comment out some code in your .cs files temporarily to get it to build. Once you get it building, then you can go back and start uncommenting your XAML until you find the part that was breaking it.
Try it:
Open the Package Manager Console, put the follow line:
update-package -project your_pcl_project_name -reinstall

UWP Media Element Custom control giving exception

I am having a very strange situation over here.
I refered to the UWP samples and tried Custom Media transport controls sample. I ran it and it was working just fine, like its supposed to work. But then I tried and made my own project and I copied exactly everything which was in sample project not even name of file or folder was different. And then when I ran that project it gave me debugger unhandled exception and open App.ig.cs some file like this and when i continue it stop debugging. Below is the attached snapshot of that error. Any help is appreciated this is a really strange error for me as it makes no sense at all.
Note: I have tried to run it in both blend and visual studio
I solved it by simply ignoring the style of transport controls provided in the sample, for some reason that style was not able to verify some properties so I deleted that file and made my own style file, I copied the style of default media controls and edited them, it worked for me :)

User control type not defined

I'm having trouble adding user controls to my project.
I right-click on my project and select Add -> User Control...
I then click Add
I drag a label onto the new user control, and save it.
I build the project, go back to my main form, and drag the control from the Components tab in the Toolbox onto the form.
I see the control, but I get an error:
Type 'crm.UserControl1' is not defined.
If I do this with a blank project, it works. I'm not familiar enough with vb.net or visual studio to understand what's going wrong.
If I double-click the error, it brings me to this line in the generated designer code for the form:
Me.UserControl11 = New crm.UserControl1()
and says that crm.UserControl1 is not defined. If I change it to Global.crm.UserControl1, it works, but obviously this code is overwritten when I fiddle with the designer.
Any ideas, or pointers to get me started in the right direction? Thanks in advance.
My main form had the same name as the root namespace. This is what caused the problem.
Kind of late to the party with this one but I had this problem and I think that the issue was due to the controls being built in a more recent framework than the one that I was using.
Basically my custom controls were built in 4.7, but my project was being built in 4.5.1
Once I changed the current build so that they both were the same it compiled happily.
As far as I know, it is kind of accessibility issue because you are able to solve the issue when you try to access the object globally. I think when you drag and drop the control, the definition codes of the control in the designer class automatically generated with private accessibility but I don't know why. You could try to change it as public. I hope this will work.
Way late to this party. I fixed it by referencing it in the aspx page with the following as it was missing.
<%# Register Src="~/Controls/mycontrolname.ascx" TagPrefix="ucControl" TagName="MyControl" %>

In a VB project, is it possible to have a resx file with the same name than a form?

Good Morning,
I'm working in a VB project (usually I work mostly on C#) and there is an issue at the compilation that I don't understand:
In my VB project I have a Windows Form (with its own Designer.vb and .resx) and a Resources file (with its Designer.vb), both have the same name, and it seems that it produce the following compilation error:
Error 13 The item "obj\Debug[projectName].[fileName].resources" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
I can't change the name of one of them as it's an internal design pattern (and it works in C# projects).
Doesn't VB accept such pattern ? If yes, are there any workaround possible ?
Or do I have something wrong in one of my project files ?
Regards
Edit: As my problem may not be very clear, here is the pattern I have to respect in this project :
This doesn't compile. In VB only as I'm using this pattern in C# projects without any issues.
You probably have a duplicated entry inside the form.designer. I ran across this problem once
Goto to your Solution Explorer, Select your project and click on the show all files icon at the top of the Solution Explorer. You should then be able to expand out your form.vb to see all the sub files. Look for a frmMain.Designer.vb and check it for a duplicate resource entry. If that doesn't work try cleaning your Solution
Extracted from here, check the link it may help:
VB.net designer error
Edit: I would delete the form. Save the code behind and create it with another name pasting the code.
Finally I found where the problem was:
It was an issue with namespaces, as VB generated in VisualStudio doesn't provide any namespace by default in WinForms, ones I gave a namespace to the form and the designer of the form, and gave a different namespace to the second resx (via it's properties/Custom Tool Namespace) it compile.