I have followed this link to run a dnx console app. I created two files Program.cs and project.json with the content as mentioned in the link
Here is the sequence of commands that i executed
F:\first-dnx> dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-beta6 clr x86 win
1.0.0-beta6 coreclr x64 win
* 1.0.0-beta8-15530 clr x86 win default
F:\first-dnx> dnu restore
Microsoft .NET Development Utility CLR-x86-1.0.0-beta8-15530
Restoring packages for F:\first-dnx\project.json
CACHE https://www.myget.org/F/aspnetvnext/api/v2/
CACHE https://www.nuget.org/api/v2/
Writing lock file F:\first-dnx\project.lock.json
Restore complete, 490ms elapsed
NuGet Config files used:
C:\Users\sam\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
https://www.myget.org/F/aspnetvnext/api/v2/
https://www.nuget.org/api/v2/
F:\first-dnx> dnu build
The project got built successfully but when i am trying to run the app
below exception is thrown
F:\first-dnx> dnx . run
System.InvalidOperationException: Unable to load application or execute command '.'. Available commands: ConsoleApp1.
at Microsoft.Dnx.ApplicationHost.Program.ThrowEntryPointNotfoundException(DefaultHost host, String applicationName, Exception innerException)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
F:\first-dnx> dnx . ConsoleApp1
System.InvalidOperationException: Unable to load application or execute command '.'. Available commands: ConsoleApp1.
at Microsoft.Dnx.ApplicationHost.Program.ThrowEntryPointNotfoundException(DefaultHost host, String applicationName, Exception innerException)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
F:\first-dnx>
You don't have to add the . to specify the base path anymore. Try:
dnx run
This was changed in beta7. See: https://github.com/aspnet/Announcements/issues/52.
Related
System.MissingMethodException: Method not found: 'StackExchange.Redis.ConnectionMultiplexer StackExchange.Redis.IRedisAsync.get_Multiplexer()'.
at Hangfire.Pro.Redis.RedisStorage.GetMasterEndpoint()
at Hangfire.Pro.Redis.RedisStorage.ToString()
at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
at Hangfire.BackgroundJobServer..ctor(BackgroundJobServerOptions options, JobStorage storage, IEnumerable1 additionalProcesses, IJobFilterProvider filterProvider, JobActivator activator, IBackgroundJobFactory factory, IBackgroundJobPerformer performer, IBackgroundJobStateChanger stateChanger) at Hangfire.HangfireApplicationBuilderExtensions.UseHangfireServer(IApplicationBuilder app, BackgroundJobServerOptions options, IEnumerable1 additionalProcesses, JobStorage storage)
at UlysOpusApi.Configuration.Hangfire.HangfireMiddlewareConfiguration.UseHangfire(IApplicationBuilder app, HangfireConfiguration configuration) in C:\Work\interface_opus_digital\UlysOpusApi\Main\4_Infrastructure\UlysOpusApi.Configuration\HangFire\HangfireMiddlewareConfiguration.cs:line 17
at UlysOpusApi.Web.Startup.Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime, IHostingEnvironment env, ILogger logger, IHangfireService hangfireService, IOptions1 swaggerConfiguration, IOptions1 hangfireConfiguration) in C:\Work\interface_opus_digital\UlysOpusApi\Main\1_DistributedInterfaceLayer\UlysOpusApi.Web\Startup.cs:line 95
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app)
at Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter.<>c__DisplayClass2_0.b__0(IApplicationBuilder app)
at Microsoft.Extensions.DependencyInjection.AutoRegisterMiddleware.<>c__DisplayClass4_0.b__0(IApplicationBuilder app) in E:\BA\56\s\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.Extensions.DependencyInjection\AutoRegisterMiddleware.cs:line 46
at Microsoft.AspNetCore.Mvc.Internal.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.<>c__DisplayClass2_0.b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter.<>c__DisplayClass0_0.b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
So I recently installed Entity Framework Core 5.0 Preview 3 because I needed to use Filtered Include.
source : https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-5-0-preview-3/
Now I had to alter a table in my Database, and naturally, I executed this command in PackagaManagerConsole:
Scaffold-DbContext "Server=<Server Name>;Initial Catalog=<Database Name>;User ID=<user id>;Password=<password>;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Entity -Project <project Name> -force
usually it works fine and the DBContext is updated.
But now I'm getting the following exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeLoadException: Could not load type 'Microsoft.EntityFrameworkCore.Internal.SemanticVersionComparer' from assembly 'Microsoft.EntityFrameworkCore, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Microsoft.EntityFrameworkCore.Design.OperationExecutor..ctor(IOperationReportHandler reportHandler, IDictionary args)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Microsoft.EntityFrameworkCore.Tools.ReflectionOperationExecutor..ctor(String assembly, String startupAssembly, String projectDir, String dataDirectory, String rootNamespace, String language)
at Microsoft.EntityFrameworkCore.Tools.Commands.ProjectCommandBase.CreateExecutor()
at Microsoft.EntityFrameworkCore.Tools.Commands.DbContextScaffoldCommand.Execute()
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.<Configure>b__0()
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
I tried updating theses packages to the latest version :
Microsoft.EntityFrameworkCore ---> 3.1.8
Microsoft.EntityFrameworkCore.Design ---> 3.1.8
Microsoft.EntityFrameworkCore.Relational ---> 3.1.8
Microsoft.EntityFrameworkCore.SQLServer ---> 3.1.8
Microsoft.EntityFrameworkCore.Tools ---> 3.1.8
but I'm still getting the exception.
what should I do? I like having Filtered Include, so I don't want to uninstall the latest efcore preview.
So I went back and read the article that I referenced in the question, and I tried using developer command prompt instead of package manager console to scaffold the DBcontext.
I executed this command :
`dotnet ef dbcontext scaffold "server=<servername>;database=<database>;user=<user>;password=<password>" Microsoft.EntityFrameworkCore.SqlServ
er --project "DataAccess" --output-dir "Models" --force`
and it worked without problems.
but I still can't understand why that heppened.
Problem:
I wish to generate a Swagger file (Open API document) from an ASP.NET Core 2.2 Web API project (either from the solution file or Compiled assemblies).
Everything is tried using the NSwag tools.
Setup
I've installed NSwag studio so "nswag" command is directly available from Command prompt. I've also built using the following way as recommended:
dotnet build /p:CopyLocalLockFileAssemblies=true
Error: Command Line
The error I get after using AspNetCore2OpenApi command is:
Command: aspnetcore2openapi /assembly:TestApi.dll /documentName:OpenApi3 /output:swagger.json
System.InvalidOperationException: The command 'aspnetcore2openapi /assembly:testapi.dll /documentname:openapi3 /output:swagger.json' could not be found.
at NConsole.CommandLineProcessor.<ProcessSingleAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.<ProcessAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NConsole.CommandLineProcessor.Process(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.Process(String[] args)
Error:NSwagStudio
System.NullReferenceException: Object reference not set to an instance of an object.
Runtime: NetCore22
at CatalogApi.Extensions.HttpClientPolicyExtensions.AddPolicies(IServiceCollection services, IConfiguration configuration) in C:\Users\ansiddiq\Source\Repos\SS-ME-ES-APIC-CatalogService\Api\CatalogApi\Extensions\HttpClientPolicyExtensions.cs:line 36
at CatalogApi.Startup.ConfigureServices(IServiceCollection services) in C:\Users\ansiddiq\Source\Repos\SS-ME-ES-APIC-CatalogService\Api\CatalogApi\Startup.cs:line 102
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Hosting.ConventionBasedStartup.ConfigureServices(IServiceCollection services)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.EnsureApplicationServices()
at Microsoft.AspNetCore.Hosting.Internal.WebHost.Initialize()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at NSwag.Commands.Generation.OpenApiGeneratorCommandBase`1.CreateWebHostAsync(AssemblyLoader assemblyLoader) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\OpenApiGeneratorCommandBase.cs:line 318
at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunIsolatedAsync(AssemblyLoader assemblyLoader) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\AspNetCoreToOpenApiCommand.cs:line 309
at NSwag.Commands.IsolatedCommandBase`1.IsolatedCommandAssemblyLoader`1.Run(String commandType, String commandData, String[] assemblyPaths, String[] referencePaths) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedCommandBase.cs:line 71
at NSwag.Commands.IsolatedCommandBase`1.<>c__DisplayClass17_0.<RunIsolatedAsync>b__0() in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedCommandBase.cs:line 61
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
at NSwag.Commands.IsolatedCommandBase`1.RunIsolatedAsync(String configurationFile)
at NSwag.Commands.IsolatedSwaggerOutputCommandBase`1.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\IsolatedSwaggerOutputCommandBase.cs:line 47
at NSwag.Commands.Generation.AspNetCore.AspNetCoreToSwaggerCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\AspNetCoreToOpenApiCommand.cs:line 94
at NSwag.Commands.NSwagDocumentBase.GenerateSwaggerDocumentAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocumentBase.cs:line 279
at NSwag.Commands.NSwagDocument.ExecuteAsync() in C:\projects\nswag\src\NSwag.Commands\NSwagDocument.cs:line 81
at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 85
at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in C:\projects\nswag\src\NSwag.Commands\Commands\Document\ExecuteDocumentCommand.cs:line 32
at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
at NConsole.CommandLineProcessor.Process(String[] args, Object input)
at NSwag.Commands.NSwagCommandProcessor.Process(String[] args) in C:\projects\nswag\src\NSwag.Commands\NSwagCommandProcessor.cs:line 56
This error seems to be in a file where I use "Polly" library in Middleware for HTTP Retry logic. There is no problem in the code as it compiles/runs fine.
Any help is appreciated!
Since yesterday I have this error in the IIS from my web site, and not be is the
happens, the site compiles well in VS2013 but when I upload it to the IIS get that
error took more than 2 years site running without problem.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[Win32Exception (0x80004005): Access is denied]
[ExternalException (0x80004005): Cannot execute a program. The command
being executed was
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\vbc.exe" /noconfig
#"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\transiceberg\26691cf8\468c99a2\sxvljlta.cmdline".]
System.CodeDom.Compiler.Executor.ExecWaitWithCaptureUnimpersonated(SafeUserTokenHandle
userToken, String cmd, String currentDir, TempFileCollection
tempFiles, String& outputName, String& errorName, String trueCmdLine)
+3365 System.CodeDom.Compiler.Executor.ExecWaitWithCapture(SafeUserTokenHandle
userToken, String cmd, String currentDir, TempFileCollection
tempFiles, String& outputName, String& errorName, String trueCmdLine)
+8591876 System.CodeDom.Compiler.CodeCompiler.Compile(CompilerParameters
options, String compilerDirectory, String compilerExe, String
arguments, String& outputFile, Int32& nativeReturnValue, String
trueArgs) +331
Microsoft.VisualBasic.VBCodeGenerator.FromFileBatch(CompilerParameters
options, String[] fileNames) +875
System.CodeDom.Compiler.CodeCompiler.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromFileBatch(CompilerParameters
options, String[] fileNames) +179
System.Web.Compilation.AssemblyBuilder.Compile() +12440424
System.Web.Compilation.BuildProvidersCompiler.PerformBuild() +303
System.Web.Compilation.ApplicationBuildProvider.GetGlobalAsaxBuildResult(Boolean
isPrecompiledApp) +12978145
System.Web.Compilation.BuildManager.CompileGlobalAsax() +50
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +665
[HttpException (0x80004005): Cannot execute a program. The command
being executed was
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\vbc.exe" /noconfig
#"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\transiceberg\26691cf8\468c99a2\sxvljlta.cmdline".]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException()
+80 System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled()
+1142 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +1193
[HttpException (0x80004005): Cannot execute a program. The command
being executed was
"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\vbc.exe" /noconfig
#"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET
Files\transiceberg\26691cf8\468c99a2\sxvljlta.cmdline".]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12980692
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +12820285
It looks like certain rights have been revoked for the user. Try providing the user rights of an Admin.
In visual studio code, I issue dnx kestrel in command line palette.
But I am encountering an error like this
info : [Microsoft.Framework.DependencyInjection.DataProtectionServices] User
profile is available. Using 'C:\Users\myaccount\AppData\Local\ASP.NET\DataProt
ection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
System.InvalidOperationException: Unable to load libuv.
at Microsoft.AspNet.Server.Kestrel.Networking.Libuv.Load(String dllToLoad)
at Microsoft.AspNet.Server.Kestrel.KestrelEngine..ctor(ILibraryManager librar
yManager, IApplicationShutdown appShutdownService)
at Microsoft.AspNet.Server.Kestrel.ServerFactory.Start(IServerInformation ser
verInformation, Func`2 application)
at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
at Microsoft.AspNet.Hosting.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly,
String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String
applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly,
String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment
env, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, Framewo
rkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, FrameworkNam
e targetFramework)
Press any key to continue . . .
How do I fix this?
Thanks.
Kestrel use libuv an asynchronous I/O library. So, you could install it to use Kestrel as web server, or you could use dnx web to launch your app, where web is a command in project.json.
"commands": {
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --config hosting.ini",
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --config hosting.ini"}
Why do you want to use kestrel on win2012 ? You'd better use IIS or AspNet selfhost instead. Kestrel should be use on Linux or Mac
Oh so there's a thing called self-hosting? thanks #agua from mars for that info