Visual Studio compilation error UWP - c#

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.

Related

Error during building application with Fody and Costura via VS 2019 : Binary is being used by another process

I have a C# Console application that was developed in different machines. In this application, we chose to use Fody, because it's the only thing we found that would embed all external resource dependencies (any extra class libraries) into a single executable for our application.
Environment Detsils:
Visual Studio Version: 16.9.2 (Professional 2019)
Type: Console application
Framework: .Net Framework 4.5
Fody Version: 4.2.1
Costura.Fody Version: 3.3.3
While this application worked without any issue in one machine, it starts giving trouble to another machine. We need to get this work on both machines as we need to cover lots of work. We have compared the two environments but couldn't figure out any difference.
the behavior of the issue is as below,
The first time when I clone and build a solution it goes in a
never-ending path and I have no other option other than end tasking
the visual studio.
And I observe that MSBUILD is occupied by something and I cannot end
task it
The second time when I start the solution and build it, I am getting
the following error.
Severity Code Description Project File Line Suppression State
Error CS2012 Cannot open '<<obj folder path>>\Debug\Binary.exe' for writing -- 'The
process cannot access the file '<<obj folder path>>\Debug\Binary.exe' because it is being
used by another process.' Binary.exe <<project path>>\CSC 1 Active
I had to restart the machine to remove the obj folder. And once it is removed Same above behavior repeats.
I found below a similar question below thread,
Error during building application with PropertyChanged.Fody
But it seems like this feature is obsolete in the latest Visual studio as per the below question.
Disabling Visual Studio hosting process on Visual Studio Community 2017
Further, I have tried to set the environment variable as explained in the below thread as I thought its somewhat relevant. However, it doesn't work as well.
https://github.com/Fody/Fody/issues/537
I must use these Nuget packages in my solution. Highly appreciate it if someone can share some thoughts to sort out this issue

UWP: Package is not getting generated with error

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.

Creating new project (.net Core Web) Visual Studio 2017 Error: Unterminated string. Path TemplateInfo[40].Tags.auth

Since yesterday I am getting a weird error when I try to create a new .Net Core Web project. The error I am getting:
It seems this is only the case for .Net Core projects (Console application .Net core also doesn't work but a regular .Net web project does work...
I looked online but it seems there is no documentation about this error whatsoever.
Some things I tried already:
Repairing Visual Studio 2017
Checked the log by running Devenv /log (Warning :
Performance warning: String load failed. Pkg:{D15F5C78-D04F-45FD-AEA2-D7982D8FA429} (VisualBasicProjectSystemPackage) LANG:0409 ID:2
)
UPDATE
I think I know what caused the problem. Prior to the problem I deleted my old user account (migrated the account so everything copied to a new user account), my guess is that Visual Studio also installs templates on my user account and with the removal of my old user account I also deleted some templates. The question however is, why is the .Net Core template the only one not working then?
Anyone know what causes this problem and how to fix it?
Removing Visual Studio and reinstalling it seems to fix the issue. Before reinstalling, make screenshots of all your settings and (manually) downloaded components.
Same problem here, I tried to repair (multiple times) the installation but the problem wasn't solved.
In my case I didn't change user accounts.. I just uninstalled VS 2013 Ultimate, Unistalled VS 2015 (with some difficulty) and then installed VS2017..

ApplicationInsight does not exist in the namespace Microsoft

I've been working my way through video training series on Microsoft's Virtual Academy. The series I'm watching is titled "Windows 10 Development for Absolute Beginners" I'm at the penultimate video when I ran into a problem. Bob Tabor put the following into the constructor of the App class (in App.xaml.cs):
Microsoft.ApplicationInsights.WindowsAppInitializer.InitializeAsync(
Microsoft.ApplicationInsights.WindowsCollectors.Metadata |
Microsoft.ApplicationInsights.WindowsCollectors.Session);
However, this line doesn't work at all for me. I'm getting red squiggly lines under Microsoft.ApplicationInsights. And when I compile I get the following error message:
The type or namespace name 'ApplicationInsights' does not exist in the
namespace 'Microsoft' (are you missing an assembly reference?)
I have tried to add a reference to that, but it didn't work. In fact VS 2017 told me outright that it was impossible to add the reference I'd found.
I'm thinking that the problem is because I'm using VS 2017, whereas when Bob Tabor did the videos he was using VS 2015. Something has changed in the configuration, but I don't understand what. I'm sure the issue is that I need to include some sort of NuGet package. I'd be delighted to do so, only I've no idea what NuGet package to install.
I'm developing for Windows 10, using Visual Studio 2017 Community Edition.
For the "Windows 10 Development for Absolute Beginners" series videos,there is a correspondent sample here. If you opened one project you are referenced and build, you will find there are three ApplicationInsights relative Nuget packages referenced, and one ApplicationInsights.config file in the project. This should caused by when OS build is 10240, you create a new Windows 10 universal application in Visual Studio that a reference to Microsoft.ApplicationInsights is added to the references folder automatically. And after that, new builds coming without adding this package automatically.
So that if you just need the error gone you may add the same three Nuget packages:Microsoft.ApplicationInsights 1.0.0,Microsoft.ApplicationInsights.WindowsApps 1.0.0,Microsoft.ApplicationInsights.PersistenceChannel 1.0.0 manually.
But actually, Microsoft.ApplicationInsights is not supported UWP app starting 2.0.0. Currently you should not use ApplicationInsights for UWP app which may be deprecated, but use HockeyApp SDK instead.

Error while trying to run the Program Visual Studio

Every time I create a new project in Visual Studio it gives me this error
Error while trying to run project:could not load file or assembly '[project_name_here]' one of its dependencies. The module was expected to contain an assembly manifest
I am not able to understand what is the problem with Visual Studio or .NET Framework, today I even tried to re-install the .NET Framework but still I don't get it to work.
It always keeps saying this message, even if I just Start the Build process as soon as Creating the project. This happens even if I create the project of (Empty) Console Application and run it, with just a Main method.
When I create the projects in C++, they run, but when I try to run the projects in C# they give me this error. I have tried almost all the methods provided on Stack Overflow, CodeProject, MSDN forums etc. But, nothing works.
What should I do or write to my application so that it would work.
I have, Visual Studio 2013 Ultimate update 2 running on Microsoft Windows 7 SP1 with no extensions or updates, just a pure Visual Studio from Microsoft.

Categories

Resources