Multiple "No resource found..." and "Error receiving parent for item" for fresh Xamarin project in VS 2017 - visual-studio

I have created a new project for Xamarin in Visual Studio 2017 Community Edition 15.8.3. Then I added a few changes in the MainPage.xaml and cs and now I am getting these error on building the solution.
The errors refer to styles.xml which I didn't touch.
I was seeing this error earlier which required required restarting VS, rebooting computer, cleaning obj and bin directories, upgrading VS, etc.
I prefer to not do such things blindly.
Is there any systematic solution for this problem?

See if you have not change any of this in the MainPage.xaml
If not put here your content in that page just to see if anyone see the error.

This worked for me in a VS2017 cross-platform solution targeting Android 7.1:
Clean your project and rebuild it.
Change each XAML file properties:
Change the Build Action from "Embedded Resource" to "Compile" or "C# compiler"
Rebuild your project (it will produce errors)
Close VS2017 and delete the .VS folder and reopen solution
Change each XAML file properties:
Change the Build Action back to "Embedded Resource"
Rebuild and it was good for me.
On a separate project, the solution above did not resolve my errors and I also performed these additional steps with success:
Using this guide, I was able to determine that I was missing the following Nuget reference:
Xamarin.Android.Support.v7.AppCompat
After clean and build, close, delete .VS folder and reopen... I checked the log again and was able to determine that I was missing the following Nuget reference:
Xamarin.Android.Support.Design
Another clean and build and those problems went away... leaving me with remnant code issues that I was able to resolve.
After another clean and build... I received another error that I was missing the following Nuget reference:
Xamarin.Android.Support.v7.CardView
Another clean and build... no errors.

Related

Error publishing .NET MAUI project: the target "_GenerateAppxPackage" does not exist

I have a .NET MAUI project that was created with VS2022 Preview 2, and it builds without errors or warnings and works as expected in the debugger. Prior to updating Visual Studio to Version 17.4.0 Preview 4.0 I was able to publish the project as a sideloadable MSIX from within VS.
Since updating, I get the following error when I click Create in the Create App Packages wizard:
MSB4057 The target "_GenerateAppxPackage" does not exist in the project.
The error is listed against the MAUI project's .csproj file.
I've tried creating a separate new, default MAUI project in the new preview - this publishes ok and (as far as I can see) doesn't contain _GenerateAppxPackage anywhere within its files or project structure. So for now I'm assuming this isn't something new that was added with the preview.
I found some references to _GenerateAppxPackage on the web but they appear to refer to Azure integration. My project is a stand-alone data transformation app that doesn't even access the net.
I'm at a loss what to try next. I don't know what this target refers to, where it should "exist" within the project, or what it does. Can anyone help me understand the problem and/or point me to a solution?
Update: 2022-10-28:
I tried deleting the project structure and creating it from scratch with File -> New Project, then adding back only the .cs and .xaml files. Publishing the recreated project gives me the same error.
I also tried uninstalling the VS preview and re-downloading and installing it. Again, publishing the project gives me the same error.
I still have no idea what is causing this, or even where to start looking.
I faced with the same problem at Visual Studio 2022 17.4.0 (net6.0-windows10.0.19041.0).
The simplest solution for me was be using the command dotnet publish directly.
At root of project just write in terminal:
dotnet publish -f net6.0-windows10.0.19041.0 -c /p:RuntimeIdentifierOverride=win10-x64
I learned today that MAUI is now in the mainline Visual Studio 2022 edition, I've tried using that instead of the preview, and I can confirm that the problem goes away. I wish I'd known about this earlier...

The target "PostBuildEvent" does not exist in the project

My application had a post build event in it but I was removing due to some required changes resulting in the following error.
The target "PostBuildEvent" does not exist in the project
So I went into my projects properties > Build Events to remove it. However once removed I would still get the error while executing the application. I then opened my .csproj to manually remove the post build event from there but that had the same result. Am I not removing the post build event properly or is there some kind of error occurring here? If there is an error what is a possible solution?
Update:
It doesn't seem to solely be a problem with any one application but all applications in Visual Studio, including new applications.
A reinstallation of Visual Studio has successfully solved the problem.

