VS show alot of errors (E1696, E0020) and warnings (C26451, C4754) with a new project - c++-winrt

When I starts a new project (Blank App (C++/WinRT)) on Windows10 1909 # VS2019(up to date) its shows up a lot of errors as if the extension wasn't installed. But after trying to compile and run its works - so why do I get the errors and how can I solve this? screenshot
Edit: I have fond a solution for that. its turns out that the project was needed an additional include directory:
under the project properties->C/C++->General->[Additional Include Directory]
I added the winRT folder:
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\cppwinrt
screenshot2
and that's it now there's no errors (correction - after creating new project its still have the same errors)
edit2:
Update: I installed the last windows 10 SDK and was still getting the seam errors. Than I installed a package via cmd with the following command:
D:\vcpkg> vcpkg install cppwinrt:x86-windows
after this was done it seem to work now
edit3:
I'm sorry for the annoying newcomer questions...
its looks like I have another problem now with my project
in the packages.config file is says that the package is not declared with the following warning packages.config pic
thanks for any help in advance.
(edit4) I followed this thread:
nuget 'packages' element is not declared warning
and that's it, now all I have to do is to learn how to code :D

The 'standard' include paths for Visual C++ projects are the VC_IncludePath and WindowsSDK_IncludePath. The Windows SDK includes path already has all of the directories:
include\<10.0.build.0>\ucrt
include\<10.0.build.0>\shared
include\<10.0.build.0>\um
include\<10.0.build.0>\winrt
include\<10.0.build.0>\cppwinrt
"Blank App (C++/WinRT)" is not part of the standard VS 2019 template set. The name of the project in the screenshoot is "ConsoleApplication2", which would imply you created a Win32 console C++ project instead of a C++/WinRT project. Even still, you can reach the standard C++/WinRT headers from a Win32 console application since they are part of the standard path.
From the looks of the errors in your first screenshot, it appears you are using a generated C++/WinRT rather than the one in the Windows 10 SDK. With VS 2019, you must add the NuGet package Microsoft.Windows.CppWinRT to your project to get the MSBuild rules needed to build with the C++/WinRT VSIX installed, so that's likely a problem here. See VS Marketplace

Related

System could not be found Visual Studio 2017 ASP.NET Core project

