Issue to open Web Browser and show web page from Web API - asp.net

I am currently developing an Web API programs with ASP.Net Core.
If someone calls a method from outside the Web API, it opens a specific web page(internal website).
When I run it from visual studio it works without errors, which occurs an error after I create a web site from IIS.
The below is my code.
Process p = System.Diagnostics.Process.Start(new ProcessStartInfo
{
FileName = #"C:\Program Files\Google\Chrome\Application\Chrome.exe",
Arguments = "http://localhost:5005/Popup/myPopUp/Index?Id=" + rtnVal + " --kiosk",
UseShellExecute = true
});
the below is the error I am getting
Faulting application name: Chrome.exe, version: 98.0.4758.81, time stamp: 0x61f44457
Faulting module name: chrome_elf.dll, version: 98.0.4758.81, time stamp: 0x61f44457
Exception code: 0x80000003
Fault offset: 0x0000000000032160
Faulting process id: 0x98b0
Faulting application start time: 0x01d81a0c3774c3af
Faulting application path: C:\Program Files\Google\Chrome\Application\Chrome.exe
Faulting module path: C:\Program Files\Google\Chrome\Application\98.0.4758.81\chrome_elf.dll
Report Id: 8a41bdb3-7f86-4784-8af6-b7154bf5b7e7
Faulting package full name:
Faulting package-relative application ID:

Related

Jpackage MSI upgrade does not complete if application is open

