So I am new to Xamarin studio and have been stuck on a little bit of a frustrating issue. Every time I make a change within the resources file, the Resource.designer.cs file does not regenerate and recognize the new changes. Does anyone know how I can update the changes so that I can interact with newly added widgets? I appreciate the help.
Check your Android's .csproj file and make sure the following AndroidResgenXXXX properties are included within a PropertyGroup (within the Project)
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
<AndroidResgenClass>Resource</AndroidResgenClass>
Related
I have a Visual Studio solution containing a Xamarin Android project.
Since the migration to VS17, the Resource designer from Xamarin started behaving strangely.
If I add a new XML layout in the Resources/layout folder, the Resource Designer will only notice it after I exclude, and re-include the new file.
However, if these steps are reproduced with a second new file, the Resource designer will notice the second new file, but the first one will be erased.
This makes refactoring impossible, and leads to completely corrupted project.
Has anyone a workaround for this ?
Visual studio 2017 entreprise version : 15.3.0
Xamarin version : 4.6.0.295 (306f67a)
On Android, files in the Resources folder should have its build action set to 'AndroidResource' in order for the Resource Designer to notice them.
So when you add existing files, make sure the build action is also set properly.
Same goes for files in the resource folder on iOS.
Only, the build actions is called 'BundleResource'.
Sorry I am kinda new to C#/.NET and Visual Studio.
The project was built by my supervisor, and I am suppose to make some changes on it. I tried to make some changes on the ModuleController file, but when I click Build Solution, it runs, but it did not affect the website. The controller contain SQL function, even if I make any changes on this file (including delete the entire code), and then refresh the webpage, it can still run the SQL function which has been deleted and output the result.
And when I try to Rebuild Solution or Rebuild Website, I get "circular file references are not allowed". I add batch="false" to Web.config file, it can run, but still get the first problem: the code could not reflect on the webpage.
I have read http://www.gitshah.com/2011/04/how-to-fix-circular-file-references-are.html, but I have checked my folder, there is no ascx files. Only one Global.asax file...
Why is that, is there any possible solutions?
Could anyone helps me? Thanks.
I have a working Android Project with a .Droid-Solution and a SharedProject. I started the App on my phone and it works great. Now, I just added a blank Windows 10 Universal Solution and did the instructions here: http://developer.xamarin.com/guides/xamarin-forms/platform-features/windows/installation/universal/
Anyway... I did nothing else. Just followed the instructions and tryed to start the Windows 10 Universal app, but I get this error:
"CS0103 C# The name 'InitializeComponent ' does not exist in the
current context."
I googled a few times, but didn't find something that helps.
I also tryed the example here: https://github.com/jamesmontemagno/Hanselman.Forms with the same error.
Does someone know this error with Xamarin.Forms and Windows 10 Universal Apps?
Everytime you create a .XAML page in Xamarin.Forms, you are using partial class definitions in three different places.
Your actual .xaml file will have a Class="" attribute on the root element that defines the namespace and class name.
The actual root element type will define the base class that your new .xaml page is subclassing. By default, that would be ContentPage.
You also get a .xaml.cs file that is linked which contains a partial class definition as well. This is your code behind file, where you put page specific code, this is also where the InitializeComponent() call is called from the constructor.
This call serves to parse the xaml contents and fill out the references to all the views you gave ids to using x:name="something" in xaml.
InitializeComponent() is automatically generated by xamarin, it is part of the output of your project and it should get re-generated each time you edit your .xaml file.
In order for this to happen, in the properties of your .xaml file Build Action needs to be set to "Embedded Resource" and the Custom Tool needs to be set to "MSBuild:UpdateDesignTimeXaml"
Now, even with these values set correctly, there are bugs in Xamarin which can lead to the file not getting generated and you getting the error.
The absolute first thing to try when you get this error is to right click the .xaml file and click on "Run Custom Tool".
You only need to do this once, on ONE xaml file, the tool will automatically run for all the .xaml files in your project.
This is somethign that I have to do about once a day during my normal development and it started when i switched to VS 2015. Your mileage may warry.
Another very important thing to check is the BuildTargets in your .csproj file.
The way Xamarin is able to do it's thing is by specifying build actions that call into it's DLL that you get when you install the Xamarin.Forms nuget package. Sometimes the build actions import line get's messed up and this causes all sorts of problems.
Unload your .csproj and find the line that imports Xamarin.Forms.targets.
It should look something like this:
<Import Project="..\..\packages\Xamarin.Forms.2.0.0.6484\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.0.0.6484\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
make sure that the version in here matches the version of Xamarin.Forms from your packages.config file, then make sure that you can actually navigate to your project's root folder, and find the actual file the important line is referring to. Ie, packages\xamarin...\Xamarin.Forms.targets
A common thing to do is to delete everything from \packages\ and let nuget re-download everything on your next build. Just make sure the version in your .csproj import and the version in packages.config is the same.
If all of these are done, you should have a valid generated partial class that implements InitializeComponent() and the errors should dissapear.
Just as an update to this:
New, clean Windows 10 Pro installation with all updates in a VM.
New, clean Visual Studio 2015 Community Edition installation with all options selected and all updates.
New project: Blank Xaml App (Xamarin.Forms.Portable) with nowt but generated code.
The project will not build as InitializeComponent in App.xaml.cs does not exist in the current context.
Opinion: this Xamarin add-on is a free add-on on top of a free product, but even so this kind of thing doesn't really inspire you to use it...
I'm currently developing an app with Mono, I recently updated to Xamarin Studio 4.0.8, and was having problems with the design elements not being added to the solution.
I tried to edit manually the designer.cs, and later on I erased it, hoping the program will regenerate it again, with the layout changes.
I have tried:
Rebuilding it
Cleaning and rebuilding
Erasing the file through the file explorer
And it still doesn't regenerate properly, Xamarin creates the Resource.designer.cs but it's empty, and when compiling it returns this:
Error CS0103: The name 'Resource' doesn't exist in the current context (CS0103)
Help please...
Lots of time having this issue. What i did:
Remove "resources.designer.cs" using Xamarin (secondary button->remove).
Go to command line (finder on Mac/Explorer on Windows) and delete manually the file (be sure you deleted it).
Go to Xamarin, clean->build (this will regenerate the resoruces.designer.cs).
As you remove the file from the project, you have to add it again. secondary button over project-> add Files->select Resources.designer.cs (tipically on /Resources folder).
Make sure the "Build Action" of the Resource.designer.cs file is Compile (sometimes it takes a different build action by default).
Clean and build.
At least it have worked most of the time.
I had this happen a while back. If you right click on your XML file, and click properties. Make sure that the Build Action is set to "AndroidResource"
If I recall correctly that fixed it
This work for me:
Open your .designer.cs file and erase all class content, letting only the class declaration empty.
open .xib file or storyboard that give you trouble with your .cs file.
update Identify>Class property of the view that use that .designer.cs class removing, unfocus, focus and setting again the property value.
save
rebuild
I have included the following folders within my project:
layout
layout-land/
layout-port/
I placed the my main.axml file in all of them, with a couple of tweaks to the UI of course. But when I change the orientation on the device, noting happens.
I'm doing basically the same as this tutorial, but I'm making use of Xamarin and Visual Studio: http://www.how-to-develop-android-apps.com/how-to-make-a-landscape-layout-in-android/
Not really sure what I'm doing wrong?! Could someone please assist?
Okay, so basically I had a folder called layout-normal. This caused the layout-land to be ignored for some or other reason. I removed the folder from the project and it worked!