I've installed the newly released version of Visual Studio 2017 and started a fresh ASP.NET Core project targeting .NET Core.
Out of the box, I'm getting the
The type or namespace name 'System' could not be found (are you
missing a using directive or an assembly reference?)
error. Any idea what's causing this and how to fix it?
Also, looks like there are problems with NuGet packages as well:
I also tried dotnet restore on the project through the command line and got the following error:
P.S. Kind of disheartening that you get an error in a fresh new project in the latest version of Visual Studio 2017!
UPDATE:
SDK version is v 1.0.1 -- see below:
UPDATE 2:
This is very strange. Looks like the original problem was due to NuGet package source pointing to a folder under Visual Studio 2015 folder. I unchecked it and left only nuget.org. With that my project seemed to have restored all the packages and when I started the project it loads up the standard ASP.NET page. But if I open startup.cs file, I get red squigglies all over the place but if I run the project, it works fine. What's going on here?
UPDATE 3:
I closed the project and VS 2017. I then restarted VS 2017 and opened the project and now it seems to be fine. And I'm not referencing the .NETStandard library 1.6.1 and everything seems to be working fine now.
I had the same issue in my Visual studio 2017 .Net Core application. I closed the Visual studio and re-open fixed everything.
Came across the same issue today. I had an old nuget source that no longer existed. So I went into Tools > Nuget Packet Manager and un-checked the wrong one. Hit "Ok", and then rebuilt the project, and it works great now. It seems like you stumbled onto it, but also wanted to verify that it fixed my issue, and it does.
I had the same problem, first when converting a VS2015 net core mvc web project to 2017 and then when trying to create a new core web application in 2017.
Went to Tools|NuGet Package Manager|Package Manager Settings - checked 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in VS' and then clicked 'Clear All NuGet Cache(s)'.
Then re-built the solution - it found and loaded all the required packages and ran OK.
May not work for all cases but simple and worth a try.
Multiple closing and reopening of VS2017 fixed it for me.
I had the same issue, the solution for me was to clear the NuGet cache. Tools > NuGet Package Manager > Package Manager Settings > Clear All NuGet Cache(s)
Check the version .NET Command Line Tools in CMD, just type dotnet --info. If version is 1.0.0, then try to install latest version .NET Core SDK from here.
Find the broken project and right click, Unload, right click, Re-load. Fastest fix for me.
If you get the problem while using the CLI, try doing nuget restore instead of dotnet restore as that sometimes pulls down packages that the dotnet CLI seems to miss.
I have had the same issue with Visual Studio 2019 and .NET Core SDK 2.2.
These steps solved the problem:
Close the Visual Studio
Open the Visual Studio as Administrator
Open the Solution
Right click on Solution -> Restore NuGet Packages
I've tried all answers above. For me works only removal and adding the reference again described in the following steps:
Open 'References' under the project.
Right click on 'System' reference.
Click on 'Remove'.
Right click on 'References'.
Click 'Add Reference...'.
From right menu choose an 'Assemblies',
In a search field type 'System'.
Choose 'System' from the list.
Click 'Add' button.
IMPORTANT: Restart the Visual Studio.
'System' reference you can replace with any you need.
Try adding the following line above the other references in the csproj file
<Reference Include="netstandard" />
For me the problem was caused by my project having a custom IntermediateOutputPath. For some reason, if project_name.csproj.nuget.g.targets is not in obj subfolder of project folder, the error occurs.
Using default IntermediateOutputPath or keeping a shadow copy of project_name.csproj.nuget.g.targets in fake obj folder solves the problem for me.
This issue seems to be triggered by a myriad of reasons. Mine was caused by cloning directly from VSTS using Git Bash, my project directory had spaces in it. Git Bash changed those spaces in the path to %20. It was throwing off all the references in my project. So for anyone who tried everything else and are at their wits end, make sure %20 is not in the path.
So, I have cloned the repository from github and started getting this error.
It was my project uploaded from another machine. I later realized that I have used the materialdesign packages in my project.
I have uninstalled and reinstalled these packages and it fixed my issue.
Had the same problem. Uninstalled Application Insights from my projects using the nuget package manager. I'm not looking at that yet, I just wanted core and unit tests. Problem solved.
I also had the same problem.
The is no SDK folder under the Dependencies one. Therefore, no Microsoft.NetCore.App libraries !
To solve this problem, in Nuget manager window, install any nuget which depends on .NetCoreApp (you can install for example Microsoft.AspNetCore or BundlerMinifier.Core from the Microsoft Visual Studio Offline Packages source).
The SDK will be restored by the same time.
Once it is back, you can uninstall the previously added nuget. The SDK will remain in place.
Not quite sure in which order vs 2017 trying to resolve packages.
But my situation was following. In my VS2015 I had configured local and 3rd party source for nuget packages, newly installed version of 2017 loaded them too.
https://api.nuget.org/v3/index.json was first in list.
But vs2017 throwed an error that it can't restore .net core libraries from my another local repo.
After I unchecked all of them except https://api.nuget.org/v3/index.json, it had started to working normally.
I had this problem too, but not right now, this steps solved my problem: Choose Project -> Properties from the menu bar. In the Project properties window, under Configuration Properties -> General, make sure that Common Language Runtime Support is set to Common Language Runtime Support (/clr)
Simply opening the NuGet package manager and then the Visual Studio settings related to it - without changing anything - merely looking around, and when I closed out, the problem was gone.
This seems to be an intermittent issue that can come and go for no obvious reason.
None of the answers here worked for me so I'm posting what did work.
My errors were mostly the same as the original poster but I also had:
Error loading meta data for 'Microsoft.Extensions.FileProviders.Embedded.2.0.1'
hexadecimal value 0x1C invalid character
Every time I attempted to download a different nuget package or restore old packages I would see this error. I also saw the other errors such as:
type or namespace system could not be found
What worked for me:
opened the filepath that the error said the bad metadata was in, which for me was C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.extensions.fileproviders.embedded\2.0.1
Then, I put the contents of that folder into another folder I named "hiding".
Then, I went back to the nuget package manager and tried to install a package, hoping to have the SDK restored. IOt worked successfully, and all my other errors were gone as well, and the fresh new project runs as it should!
The problem for me occurred when running my Visual Studio as Admin with a separate user-- I had created a Git Repo with the source files in the user documents of my normal account. When I created a new solution in that folder the above errors occurred. Try creating your project in a different place and see if the error still occurs.
I was facing the same issue when I created a new project (.net Core 2.2) in VS2019.In my case there was an Azure package which was creating the problem.I uninstalled it and the project started working fine.
Run mentioned below command to uninstall the package.
Uninstall-Package Microsoft.VisualStudio.Azure.Containers.Tools.Targets -Version 1.7.10
I had the same problem. I cloned a github project and this error came. So I deleted the cloned project and then I cloned the project again and it worked fine.

Unable to load DLL 'lua52': The specified module could not be found

I have the same problem as described here:
https://github.com/NLua/NLua/issues/33
Though I have followed the instructions to create a console application...
http://www.screencast.com/t/M12TqePQxW
...which works just fine, when I create a library project and reference it from another project (in this case, a Web API project) the following error occurs:
Unable to load DLL 'lua52': The specified module could not be found.
At this line:
using (var lua = new Lua())
How can a library project be made with the NLua nuget package without failing?
It is the exact same issue as described in the GitHub issue, the Nuget package is missing two DLLs that you need to use lua52.dll. One small difference, the current package (version 1.3.2.1) includes a newer version of lua52.dll that was built with VS2013. And therefore has a dependency on msvcr120.dll and msvp120.dll.
Beware that this may change in the future when Nuget updates your project.
As-is, you need to download and install the Visual C++ redistributable package for VS2013. Run both vcredist_x64.exe and vcredist_x86.exe so your project can run either in 32-bit or 64-bit mode.
To avoid having to do this on the machine on which you want to deploy your program, I recommend you copy the two DLLs from the c:\windows\system32 (64-bit) or c:\windows\syswow64 (32-bit) directories into the same directory as your EXE.
The package author could have done a better job putting this package together. Short from including the DLLs in the package, the better solution would be for him to rebuild lua52.dll with the /MT option so these dependencies are linked in. Consider clicking the New Issue button to let him know.