I'm working on a MSI installer for our java app using Jpackage.
Versions:
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment Temurin-17.0.1+12 (build 17.0.1+12)
OpenJDK 64-Bit Server VM Temurin-17.0.1+12 (build 17.0.1+12, mixed mode, sharing
jpackage 17.0.1
OS Name: Microsoft Windows Server 2019 Datacenter
OS Version: 10.0.17763 N/A Build 17763
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
Jpackage Usage:
jpackage --input ./home ^
--name "Acme Application" ^
--main-jar app.jar ^
--main-class org.springframework.boot.loader.JarLauncher ^
--java-options "-splash:$APPDIR/splash.png" ^
--java-options -Xmx2g ^
--icon resources/package.ico ^
--win-shortcut ^
--win-menu ^
--type msi ^
--app-version %1
Upgrade Process
The installation works fine and everything runs well. The upgrade process also works fine under normal circumstances. When the user tries to run the new MSI package while the application is still running, the MSI installer prompts the user to close the application before continuing:
Selecting to close the application and continue causes the application to close on the users desktop but the installer then prompts the user again with the same dialog. Selecting the same option (close and continue), allows the installer to complete but the user is then warned that they need to restart.
Upon restarting, it appears that application version 1.0.0 is still running. Checking the jar file signature before and after shows that installer failed to overwrite the original.
Event Viewer
Checking the event viewer, I'm only seeing a few things of interest:
Windows Installer requires a system restart. Product Name: *******. Product Version: 1.0.1. Product Language: 1033. Manufacturer: Unknown. Type of System Restart: 1. Reason for Restart: 0.
and
The Windows Installer initiated a system restart to complete or continue the configuration of '*******'.
Failing to Stop the Application
I also noticed that the application is not completely stopping. Looking at the task manager, it shows the application running under the user and then moves to background processes. This leads me to believe that it's still locking the jar file. The application stops normally under other circumstances so I'm not sure what's different here.
I'm assuming that I need to solve this mystery but I have no idea why the application wouldn't respond to the installer's close signal while working with everything else.
Alright, I've done some digging and this is related to JavaFX's lifecycle. Simply overriding the Application.stop method is not enough to properly shutdown on these types of close requests.
Two changes to my application fixed the issue:
Register a EventHandler on the primary stage onCloseRequest
Here I initialize my spring application as well as register the event handler to stop the application:
#Override
public void start(Stage stage) {
applicationContext.publishEvent(new StageReadyEvent(stage));
stage.setOnCloseRequest(event -> stop());
}
Ensure you have a call to System.exit in your EventHandler
Platform.exit is not enough to close the application under these circumstances:
#Override
public void stop() {
log.info("Shutting down application...");
applicationContext.close();
Platform.exit();
log.info("Shutdown complete");
// System.exit is required or the app will move to a background process on uninstall/upgrade
// events from Windows MSI installer
System.exit(0);
}

Unable to run blazor assembly project with hot reload feature enabled (.net 6 preview 5)

After installation net6 preview 3 and setting up the project to use net6 I have changed the launchSettings.json and added "hotReloadProfile": "blazorwasm" configuration.
When I run dotnet watch projects starts but I an unable to open the application because of error on client side (dotnet.6.0.0-preview.5.21301.5.js):
System.AggregateException: One or more errors occurred. (Failed to fetch dynamically imported module: https://localhost:5555/_framework/blazor-hotreload.js
TypeError: Failed to fetch dynamically imported module: https://localhost:5555/_framework/blazor-hotreload.js)
---> Microsoft.JSInterop.JSException: Failed to fetch dynamically imported module: https://localhost:5555/_framework/blazor-hotreload.js
TypeError: Failed to fetch dynamically imported module: https://localhost:5555/_framework/blazor-hotreload.js
at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__15`1[[Microsoft.JSInterop.IJSObjectReference, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext() in Microsoft.JSInterop.dll:token 0x600008f+0x154
at Microsoft.AspNetCore.Components.WebAssembly.HotReload.WebAssemblyHotReload.InitializeAsync() in Microsoft.AspNetCore.Components.WebAssembly.dll:token 0x6000098+0xc6
at Microsoft.AspNetCore.Components.WebAssembly.Hosting.WebAssemblyHost.RunAsyncCore(CancellationToken cancellationToken, WebAssemblyCultureProvider cultureProvider) in Microsoft.AspNetCore.Components.WebAssembly.dll:token 0x60000bd+0x1be
What else should be changed to enable hot reload feature?

Android application output verbosity with Xamarin Forms

Every time I deploy Xamarin Forms to Android I get approximately 1000 [mono-assembly] messages
In the Project / Build settings, I have set the requisite option to 'Quiet'
I have also implemented an environment.txt file with following
MONO_LOG_LEVEL=error
MONO_LOG_MASK=gc
In spite of this, I cannot get rid of these messages
[monodroid-assembly] ZIP: local header offset: 35499804; data offset: 35499912; file size: 1683384
[monodroid-assembly] /data/app/Mono.Android.DebugRuntime-kjbSvJffIh6KuLyEXW4fQQ==/base.apk entry: assemblies/netstandard.dll
[monodroid-assembly] ZIP: local header offset: 37183296; data offset: 37183408; file size: 90624
[monodroid-assembly] /data/app/Mono.Android.DebugRuntime-kjbSvJffIh6KuLyEXW4fQQ==/base.apk entry: typemap.jm
[monodroid-assembly] ZIP: local header offset: 37274032; data offset: 37274128; file size: 1304780
[monodroid-assembly] /data/app/Mono.Android.DebugRuntime-kjbSvJffIh6KuLyEXW4fQQ==/base.apk entry: typemap.mj
Please can advise what am doing wrong?

Getting assert at fx_muxer.cpp:316 upon startup of .NET Core App 1.0 on Ubuntu

I'm seeing the following output from my .NET Core App 1.0 on Ubuntu after adding a dependency for my PCL that targets netstandard1.3:
foo: /opt/code/src/corehost/cli/fxr/fx_muxer.cpp:316: static pal::string_t fx_muxer_t::resolve_fx_dir(host_mode_t, const pal::string_t &, const runtime_config_t &, const pal::string_t &): Assertion `mode != host_mode_t::standalone' failed.
Aborted (core dumped)
That line of code is:
// No FX resolution for standalone apps.
assert(mode != host_mode_t::standalone);
This didn't happen to me before, so I'm unsure where to start looking. How is this host_mode_t resolved on startup?
It seems to me the problem is that some dependency resolution is happening that doesn't need to, because of a mistake in a configuration file?
Thanks in advance.
EDIT:
This is the full output of the app upon startup once I set COREHOST_TRACE=1:
Tracing enabled
--- Invoked dotnet [version: 1.1.0, commit hash: 0bc55b1fcc0bd58987bf96683c15596918db2b13] main = { ./foo --staging }
Resolved fxr [/var/www/html/foo/staging/libhostfxr.so]...
Tracing enabled
--- Invoked hostfxr [commit hash: 928f77c4bc3f49d892459992fb6e1d5542cb5e86] main Own DLL
ath=[/var/www/html/foo/staging/foo.dll]
Checking if CoreCLR path exists=[/var/www/html/foo/staging/libcoreclr.so]
Detecting mode...
CoreCLR present in own dir [/var/www/html/foo/staging] and checking if [foo.deps.json] file present=[1]
--- Executing in standalone mode...
Treating application '/var/www/html/foo/staging/foo.dll' as a managed executable.
App runtimeconfig.json from [/var/www/html/foo/staging/foo.dll]
Runtime config is cfg=/var/www/html/foo/staging/foo.runtimeconfig.json
dev=/var/www/html/foo/staging/foo.runtimeconfig.dev.json
Attempting to ead runtime config: /var/www/html/foo/staging/foo.runtimeconfig.json
Attempting to read dev runtime config: /var/www/html/foo/staging/foo.runtimeconfig.dev.json
Runtime config[/var/www/html/foo/staging/foo.runtimeconfig.json] is valid=[1]
foo: /opt/code/src/corehost/cli/fxr/fx_muxer.cpp:316: static pal::string_t fx_muxer_t::resolve_fx_dir(host_mode_t, const pal::string_t &, const runtime_config_t &, const pal::string_t &): Assertion `mode != host_mode_t::standalone' failed. Aborted (core dumped)
This issue was twofold:
I was using rsync to publish the app to my server, but I wasn't deleting files no longer in use, so the dependency configuration files were still present;
I had, at some point, added "platform" as the "type" for "Microsoft.NETCore.App" in my dependencies for the "netcoreapp1.0" target. This was causing a DLL to be generated instead of a standalone executable.

IIS 7 Web Deploy can't handle creating sub folder?

For the past few days I'm trying to deploy my package to IIS 7 but I'm getting nowhere.
Whenever I try to publish the package I receive an error saying that the destination folder doesn't exist - but in fact it WAS created on the remote server but was empty (just the folder structure) :/
I'm building my package with a following command:
msbuild.exe /t:CreateWebPackages /toolsversion:4.0 CRM.msbuild
and trying to deploy it with:
CRM.cmd /M:server /Y
Result is:
C:\...WebService.deploy.cmd /M:crm-web /y
=========================================================
SetParameters from:
"C:...WebService.SetParameters.xml"
You can change IIS Application Name, Physical path, connectionString
or other deploy parameters in the above file.
-------------------------------------------------------
Start executing msdeploy.exe
-------------------------------------------------------
"C:\Program Files\IIS\Microsoft Web Deploy\\msdeploy.exe"
-source:package='C:...WebService.zip' -dest:auto,computerName='crm-w
eb-new',includeAcls='False' -verb:sync -disableLink:AppPoolExtension -disableLin
k:ContentExtension -disableLink:CertificateExtension
-setParamFile:"C:...WebService.SetParameters.xml"
Info: Adding sitemanifest (sitemanifest).
Info: Updating createApp (Kruk CRM Web Service/2.0.65000.65000).
Info: Adding contentPath (Kruk CRM Web Service/2.0.65000.65000).
Info: Adding dirPath (Kruk CRM Web Service/2.0.65000.65000).
Info: Adding child dirPath (Kruk CRM Web Service/2.0.65000.65000\bin).
Info: Adding setAcl (Kruk CRM Web Service/2.0.65000.65000).
Error: (2011-10-27 11:07:59) An error occurred when the request was processed on
the remote computer.
Error: Could not find file '\\?\C:\inetpub\wwwroot\CRM\2.0.65000.65000'.
Error count: 1.
But when i edit the SetParameters.xml file and change
<setParameter name="IIS Web Application Name" value="Web Service/2.0.65000.65000" />
to
<setParameter name="IIS Web Application Name" value="Web Service" />
it works!
So is there some magic trick that I need to do in order to create new dirs under the site ?
Found it! After experimenting with almost all of the available options of msbuild, msdeploy, project settings, IIS etc, I've noticed that msdeploy couldn't create my application under site's application pool because apparently it's identity had not high enough privileges to do so.
What did the trick was changing the identity of the site pool to Local System.

Resources