Ive started getting this error out of the blue
This only happens when I deploy the application via teamcity. If I run it locally it works fine.
What ive tried doing .
Added the nuget package manually to the class libraries
Debug Locally - My local solution runs fine
I have never seen anything like this before.
UPDATE
Ive browsed to my output directory and the DLL Version is this .
This would explain the error but I have no clue why its using this version.
UPDATE 2 - As Requested .csproj file
<ItemGroup>
<PackageReference Include="Autofac" Version="4.8.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.9" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.0.4" />
<PackageReference Include="Microsoft.VisualStudio.SlowCheetah" Version="3.1.66" />
<PackageReference Include="NLog.Web.AspNetCore" Version="4.6.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="3.0.0" />
</ItemGroup>
So Im not sure why this happened but on the publish the Microsoft.Extensions.ObjectPool.dll in the publish folder was never being updated .
Simply marking <DeleteExistingFiles>True</DeleteExistingFiles> as true in my publish .pubxml and republishing magically fixed the issue. Hope this helps someone in the future.
Related
I am trying to follow Microsofts guide on building a web app with individual user authentication.
https://learn.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.1
Every time I try to run the program I get an error 502.5
error 502.5
I have tried the suggestions in the comments of the guide and done a fair bit of searching for people having the same issue but I didn't find any solutions that solved my issue.
I'm not sure what could be the source of the issue but I will put up the project settings launch settings etc.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>aspnet-ContactManager-0DAD76F8-C053-4971-A8DF-4C55A4FF198B</UserSecretsId>
</PropertyGroup>
<!-- <PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup> -->
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Utils" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1 />
</ItemGroup>
</Project>
LaunchSettings.json
LaunchSettings Screenshot
Program.cs
Program.cs Screenshot
When the web app is running with debugging, this error is brought up.
Run Error
Update-database
If there's anything you need me to include let me know.
Thank you.
5xx codes indicate some unhandled error in the application or server itself. You should attach a debugger in your dev environment and see what the unhandled exception is, which is what I guess is happening here.
The only time I've run into this I didn't have the correct versions of Core SDK installed. Maybe double check that?
I am developing a netcoreapp2.0 console application and I need access to the whole encoding package from .NET.
I have already added the System.Text.Encoding.CodePages Version=4.4.0 Nuget package from this page to my project and cleaned/restored the project several time.
However I can't get the extra encoding I need.
The following code:
Console.WriteLine(Encoding.GetEncodings().Length);
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.WriteLine(Encoding.GetEncodings().Length);
returns:
8
8
and no extra encoding is added to Encoding class.
These are all the references I have in my project:
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="2.0.0" />
<PackageReference Include="System.Data.HashFunction.xxHash" Version="2.0.0-ci-00012" />
<PackageReference Include="Nager.PublicSuffix" Version="1.1.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
Am I doing something wrong here?
Update
After reinstalling the .NET Core SDK 2.0.2 again, things started to work fine and I can use the extended Encoding code pages using Encoding.GetEncoding() method, however the Encoding.GetEncodings() still returns the initial 8 Encoding code pages.
Update August 2022:
Thanks to a comment from zapoo, we know that while the solution is not required in .net framework 4.8, it is needed for .net 6.0
I am adding this as the answer regarding Gabriel Rainha's suggestion that it might help other people in the future too.
I cleaned the Nuget cache, repaired my ".NET Core SDK 2.0.2" installation, did a "Solution and Project Cleanup" and rebuilt my project, and the Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) code started to work fine.
Now I can access the extra code pages using the Encoding.GetEncoding() method, however I still get the same list of encodings from Encoding.GetEncodings() method after adding the extra encodings.
From my perspective the Encoding.GetEncodings() method should return all the encodings available after more of them have been added.
install nuget packages:
System.Text.Encoding & System.Text.Encoding.CodePages
Getting a 502.5 error after CI deployment to azure app service.
When running dotnet {myproject}.dll on the debug console this is the error I get:
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.0.2.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors)
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at My.IOEducation.Api.Program.Main(String[] args) in D:\home\site\repository\My.IOEducation.Api\Program.cs:line 11
Running dotnet --version returns 2.0.0
Anyone else run into this yet and any suggestions on how to resolve?
UPDATE:
Here is the contents of the project file.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\Report\" />
<Folder Include="wwwroot\" />
<Folder Include="DataAccess\ExternalApis\" />
<Folder Include="DataAccess\ExternalApis\Helpers\" />
<Folder Include="Models\Dashboard\" />
<Folder Include="Helpers\" />
<Folder Include="DataAccess\Redis\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="PowerBI.NetStandard.Api" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="1.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="1.0.0" />
<PackageReference Include="Dapper" Version="1.50.2" />
<PackageReference Include="StackExchange.Redis" Version="1.2.6" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<None Remove="DataAccess\.DS_Store" />
<None Remove=".DS_Store" />
</ItemGroup>
</Project>
I spoke to the aspnet IISIntegration team members and found my solution.
tldr: Empty out your wwwroot folder on kudu.
The issue relates to having old things leftover from previous 1.x deployments
Step 1:
Navigate to the Kudu Console (https://{yourapp}.scm.azurewebsites.net/)
Step 2:
Step 3:
(Note: navigate into the "site" directory)
(Note: there is a wwwroot folder within this wwwroot. You should delete the one that is in the "site" directory)
Step 4:
Add a new empty folder called wwwroot where you just deleted the previous one (within "site" directory)
(Note: my deployment failed when I didn't have the empty wwwroot folder in there)
Step 5: Redeploy your app and hopefully it works. Good luck
Found the issue. Let me start by adding a little more information. This was originally a .net-core-1.1 project that I updated to 2.0 following instructions provided by Microsoft. After upgrading, I had no issues at all running locally, but once I tried to publish my azure app service, i kept getting the IIS error. Last ditch effort was to create a new .net-core-2.0 project from scratch this morning and noticed that the new project file contained this:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
I added that to my existing project file (the one upgraded from 1.1) and now the error is gone and issue resolved.
Brand new .net core 2.1 app trying to deploy to new Azure app service with new app service plan. Same issues, namely 502.5 error ( HTTP Error 502.5 - Process Failure ).
I implemented the above steps and still ran into errors. I opted to use the chose the self-contained deployment mode (compared to framework dependent (win-x64)).
This resolved my issue.
This answer was also submitted to [question]: ASP.NET Core 2.0 Preview 2 on IIS error 502.5
Perhaps these questions should be linked.
I am trying to migrate a WPF app built under the old csproj format to the new csproj format defined for VS2017.
I've been able to get the app to compile, but I when I try to launch it in the debugger under VS2017 I get the following error message:
Unable to run your project. The "RunCommand" property is not defined.
Interestingly, if I double-click the exe within File Explorer it launches just fine.
FYI, the project was initially a console app, which I then modified to be a WPF app. Here's the csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LanguageTargets>$(MSBuildExtensionsPath)\$(VisualStudioVersion)\Bin\Microsoft.CSharp.targets</LanguageTargets>
<OutputType>winexe</OutputType>
<TargetFramework>net47</TargetFramework>
<ApplicationIcon />
<OutputTypeEx>winexe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />
<Compile Update="Properties\Resources.Designer.cs" DesignTime="True" AutoGen="True" DependentUpon="Resources.resx" />
<Compile Update="Settings.Designer.cs" AutoGen="True" DependentUpon="Settings.settings" />
<None Update="Settings.settings" LastGenOutput="Settings.Designer.cs" Generator="SettingsSingleFileGenerator" />
<Page Include="**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" Exclude="App.xaml" />
<Compile Update="**\*.xaml.cs" SubType="Designer" DependentUpon="%(Filename)" />
<Resource Include="assets\*.*" />
<ApplicationDefinition Include="App.xaml">
<Generator>MsBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.6.0" />
<PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="4.0.0" />
<PackageReference Include="Extended.Wpf.Toolkit" Version="3.0.0" />
<PackageReference Include="Hardcodet.NotifyIcon.Wpf" Version="1.0.8" />
<PackageReference Include="MaterialDesignColors" Version="1.1.3" />
<PackageReference Include="MaterialDesignThemes" Version="2.3.0.823" />
<PackageReference Include="MvvmLightLibs" Version="5.3.0" />
<PackageReference Include="Serilog" Version="2.4.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\WPFUtilities\J4JUI\J4JUI.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.ComponentModel.DataAnnotations" />
</ItemGroup>
<Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
</Project>
Where is the RunCommand property set, and how do I set it?
Update
Playing around with the project settings, I configured the debug options to launch the executable created by the project (the default is to "run" the project).
This lets me launch the app in the debugger within VS 2017...and makes me think this might be a bug in VS 2017, with the RunCommand property not being defined by the build environment the way it should be.
For the 1.0.0 and 1.1.0 SDK, the Microsoft.NET.Sdk.targets file tries to set the RunCommand property when Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and '$(OutputType)' == 'Exe'". But since the project specifies <OutputType>winexe</OutputType> (which it needs to), the condition is not satisfied (and of course none of the others are either).
This seems to have been fixed in the upcoming 2.0.0 SDK (source, you'll have to explore the other files to find the _IsExecutable property), which should be shipped in the next VS2017 update.
In the meantime I opted to set the property manually in my .csproj: <RunCommand>bin\Debug\net47\MyApp.exe</RunCommand> (I could've spent more time to use more SDK-defined properties, but I'd have to schedule it after the SDK targets are imported, which I've left out for simplicity)
What kind of "migrate" are we talking here? There is no in-built migration tool, and it's way more than the previous "VS 2012 to VS2013" type upgrade, it's a fundamentally different format all together.
I know some people have tried (unsuccessfully) to manually update the .csproj XML, it usually ends in frustration and getting no where with it.
Honestly I would 100% recommend making brand new projects and manually copying your files in. Will take a while, but at least you'd be totally sure it was actually going to work, and you don't spend hours trying banging your head on the wall with the barely documented new XML format.
Of course a better option would be something built in to do it for you.
For the last couple of days, I've been trying to compile my .NET Core console application, and upload it to a VPS running "Windows Server 2012 R2". The reason I am using .NET Core is because this is needed for the library - Discord.Net 1.0.
The first thing I tried was simply taking my release DLL file and data, with the following file structure:
LeveledStudios.deps
LeveledStudios.dll
LeveledStudios.pdb
LeveledStudios.runtimeconfig.dev
LeveledStdios.runtimeconfig
This worked fine for execution on the PC I developed it on, however I then went into my server, ran "dotnet LeveledStudios.dll", and was faced with the error
Error: assembly specified in the dependencies manifest was not found -- package: 'discord.net.commands', version '1.0.0-rc-00546', path: 'lib/netstandard1.3/Discord.Net.Commands.dll`
Noticing this fitted the structure of the .nuget folder on my development PC. I copied it across and faced the same issue, and tried to copy it into the same folder as leveledstudios.dll, only to run into some .dll's which refused to work. This also included missing system DLL files, like System.Net.Http, etc.
I did some googling, and saw information about self contained .NET Core applications. This sounds perfect because clearly my problem was that it was not compiling with all my additional libraries. I was a little confused because I did not have a project.json file, as mentioned in all the documentation I read on it.
However when running:
dotnet restore
dotnet build -r win10-x64
I get a host of errors, suggesting none of the system libraries are compiled:
Errors
The contents of LeveledStudios.csproj:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Commands" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Core" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.WebSocket" Version="1.0.0-rc-00546" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
</ItemGroup>
</Project>
How can I fix this?
...self contained .NET Core applications [sound] perfect... however... I get a host of errors, suggesting none of the system libraries are compiled.
To resolve the errors that happened when you built as a self-contained application, add this one line to your *.csproj file:
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
Restore will then bring down the runtime, allowing you to build and publish as a self-contained application.
dotnet restore
dotnet build -r win10-x64
dotnet publish -c release -r win10-x64
The final *.csproj file looks like this:
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>exe</OutputType>
<TargetFramework>netcoreapp1.0</TargetFramework>
<RuntimeIdentifiers>win10-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Compile Include="**\*.cs" />
<EmbeddedResource Include="**\*.resx" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Commands" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.Core" Version="1.0.0-rc-00546" />
<PackageReference Include="Discord.Net.WebSocket" Version="1.0.0-rc-00546" />
<PackageReference Include="Microsoft.NETCore.App" Version="1.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.2-beta2" />
</ItemGroup>
</Project>
That's how to publish as a self-contained application, which is one alternative to resolve your initial problem.
The other alternative (which Ryan suggested and which you said did not work) is to use a framework-dependent application, in which case you do not need the RuntimeIdentifiers property. You can then run the same commands but without specifying the runtime.
dotnet restore
dotnet build
dotnet publish
The publish files, which will include the Discord dependencies, will be here:
bin\Debug\netcoreapp1.0\publish