Having issues getting a dotnetcore2.1 console app running as part of a UWP package with full trust launcher, code:
<Extensions>
<desktop:Extension Category="windows.fullTrustProcess"
Executable="NBXplorer\NBXplorer.exe">
<desktop:FullTrustProcess>
<desktop:ParameterGroup GroupId="Parameters" Parameters="/--datadir
nbxplorer /--chains btc /--network testnet" />
</desktop:FullTrustProcess>
</desktop:Extension>
</Extensions>
if(ApiInformation.IsApiContractPresent
("Windows.ApplicationModel.FullTrustAppContract", 1, 0))
{
await
FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync
("Parameters");
}
The DotNetCore console launches, spits out the following console log:
Specify --help for a list of available options and commands net core
then the process is killed.... really don't get it when this DotNetCore app launched fine standalone
Hierarchy structuor for the DotNetCore app and dll dependencies is: UWPAppPackage->NBXplorer->Files
Really need help with this , I cannot afford to wait till end of year when MSFT releases a working fullTrust with DotNetCore3.0!
Parameters should NOT start with a '/ ', at least not for .NETCore apps, as depicted in the fullTrustLauncher examples of:
https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-2/
this is misleading
Related
I have created a simple, stripped down project to try to get this to work: ASP.NET Core 6 WebAPI project, hosted as a Windows Service, just trying to get it up and running with the sample WeatherForecast controller. I have added NuGet package for Microsoft.Extensions.Hosting (6.0.1) and Microsoft.Extensions.Hosting.WindowsServices (6.0.0). My program.cs looks like:
using IRDSPrototype.Configuration;
using IRDSPrototype.Services;
using Microsoft.Extensions.Hosting.WindowsServices;
var webApplicationOptions = new WebApplicationOptions
{
Args = args,
ContentRootPath = WindowsServiceHelpers.IsWindowsService() ? AppContext.BaseDirectory : default
};
var builder = WebApplication.CreateBuilder(webApplicationOptions);
builder.Services.AddHostedService<IRDSHostingService>();
builder.Host.UseWindowsService();
builder.WebHost.UseUrls(UriServices.GetBaseUri().AbsoluteUri);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
await app.RunAsync();
I created a background service as well:
public class IRDSHostingService : BackgroundService
{
public ILogger Logger { get; }
public IRDSHostingService(ILoggerFactory loggerFactory)
{
Logger = loggerFactory.CreateLogger<IRDSHostingService>();
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
Logger.LogInformation("IRDS Hosting Service is starting.");
stoppingToken.Register(() => Logger.LogInformation("IRDS Hosting Service is stopping."));
while (!stoppingToken.IsCancellationRequested)
{
await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
}
Logger.LogInformation("IRDS Hosting Service has stopped.");
}
}
I also created a service installer via Wix. When I run the installer it gets to the point of "Starting services" and fails with a message 'Verify that you have sufficient privileges to start system services'. When I check Windows Application Log, I see that error and a also see an error for:
Application: IRDSPrototype.exe
CoreCLR Version: 6.0.822.36306
.NET Version: 6.0.8
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.ServiceProcess.ServiceController, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
My publish directory and Wix manifest do include the System.ServiceProcess.ServiceController.dll.
I installed the service via sc.exe and the install succeeded, but starting the service gives an Error 5: Access Denied message. Unlike with the installer, though, this didn't generate any messages in the Windows log. I checked permissions on the folder containing the executable, giving full permissions to NETWORK SERVICE and LOCAL SERVICE. That didn't help. So I'm kind of stuck on what to do now. All my internet searches basically guided me to the setup I have now and it still doesn't work. So I'm at a loss. Anyone have any suggestions of what I'm missing here?
Thanks,
Dennis
Edit: So I'm whittling down the problem. It turns out I needed the version of System.ServiceProcess.ServiceController.dll that was published to my 'runtimes' folder under the .Net 6.0.0 runtime. So that error no longer shows up in the Event Viewer. The only erro that shows in the Event Viewer now is:
Error 1920. Service 'IRDS Prototype' (IRDSPrototype) failed to start. Verify that you have sufficient privileges to start system services
I have it installing as a Local Service and I believe I've given Local Service full permissions on the proper folders but I will check that. Still looking for suggestions though.
Edit #2: Getting closer. The problem I had when installing through sc.exe was that my binPath was wrong. I wasn't including the exe file in the binPath. Now I can install my service through sc.exe and it starts and works properly. The service still won't start when installed via my Wix installer though. So now I'm down to a Wix issue. Anyone with experience installing Windows services via Wix?
OK, it turns out what I needed to do was publish as a single executable:
Notice the "Deployment Mode: Self-contained" choice and "Produce single file" checked. After publishing that way, I only had to add the executable (no other files) to my Wix manifest and the generated installer worked fine. I'm guessing I was missing a dependency somewhere that I didn't know about. But it's weird that I was able to install and start the service from the same publish directory as I was trying previously with Wix via sc.exe. Anyway, it works now. Thanks to Md Farid Uddin Kiron for redirecting me back to the official page, which I read a little more carefully this time and found the little blurb about this being recommended.
I'm trying to debug and evaluate expression in my blazor wasm Program.cs using QuickWatch in my Visual Studio 2019. To make the breakpoint hit in Main method, I added
await Task.Delay(10000);
this gives debugging proxy some time to load as mentioned in docs.
Now after my break point gets hit if I select any expression and press Shift+F9 to toggle QuickWatch, I get
Unable to evaluate (Unable to evaluate)
for any variables, expression. Please assist on what I'm missing
Screen Print:
Currently Blazor WebAssembly does not support hitting breakpoint the Program > Main method inside Program.cs. Below is from Microsoft docs:
For now, you can't:
Break on unhandled exceptions.
Hit breakpoints during app startup before the debug proxy is running. This includes breakpoints in
Program.Main (Program.cs) and breakpoints in the
OnInitialized{Async} methods of components that are loaded by the
first page requested from the app.
For me it was an upgrade issue from DotNet Core 3.x to 5.0.
It is a good idea to create a completely new Blazor Application with identical configuration and compare all project files. In my case it was an entry in {MyProject}.Server.csproj of:
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="3.2.1" />
that needed to be updated to the latest version:
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="5.0.4" />
Everything worked fine to run and breakpoints were hit but until I changed that line all variables would show "Unable to evaluate (Unable to evaluate)" in Quickwatch and hovering in the editor showed nothing.
I have been chasing an issue with a AspNetCore web api project running on an Azure app service for a few days.
Basically I have a very small api project that when deployed / started - I get a 500.30 ANCM error. Cryptic enough - I pulled the event log from the app service and I find this:
<Data>Could not find inprocess request handler.
Captured output from invoking hostfxr: Error:
An assembly specified in the application dependencies manifest
(SampleApp.Api.deps.json) was not found:
package: 'System.Data.SqlClient', version: '4.6.1'
path: 'runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll'
</Data>
Looking at the SampleApp.deps.json - sure enough I see this:
"runtimeTargets": {
"runtimes/unix/lib/netcoreapp2.1/System.Data.SqlClient.dll": {
"rid": "unix",
"assetType": "runtime",
"assemblyVersion": "4.5.0.1",
"fileVersion": "4.6.27618.1"
},
"runtimes/win/lib/netcoreapp2.1/System.Data.SqlClient.dll": {
"rid": "win",
"assetType": "runtime",
"assemblyVersion": "4.5.0.1",
"fileVersion": "4.6.27618.1"
}
},
I have a similar (almost identical) project that is running fine on another app service. If run the
dotnet publish -c release /property:PublishWithAspNetCoreTargetManifest=true
(the same publish command I am running with the app I am having an issue with)
I do not see this section in the runtime targets section at all in the otherapp.deps.json file.
Where is this coming from and how do I get rid of it?
I had a similar situation
a aspnetcore webapp that worked
and a dotnet cli app that failed with an almost identical error as above
What worked for me was running dotnet publish cli-proj -r win-x64. This creates a self-contained bundle, which does not rely on any installed runtime. Then my deployment was taking all the files from bin/debug/netcoreapp3.1/win-x64/publish and pushing them to my webserver.
I'm sure the installed runtime is supposed to supply these files, but it doesn't seem to work well. This "fixed" my issue.
I had a similar issue, where most projects were .Net 5.0 and one class library was .NetStandard, upgrading the .NetStandard Library to .Net 5.0 fixed the issue.
I think the issue is re;ated to not having the correct runtimes for multiple platforms, ideally run with a single platform, or install all the required runtimes.
I forgot to publish the /runtime/ folder when I published on the iis server.
Just ran into the same issue. In my case, the publish profile had target runtime set to win-x64.
Changing this to portable got the publish command to generate the runtime directory and resolve the problem.
I have a .Net Core web application targeting net461 Framework. It was originally producing an .EXE and working fine when deploying to IIS. I want to change to a portable app, so I changed "buildOptions" in ProjectJson as follows:
"buildOptions": {
"emitEntryPoint": false,
"preserveCompilationContext": true,
"debugType": "portable"
},
Now when I compile I get a DLL and it runs fine in IIS Express, but when I publish to IIS and change the web.config aspnetcore element to:
<aspNetCore processPath="dotnet" arguments=".\myWebApp.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
forwardWindowsAuthToken="false" />
The project fails to run and I see "Failed to start process with commandline '"dotnet" MyWebApp.dll', ErrorCode = '0x80004005'" in the application event log.
Attempting to run from command line with "dotnet mywebapp.dll" results in:
A fatal error was encountered. The library 'hostpolicy.dll' required to
execute the application was not found in 'C:\inetpub\wwwroot\ETimeCore2'.
So I found and copied hostpolicy.dll to the directory and now get:
Could not resolve CoreCLR path. For more details, enable tracing by setting
CORE HOST_TRACE environment variable to 1
I did set the CORE HOST_TRACE to 1 and got a verbose response of all the dlls being loaded with just that one error (above) at the end so it added no value.
Any idea what I am doing wrong?? I prefer a DLL to an EXE because to publish changes when an .EXE, you have to recycle the app pool first which is a real pain.
You cannot use dotnet mywebapp.dll if disable "emitEntryPoint".
emitEntryPoint indicates whether the project is a console application vs. a library. From sources:
if (framework.IsDesktop() && compilerOptions.EmitEntryPoint.GetValueOrDefault())
{
OutputExtension = FileNameSuffixes.DotNet.Exe;
}
In your case the framework.IsDesktop() is true, as your target framework is net461, that is .NET Framework , not .NET Core. That's way you get .exe as output if enable emitEntryPoint.
Actually error "The library 'hostpolicy.dll' required to execute the application was not found in " right now means the following (see http://github.com/dotnet/cli/issues/2859 issue):
dotnet.exe cannot find the entry point in mywebapp.dll
I found voip example on github for UWP. Now I'm trying to create my voip app, and I want to use VoipHost project in my app. I added existing project, edited package manifest file. When I want to deploy the app to the device I get error:
Severity Code
Description Project
File Line
Suppression State Error
DEP6701 : Bootstrapping failed with unexpected error: 'The ID value is not specified. Parameter name: id'.
VoipHost
And one warning:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(1930,5): warning APPX1708: The executable 'VoipHost.exe' is specified as the implementation for the .winmd file. Only in-process servers are supported for generating registration information in the app manifest. You must specify the out-of-process server registration information in the app manifest.
Any advices?
Many thanks.
I had a similar issue deploying a headless application with Windows IoT running in a Raspberry pi 3. I solved the problem giving an "Assembly Identity" in the project properties.
You can do that following the next steps: Rigth Click to project --> Properties --> Manifest Tool --> General.
Fill the field "Assembly Identity" with any number. After that compiles, run and works like a charm.