UWP: Package is not getting generated with error - c#

I have a about 2 yr old in UWP that we are successfully compile and creating package until Visual Studio 16.9. But yesterday I update my Visual Studio to 16.10 and now whenever I try to create a package I got following error
Severity Code Description Project File Line Suppression State
Error System.Runtime.InteropServices.COMException (0x80070716): The
specified resource name cannot be found in the image file. (Exception
from HRESULT: 0x80070716) at
Microsoft.VisualStudio.Deployment.AppxFactory.CreatePackageReader(IStream
inputStream) at
Microsoft.VisualStudio.Deployment.AppxInteropHelpers.GetAppxManifestReader3(String
appxFilePath) at
Microsoft.Build.AppxPackage.AppxPackageFile.ReadAppxPackageFile()
at
Microsoft.Build.AppxPackage.GenerateAppInstallerFile.AddPackageDependencies(XElement
dependenciesRoot) at
Microsoft.Build.AppxPackage.GenerateAppInstallerFile.AddDependenciesIfNecessary(XElement
element) at
Microsoft.Build.AppxPackage.GenerateAppInstallerFile.CreateAppInstallerFile(String
uri, Boolean addOnLaunchUpdateCheck) at
Microsoft.Build.AppxPackage.GenerateAppInstallerFile.ExecuteImplementation() Package C:\Program
Files (x86)\Microsoft Visual
Studio\2019\Community\MSBuild\Microsoft\VisualStudio\v16.0\AppxPackage\Microsoft.AppXPackage.Targets 6362
I initially thought that installation of VS is corrupted, so I try to reinstall but it was not the case. My application is working fine in debugger mode. But when I try to create package it fails. I can however able to create package if I change my Windows SDK Target to latest 2004 but then when I run the application from Installed version on test machine it crash after Splash Screen i.e. my AppShell do not load.
When searching that error in google it shows that some windows back service has this issue. No reference is found for UWP Package in this regard. I am not sure if some image file is missing from package or application or if some system "Image" is missing as in packaging of application.
Any help is appreciated thanks.
EDIT: After I run DSIM to restore windows image it create it once, but only once.
EDIT 2: I found an old machine with Visual studio 16.7.4 and it compile same exact code without any modification just fine. So either the Visual studio update or Windows update (it happens to be my machine get updated to 21h1 today only) with and I didn't realise as I have automatic update enable.

Related

Visual Studio Build Error: The target "MainResourceGeneration" does not exist in the project

Getting the following error 'The target "MainResourceGeneration" does not exist in the project' on Any project I try to build with Visual Studio. Cannot run debugger, cannot build/rebuild solution or projects.
Backing up a bit:
I had VS2012 and VS2017 (always used 2017) installed.
Got an error that pointed me to the Microsoft.Common.CurrentVersion.targets file. I mistakenly edited this file thinking it was part of my project.
Started getting the aforementioned build error on all my projects. Including simple, brand new, unaltered C# .NET framework console app.
Also had the same error on VS2012...
Tried VS2017 repair.
Tried VS2017 uninstall/reinstall.
Tried uninstall VS2017/2012, manually delete visual studio program files folders, reinstall 2017.
Still have the problem. Brand new fresh VS2017 install and not even a new console app will build.
Build output just shows this...
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(2789,7): error MSB4057: The target "MainResourcesGeneration" does not exist in the project.
Visual Studio Build Error: The target “MainResourceGeneration” does not exist in the project
Since this issue still occurs on a new console app, it seems that the Visual Studio installation file is corrupted. You can try to following steps to clean up the Visual Studio and reinstall it:
See if you have this file on your machine:
"%programfiles(x86)%\Microsoft Visual
Studio\Installer\resources\app\layout\InstallCleanup.exe"
Start an admin command prompt
Right-click on cmd.exe and select Run AsAdministrator
If so, please launch it from an admin command prompt with a -full
param
InstallCleanup.exe -full 
If not, please manually delete the "%programfiles(x86)%\Microsoft
Visual Studio\Installer” folder
Verify that your initial install location for VS is removed.  If it
is not, delete it manually.
Relaunch the newly downloaded vs_enterprise.exe (or
vs_professional.exe or vs_community.exe…)
Allow the first step to install the installer  Once the installer
comes up and you can see workload choices (.net desktop and the
like), close it
Go launch the same InstallCleanup.exe to clean up old build of VS
Then relaunch vs_enterprise.exe and install VS
Please let me know if it works for you.
I tried several further steps like manually deleting Visual Studio related folders in my Users and ProgramData directories, and repairing .NET framework. None of those changes worked. Still had the same issue.
As a last resort I fully uninstalled .NET Framework (4.7.1) and grabbed the latest version (4.7.2) from https://www.microsoft.com/net/download/dotnet-framework-runtime. I no longer received the error and could then build my projects again.
I do not know or understand the root cause, but a full uninstall/reinstall of .NET framework fixed it...

Xamarin forms (Visual Studio) - Error while loading project after updating to Xamarin and jdk 1.8