the target "UpdateDesignTimeXaml" does not exit in the project error in Xamarin Studio

I am new to mobile application developing. When I was creating a new .xaml file in new solution in the Xamarin Studio.
It gave the error:
"the target "UpdateDesignTimeXaml" does not exit".
How can I resolve this problem?
Build errors can occur if you have updated the Xamarin.Forms nuget to a newer version that requires UpdateDesignTimeXaml.
Close and reopen Xamarin Studio.
Clean all and ReBuild your project.
Ref: https://forums.xamarin.com/discussion/49152/problem-initializecomponent-and-pcl
A workaround for this is to remove the MSBuild:UpdateDesignTimeXaml from the Custom Tool of the xaml file properties in VS. Save, add MSBuild:UpdateDesignTimeXaml again and save again will force MSBuild to recreate the *g.cs file.
I had this with Visual Studio for Mac.
I fixed it by:
closing VS
manually deleting the packages, bin and obj folders
restart the project in VS
restore NuGet packages, build and run.
Got same issue in Visual Studio for Mac. Worked find with
closing VS
manually deleting the packages, bin and obj folders in both android folder and main folder
restart the project in VS
restore NuGet packages, build and run.

Creation of Release Build Failed in UWP

I am trying to build a UWP project in Release. But i am not able to create the build and I am getting an error could not copy the file "C:\Users\kumara krishnan\.nuget\packages\System.Private.Uri\4.0.0\runtimes\win8-aot\lib\netcore50\System.Private.Uri.dll" because it was not found. Also I am able to build and deploy when i keep it in debug mode. How to fix this issue?
It seems there is something wrong with your .nuget environment. You can try following steps to fix it.
Firstly delete the whole System.Private.Uri folder under C:\Users\kumara krishnan\.nuget\packages\.
Then in Visual Studio, open the Visual Studio Options dialog, click on the "NuGet Package Manager" node and make sure you have checked "Allow NuGet to download missing packages" and "Automatically check for missing package during build in Visual Studio".
After this, you can just rebuild your project and Visual Studio will automatically restore the NuGet packages your project used and download whole "System.Private.Uri" files.
You can also create a blank app and create a new instance of Uri without adding other references manually to check your environment.

Namespace not found within the same project according to intellisense, yet project builds

I have a simple ASP.Net MVC project which for some reason has issues with intellisense. It is constantly giving me errors that namespaces local to the project can not be found, even though they do exist and the project will build fine. Here's an example:
It is very frustrating as this results in me having no intellisense available whatsoever. Has any one encountered a problem like this before, and do they know of a solution?
The project itself is an MVC4 website running in VS2013 in W8 under Paralells on a Macbook Air, should that have any effect on the problem.
As stated, I have no error messages to provide as the project builds and runs successfully, but please let me know if more details are required.
I had the same issue. Try removing your project from the solution and then add it again. It worked for me. Looks like a solution file quirk.
UPDATE: this is not a permanent fix as closing and reopening visual studio brings back the issue.
UPDATE 2: while looking to fix another issue where I couldn't change the default namespace of a project (I would get a System.Runtime.InteropServices.ExternalException), I found out that it was related to Xamarin tools for Visual Studio. I proceeded to completely uninstall Xamarin. It fixed my namespace renaming issue as well as the weird type or namespace not found / intellisense issue.
I had this same issue, seems to be something with the solution file and building the project as I could replicate the problem by simply creating a new project building then restarting visual studio.
Anyway I get around it at the moment by deleting the solution file and opening the project using the project file.
For anyone reading this in 2020, a fix that I've found that has worked for me is:
cleaning the solution and unloading the projects that have dependencies such as a web API depending on a data project and an application project (right click on the project in solution explorer and find "Unload Project"),
then reloading and building each project in the order of dependence such that they build successfully (right click on the unloaded project in solution explorer and find "Reload Project").
so in my case my data project does not depend on any other project so I reloaded and built that first, then the application project which depends on the data project and finally the web API project which depended on both data and application.

Resources