I am getting the below mentioned error while running application from command prompt.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType) at System.Attribute.GetCustomAttributes(Assembly element, Type attributeType, Boolean inherit) at System.AppDomain.GetTargetFrameworkName()
My Service class is as:
`
namespace DataHunterService
{
public class HunterService : IMicroService
{
private IMicroServiceController Controller;
public HunterService()
{
Controller = null;
}
public HunterService(IMicroServiceController controller)
{
Controller = controller;
}
public void Start()
{
Thread t = new Thread(new ThreadStart(this.DoWork));
t.Start();
}
public void Stop()
{
System.Threading.Thread.Sleep(1000);
}
public void DoWork()
{
try
{
CustomLogger.Logger.LogInfo("Called DataHunterHost....!");
var host = new DataHunterHost();
host.Start();
}
catch (Exception)
{
Stop();
}
}
}
}
`
My Program.cs is as:
`
public class Program
{
public static void Main(string[] args)
{
try
{
ServiceRunner.Run(config =>
{
var name = config.GetDefaultName();
config.Service(serviceConfig =>
{
serviceConfig.ServiceFactory((extraArguments, controller) => new HunterService(controller));
serviceConfig.OnStart((service, extraParams) =>
{
CustomLogger.Logger.LogInfo("Service {0} started", name);
service.Start();
});
serviceConfig.OnStop(service =>
{
CustomLogger.Logger.LogInfo("Service {0} stopped", name);
service.Stop();
});
serviceConfig.OnError(e =>
{
CustomLogger.Logger.LogInfo("Service {0} errored with exception : {1}", name, e.Message);
});
});
});
}
catch (Exception e)
{
CustomLogger.Logger.LogInfo("Service errored with exception : {0}", e.Message);
}
}
`
And my project.json is as:
`
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"copyToOutput": {
"includeFiles": [ "appsettings.json", "datahunters.json" ]
}
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
},
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Quartz": "3.0.0-alpha3",
"DataHunter.Models": {
"target": "project",
"version": "1.0.0-"
},
"CustomLogger": {
"target": "project",
"version": "1.0.0-"
},
"DataHunter": {
"target": "project",
"version": "1.0.0-*"
},
"PeterKottas.DotNetCore.WindowsService": "2.0.0",
"System.Runtime": "4.3.0"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
`
Please help to resolve this.