System.PlatformNotSupported exception with service stack - asp.net-web-api

I am trying to run a service stack application, it works fine on my dev machine when deployed on another box, I get System.PlatformNotSupported exception.
Stack trace below:
Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Net.HttpListener..ctor()
at ServiceStack.Host.HttpListener.HttpListenerBase.Start(IEnumerable`1 urlBases, WaitCallback listenCallback)
at ServiceStack.Host.HttpListener.HttpListenerBase.Start(String urlBase)
at ExcaliburAppHost.Program.Main(String[] args)
I am trying to build a Restful app with self hosting (with no IIS support on the other box).
var listeningOn = args.Length == 0 ? "http://*:8090/" : args[0];
var appHost = new AppHost()
.Init()
.Start(listeningOn);
error occurs in AppHost().Start() method

If you have any unmanaged .dlls e.g. sqlite3.dll you may need to set the Platform Target of your project as x86.
You can also try running the Console App as Administrator / sudo in-case it's a permissions issue.

To whom facing with exception "System.PlatformNotSupportedException: ServiceController enables manipulating and accessing Windows services and it is not applicable for other operating systems." - in my case I had to add "System.ServiceProcess.ServiceController" NuGet package to my .net 5 Worker Service project and issue is gone.

For me, I was building a .NET 6 worker service in a Docker container on a Linux host, building a Windows service to run on Windows Server 2016. My csproj file has the following properties set, but I was receiving the same PlatformNotSupportedException as the OP:
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<OutputType>Exe</OutputType>
<InvariantGlobalization>true</InvariantGlobalization>
<PublishSingleFile>false</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishReadyToRun>false</PublishReadyToRun>
I was able to resolve this by specifying the runtime option (-r win-x64) directly to the dotnet publish command in my Dockerfile.
Now the application builds from a Docker container running on a Linux host, but the resulting binaries run fine on the Windows Server 2016 platform.

Related

HTTP Error 502.5 - Process Failure - .net core 2.0 to AWS EB

I'm getting this error after deploying my API to AWS Elastic Beanstalk.
Steps to reproduce
File -> New -> Project
ASP.NET Core Web Application
ASP.NET Core 2.0
Web API
F5: OK
Publish to AWS Elastic Beanstalk... (via AWS Tollkit for Visual Studio 2017)
HTTP Error 502.5 - Process Failure
Additional info
Visual Studio 2017
64bit Windows Server 2012 R2 v1.2.0 running IIS 8.5
I've already tried looking up many other questions, but to no success.
Log
2018-01-15T13:27:21.000Z Error 0:(0) IIS AspNetCore Module - Application 'MACHINE/WEBROOT/APPHOST/DEFAULT WEB SITE' with physical root 'C:\inetpub\AspNetCoreWebApps\app\' failed to start process with commandline 'dotnet .\WebApplication2.dll', ErrorCode = '0x80004005 : 8000808c.
<PropertyGroup>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
Adding the above code to the .csproj solved the problem.
I faced the same issue. After contacting AWS support, it turns out that there was a bug in my code [Release version].
I suggest the following steps to debug locally:
Publish your solution to a file
Open Command Prompt in the published folder
Run "dotnet Your.Main.App.dll"
Most probably you will see an exception
Sometimes we forget to test our solutions in Release mode.
Cheers!

Visual Studio 2015 Docker Integration wont attach for debuging

I created a Default .net Core RC2 MVC app using VS 2015. I added Docker Support so I could run and debug it in docker.
When I run the project it builds the docker container and starts it. Running the command "docker ps" shows the container running with the correct ports mapped. However I get the following error:
The target process exited without raising a CoreCLR started event. Ensure that the target process is configured to use NETStandard [version ...] or newer. This might be expected if the target process did not run.
Also trying to access the web page returns the following error:
[Fiddler] The connection to '10.0.75.2' failed.
Error: ConnectionRefused (0x274d).
System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it 10.0.75.2:80
Turns out the problem is related to the docker for windows beta I am running. By default it does not let you map volumes.
To enable open the docker for window settings:
And select Manage shared drives.
Select the C drive or drive you have the .Net code stored on and rebuild and deploy the project:

ASP5 deploy to windows 7 server

I'm developing web api in .NET 4.5.1. It is build on TeamCity CI server, but I would like to deploy it to the Windows 7 machine in the local network after every successful build.
I wanted to use dnu publish command, but I have no idea how to use it in this case and how to prepare Windows 7 machine to be ready to receive new, just builded application.
This issue is realy poorly described in case of new ASP.
You need to run:
dnu publish --runtime <name of runtime or "active">
Optionally, you can also pass --no-source.
Once you do that, the bin/output folder will have the application, its dependencies and the runtime. Then, all you have to do is copy that folder to your Win 7 machine.
Here's a script that does something similar for the MusicStore sample. We use it to deploy MusicStore on Nano Server

OperationFailedException when using vNext template in Microsoft Release Management

I am getting the following error while running a workflow in microsoft release management 2013 update 4:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. ---> Microsoft.TeamFoundation.Release.Common.Helpers.OperationFailedException: System.AggregateException: Failed to install 'VisualStudioRemoteDeployerbd3a8a59-325a-45d0-89f5-86a548554a12' from service executable path VisualStudioRemoteDeployer.exe . Consult the logs below:
c:\Users\vmadmin\AppData\Local\Temp\mfurnl9w.0.cs(95) : ; expected
c:\Users\vmadmin\AppData\Local\Temp\mfurnl9w.0.cs(94) : IntPtr policyHandle = IntPtr.Zero;
c:\Users\vmadmin\AppData\Local\Temp\mfurnl9w.0.cs(95) : >>> var attributes = new LSA_OBJECT_ATTRIBUTES()
c:\Users\vmadmin\AppData\Local\Temp\mfurnl9w.0.cs(96) :
I am using a vNext Release Template. I have added an action "Deploy using PS/DSC" which is supposed to execute a powershell script on the machine.
All I get is the above error.
I have verified that remoting is setup as per here (on-premise section): https://www.visualstudio.com/en-us/get-started/deploy-no-agents-vs.aspx
I have also referenced this: http://roadtoalm.com/2015/02/04/start-with-visual-studio-release-management-vnextvs-rm-for-dummies/
but our error is slightly different as it doesn't complain about the account. Although i am assuming the account is ok... I did use a couple variations and when the account is incorrect i get an obvious failure.
any help would be appreciated.
I found this question because I had the same issue. In RoadToAlm article he is using Windows Server 2012 on his VM. My Azure VM was Windows Server 2008 SP2 and I resolved the issue by installing Windows Management Framework 3.0 (http://go.microsoft.com/?linkid=9811175) which includes a newer Powershell than was installed on my server. After this update the issue was resolved.
I was facing the same issue on a destination Windows Server 2008 R2. I just shift down the UAC level and it let the deployment tools be copied by the task into the c:\Windows\DtlDownloads folder (with VisualStudioRemoteDeployer.exe).
From the moment this file was available, the artifact copy had been successful.

SonarQube installation failing to start service

I'm installing sonarqube on Windows Server 2012.
I have followed the following steps:
Downloaded sonarqube4.4 and extracted to C:\Sonarqube
Downloaded Java JDK 1.7.0_60 and jre 1.7.0_67 as well as jre7
Installed Windows SDK 7 and .NET Framework 4
Navigated to C:\sonar\bin\windows x86-64 and ran StartSonar.bat as an administrator, this ran ok with no output and Ihad to hot ctrl- Z to break
I then ran \windows-x86-64\InstallNTService.bat as an administrator and I am seeing the sonarQube services was launched, but failed to start.
Not sure what the problem is.
I believe you first ran \windows-x86-64\InstallNTService.bat successfully and then StartSonar.bat unsuccessfully (the inverse order of what you describe).
You probably have [this problem]: http://qualilogy.com/fr/wp-content/uploads/sites/2/2013/09/Sonar_ServiceLaunchError2.jpg
Windows could not start the Sonar service on Local Computer.
Error 1067: The process terminated unexpectedly.
In that case, the solution is to change the user/rights to launch the Sonar service: https://qualilogy.com/en/migrate-sonarqube-tomcat-to-windows-service/
Go to the Services window, find the Sonar service, and open the Properties windows to change the user it logs on as to one with sufficient permissions.
I was able to solve this problem by creating a new folder named “Temp” in C:\Windows\System32\config\systemprofile\AppData\Local\
The Log-File will show only
--> Wrapper Started as Service
Cleaning or creating >temp directory C:\Program Files (x86)\SonarQube\sonarqube\temp
<-- Wrapper Stopped
The SonarQube service was launched, but failed to start.
After a long search, I came up to this site http://zen-and-art-of-programming.blogspot.de/2013/03/installing-and-running-sonar-source.html.
Solution:
Navigate to C:\Windows\system32\config\systemprofile\AppData\Local\ and create the directory Temp
2: Set the user rights to full access
3: Run the StartNTService.bat

Resources