After updating Xamarin for Visual Studio to v'4.3.0.789' and jdk 1.8. I am getting this error. I have tried all possible way but unable to resolve.
Severity Code Description Project File Line Suppression State
Error An error occurred trying to install required android components
on Project 'CrossPlatformApp2.Android'. Project
'CrossPlatformApp2.Android' requires the following components
installed on your machine: Xamarin.Android.Support.v7.AppCompat
JavaLibraryReference:
https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip-m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0.aar-23.3.0.0
AndroidResources:
https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip-m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0.aar-23.3.0.0
Xamarin.Android.Support.v7.MediaRouter JavaLibraryReference:
https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip-m2repository/com/android/support/mediarouter-v7/23.3.0/mediarouter-v7-23.3.0.aar-23.3.0.0
JavaLibraryReference:
https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip-m2repository/com/android/support/mediarouter-v7/23.3.0/mediarouter-v7-23.3.0.aar-23.3.0.0
AndroidResources:
https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip-m2repository/com/android/support/mediarouter-v7/23.3.0/mediarouter-v7-23.3.0.aar-23.3.0.0
Please double-click here to install it.
Intallation Errors: XA5209 Unzipping failed. Please download
'https://dl-ssl.google.com/android/repository/android_m2repository_r29.zip:m2repository/com/android/support/appcompat-v7/23.3.0/appcompat-v7-23.3.0.aar'
and extract it to the
'C:\Users\prashantvarma\AppData\Local\Xamarin\Xamarin.Android.Support.v7.AppCompat\23.3.0.0\embedded'
directory XA5209 Reason: The process cannot access the file
'C:\Users\prashantvarma\AppData\Local\Xamarin\Xamarin.Android.Support.v7.AppCompat\23.3.0.0\embedded\res\drawable-xxhdpi-v4'
because it is being used by another process. XA5207 Please install
package: 'Xamarin.Android.Support.v7.AppCompat' available in SDK
installer. Java library file 'C:\Program Files
(x86)\Android\android-sdk\extras\android\classes.jar' doesn't exist.
XA5207 Please install package:
'Xamarin.Android.Support.v7.MediaRouter' available in SDK installer.
Java library file 'C:\Program Files
(x86)\Android\android-sdk\extras\android\classes.jar' doesn't exist.
XA5207 Please install package:
'Xamarin.Android.Support.v7.MediaRouter' available in SDK installer.
Java library file 'C:\Program Files
(x86)\Android\android-sdk\extras\android\libs/internal_impl-23.3.0.jar'
doesn't exist. 0
However, my old application (created in old Xamarin version) is able to run.
I used to have this error as well. Try the underlying fix I wrote and use myself.
If you get multiple errors when trying to build the project (e.g. ~14 errors) which state that the unzipping of packages failed and that you will have to do it manually, then do the following:
Go to the path stated in the error
Go a folder (or 2) higher until you see a folder called "zips".
Delete all the content in that (“zips”) folder and retry building.
The build will take a bit longer, so have some patience.
This error is caused by a corrupted zip of a needed package in the build, mostly caused by aborting a build. Deleting the files will force the compiler to redownload the packages which will fix the corrupted zips issue.
Ok, I am able to resolve this issue simply by uninstalling Xamarin and installing again the older version (v4.2.1) that shows in Visual studio Professional 2015 Setup.

WPF Designer unable to find SQLite.Interop.dll

In my WPF application a seperate class-library is used to persist session-data to a SQLite-database. I ran into the well known problem of the SQLite.Interop.dll not being found, after adding the class-library-dll to my WPF-project. I manually added x86/x64-dlls to the project and installed the SQLite nuget-packages to the wpf-project as well, the application is running fine now.
However the VS WPF-Designer is still unable to display views that utilize my class-library and crashes with "SQLite.Interop.dll not found". This obviously 'limits' my ability to change the design of the views. Any ideas on how to provide the designer with the desired dll??
This is not a duplicate of the numerous posts about the SQLite.Interop-dependency, as my problem is solely related to the WPF-designer in Visual-Studio.
To fix this problem, copy the x86 version of SQLite.Interop.dll to the Visual Studio IDE folder. For a default installation of Visual Studio 2019 Community, the path is "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE".

SwipeRefreshLayout does not exist on Visual Studio + Xamarin

I have a problem when I'm trying to run my program on my phone. I'm using Visual Studio 2015 and Xamarin for developing android app. I got this error :
error: package android.support.v4.widget.SwipeRefreshLayout does not exist
android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener
Here is my References Pic, I already added Xamarin.Android.Support.V4 and Xamarin.Android.Support.V13 and this is my SDK Manager Pic
Does anyone see anything that I missed?
A downloaded package (zip file) from Google is truncated/corrupt and does not inflate properly can cause this.
Try:
Remove the Nuget package and re-add it. Perform a clean all/build all on your solution
Otherwise:
Check the following location:
C:\Users\[YourUserID]\AppData\Local\Xamarin\Android.Support.v4\[Version])
You can delete those files, restart Visual Studio and perform a clean all/build all on your solution and those support files will be downloaded and cached from Google again.

Visual Studio compilation error UWP

I am building a UWP app on Visual Studio 2015 Update 1. I am encountering errors where Compiler says "async is not a feature of C# 4.0 use 5.0 or greater", "Windows namespace cannot be found"
Error CS8025 Feature 'async function' is not available in C# 4.
Error CS0246 The type or namespace name 'ConnectionProfile'
However upon closing my solution and reopening it these errors disappear. And my app runs(in debug mode). However after a few debug sessions the problem resurfaces.
To Correct any errors on my part I Have :
1> Reset VS user Settings
2>Reinstalled VS
3>Reset Windows 10
But the problem doesn't want to go. I am using Windows 10 Home Edition and also I don't use insider builds. Recreated my project from scratch
As a result even the most basic tasks performed in my code appear erroneous.
Can you revise if you have installed Microsoft.NETCore.UniversalWindowsPlatform as a nuget package? Wen you create a new uwp project, automatically its added.
I had similar problem that some namespaces was not encountered and the answer was this nuget package.

Categories

Resources