Global Assembly Cache - Assembly Install required

I am currently updating a VB.NET application with Visual Studio 2013 that possibly was originally created on VS2010 or VS2012.
This application uses a Network SQL Database
Everything goes fine up to the point of installing when just shows an error message. that says the Assembly 'Microsoft.VisualBasic.Shell.9.0' version 2.0.0.0
is required and then will not let me finish the installation.
The project has been exported using the Visual Basic tool [OneClick]
I have already checked the References list on the Project menu, and is not included there. Also not available to be added.
The project requires the Microsoft Framework 4.5, so it seems that the Shell v2.0.0.0 is pretty old...
Do you have any suggestions, this kept me scratching my head already quite a while...
I finally figured it out.
I am not too sure if this is the right solution or not but it worked for me. Hopefully this will help someone else.
It turn out to be a error with the framework I was compiling the project (v4.5),
I was trying to install it on a Windows 7 machine with a framework installed up to v4.0. I cant understand why this error message showed up instead of telling me the framework version required for the software was not installed.
But anyways, I changed the version on the compiler, build and export again. Another error pop up but it was because references to the DLL for the different framework version were not included in the project. After including them and set the value for "Copy to Local" to true, the installation worked like a charm.
So I got my program up and working.

ResolveAssemblyReference Could not load file or assembly - Xamarin - PCL Library -

I upgraded to latest version of Xamarin Studio(5.0.878) in MAC OSX Mountain Lion . I have a basic setting with a PCL project - which contains .NET Portable subset as expected.
And I have an android project that refers to this PCL project. However when I include the PCL project in the references and try to compile - I get that error below:
/Library/Frameworks/Mono.framework/Versions/3.4.0/lib/mono/4.5/Microsoft.Common.targets:
Error: Error executing task ResolveAssemblyReference: Could not load
file or assembly
'/Users/uakdemir/Projects/Likya/CoreLib/bin/Debug/System.Diagnostics.Tools.dll'
or one of its dependencies. The system cannot find the file specified.
(MyIncludedPCLProject)
Inside the .NET Portable subset (which is added as default by Xamarin) - I see the System.Diagnostics.Tools. I never refer to that namespace in my solution (I refer to System.Diagnostics).
No matter what I tried I was not able to get over that ResolveAssemblyReference error - there are some links on the web saying that it is a bug of xbuild - it was introduced in .NET 4.0 - with suggestions of reverting to .NET 3.5 - which I cannot since I will be using async and await in the project. Googling does not help either.
Is there a workaround you know for this ResolveAssemblyReference issue? Why is msbuild trying to look for an assembly that is supposed to be in the .NET Portable Subset for PCL in the output folder for the PCL library?
I may be missing some information since I am not much experienced with this error - please bear with me and ask any additional details that might be needed.
Thanks a lot
What worked for me was:
Build > Clean all
File > Close solution
File > Open solution
Project > Update NuGet packages
c# project in Xamarin 5.9.8, OSX El Capitan
I had the exact same error in Monodevelop with my F# project I am bootstrapping and what I did was close the solution and re-opened it and saw that I was prompted that updates for some of the packages in my project were available for download, so I installed the package updates and my project ran fine after that. So you might want to give that a try.

Trouble getting TeamCity to build F# projects

I'm trying to get our build server (TeamCity 8) to build an F# project (the first any of us have ever created on my team).
When I first ran the build I got the following error:
The value "" of the "Project" attribute in element <Import> is invalid. Parameter "path" cannot have zero length.
I assume that this means that the requisite F# tools are not present on the build server. I tried to rectify this using instructions on this blog post: http://www.heartysoft.com/ashic/blog/2013/3/build-fsharp-3-on-build-server-without-vs (summary: download and install VWD_FSharp.msi) but the problem persisted. I then added Condition="Exists('$(FSharpTargetsPath)')" to the Import tag in the fsproj so that it now reads:
<Import Project="$(FSharpTargetsPath)" Condition="Exists('$(FSharpTargetsPath)')" />
which I saw in another blog post, but all that's done is swapped the earlier error for a new one:
The target "Rebuild" does not exist in the project.
Any help here would be greatly appreciated; I really don't want to install VS on the build server. The only thing about our environment that might be noteworthy is that we're on .NET 4 rather than 4.5.
Thanks
Thanks for your question Ganesh, I have since solved the problem.
So, installing the F# tools using the link in my question did work, but after some digging round in the MSBuild directories it turns out that it only installed F# v3; my projects were targeting v3.1 (the default version in VS2013).
Going into each project's settings file and retargeting for 3.0 solved the problem.