Skip to content

Instantly share code, notes, and snippets.

@alastairs
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastairs/a22ef6088f37a660d727 to your computer and use it in GitHub Desktop.
Save alastairs/a22ef6088f37a660d727 to your computer and use it in GitHub Desktop.
Topshelf with ASP.NET vNext
Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshel
f.HostConfigurationException: The service was not properly configured:
[Failure] Command Line An unknown command-line option was found: SWITCH: appbase
(True)
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "C:\t
emp\TopShelfVNextIssue"
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "Micr
osoft.Framework.ApplicationHost"
[Failure] Command Line An unknown command-line option was found: SWITCH: configu
ration (True)
[Failure] Command Line An unknown command-line option was found: ARGUMENT: Debug
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "TopS
helfVNextIssue"
[Success] Name Stuff
[Success] Description Sample Topshelf Host
[Success] ServiceName Stuff
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumera
ble`1 results)
at Topshelf.HostFactory.New(Action`1 configureCallback)
Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.Host
ConfigurationException: The service was not properly configured:
[Failure] Command Line An unknown command-line option was found: SWITCH: appbase
(True)
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "C:\t
emp\TopShelfVNextIssue"
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "Micr
osoft.Framework.ApplicationHost"
[Failure] Command Line An unknown command-line option was found: SWITCH: configu
ration (True)
[Failure] Command Line An unknown command-line option was found: ARGUMENT: Debug
[Failure] Command Line An unknown command-line option was found: ARGUMENT: "TopS
helfVNextIssue"
[Success] Name Stuff
[Success] Description Sample Topshelf Host
[Success] ServiceName Stuff
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumera
ble`1 results)
at Topshelf.HostFactory.New(Action`1 configureCallback)
at Topshelf.HostFactory.Run(Action`1 configureCallback)
Press any key to continue . . .
using System;
using System.Timers;
using Topshelf;
namespace TopShelfVNextIssue
{
public class TownCrier
{
readonly Timer _timer;
public TownCrier()
{
_timer = new Timer(1000) { AutoReset = true };
_timer.Elapsed += (sender, eventArgs) => Console.WriteLine("It is {0} and all is well", DateTime.Now);
}
public void Start() { _timer.Start(); }
public void Stop() { _timer.Stop(); }
}
public class Program
{
public static void Main()
{
HostFactory.Run(x =>
{
x.Service<TownCrier>(s =>
{
s.ConstructUsing(name => new TownCrier());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
x.RunAsLocalSystem();
x.SetDescription("Sample Topshelf Host");
x.SetDisplayName("Stuff");
x.SetServiceName("Stuff");
});
}
}
}
{
"version": "1.0.0-*",
"description": "",
"authors": [ "" ],
"tags": [ "" ],
"projectUrl": "",
"licenseUrl": "",
"dependencies": {
"Topshelf": "3.2.0"
},
"commands": {
"TopShelfVNextIssue": "TopShelfVNextIssue"
},
"frameworks": {
"dnx451": { }
}
}
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22823.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TopShelfVNextIssue", "TopShelfVNextIssue.xproj", "{EC398546-12C7-47B3-82E8-221DD59043A4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EC398546-12C7-47B3-82E8-221DD59043A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC398546-12C7-47B3-82E8-221DD59043A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC398546-12C7-47B3-82E8-221DD59043A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC398546-12C7-47B3-82E8-221DD59043A4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>ec398546-12c7-47b3-82e8-221dd59043a4</ProjectGuid>
<RootNamespace>TopShelfVNextIssue</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment