retarget for .net 4.5 (from 4.5.2) for mono support.

reference logger.
add calls to logger to help trace the service on start/stop.
This commit is contained in:
Chris.Watts90@outlook.com 2017-03-30 16:54:54 +01:00
parent cbfeecd608
commit d55ee663b8
5 changed files with 38 additions and 8 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup> </startup>
<appSettings> <appSettings>
<add key="DataCenterServiceEndpoint" value="http://localhost:1234"/> <add key="DataCenterServiceEndpoint" value="http://localhost:1234"/>

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CardReaderService</RootNamespace> <RootNamespace>CardReaderService</RootNamespace>
<AssemblyName>CardReaderService</AssemblyName> <AssemblyName>CardReaderService</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -68,6 +69,12 @@
<None Include="App.config" /> <None Include="App.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Logger\Logger.csproj">
<Project>{42EFE386-DC2E-455A-BA81-5FC9CEE45D02}</Project>
<Name>Logger</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -5,6 +5,7 @@ using System.Linq;
using System.ServiceProcess; using System.ServiceProcess;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using Logger;
namespace CardReaderService namespace CardReaderService
{ {
@ -29,8 +30,29 @@ namespace CardReaderService
protected override void OnStart(string[] args) protected override void OnStart(string[] args)
{ {
<<<<<<< HEAD
StartWorkerThread(); StartWorkerThread();
} }
=======
Console.WriteLine("Starting.. Getting available readers");
MessageLogger.Log("Starting.. Getting available readers");
var ctxFactory = ContextFactory.Instance;
using(var context = ctxFactory.Establish(SCardScope.System))
{
var readerNames = context.GetReaders();
if (NoReaderAvailable(readerNames))
{
Console.WriteLine("No Card Reader is available, Exiting..");
MessageLogger.Log("No Card Reader is available, Exiting..");
return;
}
Console.WriteLine("Choosing first available reader: " + readerNames.First());
MessageLogger.Log("Choosing first available reader: " + readerNames.First());
_readerName = readerNames.First();
_cardMonitor = new SCardMonitor(ctxFactory, SCardScope.System);
_cardMonitor.CardInserted += _cardMonitor_CardInserted;
_cardMonitor.Start(_readerName);
>>>>>>> retarget for .net 4.5 (from 4.5.2) for mono support.
private bool WeHaveValidCardReader() private bool WeHaveValidCardReader()
{ {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup> </startup>
</configuration> </configuration>

View File

@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CardReaderServiceHost</RootNamespace> <RootNamespace>CardReaderServiceHost</RootNamespace>
<AssemblyName>CardReaderServiceHost</AssemblyName> <AssemblyName>CardReaderServiceHost</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>