-1

i have made wpf (c#) app that installs some of my apps to the windows, i am having issue with webapp when running .net hosting bundle repair.

my installer does this, amongst other things:

  1. Install .net hosting bundle 7.0.5
  2. Install IIS
  3. Copy app files to c:/inetpub/MyApp
  4. Give permission to that folder to IIS_IUSRS and DefaultAppPool
  5. Creates iis website localhost:8888
  6. Repairs .net hosting bundle (this step is necessary, since i get error "HTTP Error 500.19 - Internal Server Error" if i don't do it with c# process or manually)
  7. Restarts IIS

If i have no hosting bundle installed, this all works like a charm, but problem occurs when i have hosting bundle isntalled (in my case 7.0.5) and i try to repair through c#. My app just closes, i can't even get error in catch.

After installation (crash) i can manually opent hosting bundle .exe and click repair, or do it through cmd, than my website on iis works like it should Code for IIS installation is:

            string file = @"dism.exe";
            string arguments = $"/quiet /norestart /Online /Enable-Feature /FeatureName:IIS-WebServerRole /All";
            Process process = new Process();
            process.StartInfo.FileName = file;
            process.StartInfo.Arguments = arguments;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.Start();
            process.WaitForExit();

I've tried:

  • Run as admin
  • Stop IIS before repairing .net hosting bundle and starting it again
  • Execute repair with process()
  • Execute repair with cmd (inside my wpf(c#) app)
  • And so many combinations

my first code (that is working if .net hosting bundle is not installed, and my app does the install before creating iis site) is like this:

            string file = @"./Source/dotnet-hosting-7.0.5-win.exe";
            string arguments = $"/repair /quiet /norestart";
            Process process = new Process();
            process.StartInfo.FileName = file;
            process.StartInfo.Arguments = arguments;
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = true;
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
            process.Start();
            process.WaitForExit();

i have tried adding timeout

  int timeoutMilliseconds = 10000;
  if (!process.WaitForExit(timeoutMilliseconds))

i also tried giving full path to .net hosting bundle .exe file (even though it works when hosting bundle is not installed before my app starts install)

also this doen't work:

            process.OutputDataReceived += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.Data))
                    Console.WriteLine(e.Data);
            };

            process.ErrorDataReceived += (sender, e) =>
            {
                if (!string.IsNullOrWhiteSpace(e.Data))
                    Console.WriteLine(e.Data);
            };

basically, if there is .net hosting bundle installed before my wpf app is executed, repair doesn't work, i need to do it manually if i want my iis site to work

and btw this is the error i get before i do the repair enter image description here

PS: I have asked ChatGPT 100000 questions, it's useless in this case

edis1409
  • 149
  • 1
  • 7
  • 1
    The hosting bundle includes an IIS module. If you install the hosting bundle *after* installing IIS, no repair is needed because it's able to configure the module. Without IIS, it's missing the configuration file it needs to modify, which is why you're having to repair the installation. Installation order matters. – madreflection Jun 13 '23 at 19:13
  • as i said, i already have hosting bundle installed (v7.0.5) in this scenario (using hyper-V) but i can't open iis, so it's not installed with bundle – edis1409 Jun 14 '23 at 07:33

2 Answers2

1

So, i have found the solution, I've noticed that ApplicationHost.config didn't have element

<add name="AspNetCoreModuleV2" image="%ProgramFiles%\IIS\Asp.Net Core Module\V2\aspnetcorev2.dll" />

and i got to an conclusion that repairing hosting bundle registers this AspNetCoreModuleV2 to IIS, I have tired many different approaches to install this module alongside IIS installation but to no avail, tried giving args to dism.exe like:

/quiet /norestart /online /enable-feature /featurename:IIS-WebServerRole /featurename:IIS-ASPNETCoreModuleV2

The reason this happens is because Hosting bundle has been installed before IIS, since repair didn't work (my app keeps crashing) i figured out to just install "AspNetCoreModuleV2" after i install IIS

so i got my .msi on this site:

then i just installed it after iis, and it fixed the issue with the code

 string msiPath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Source" , "aspnetcoremodule_x64_en_v2.msi");
 process = new Process();
 process.StartInfo.FileName = "msiexec.exe";
 process.StartInfo.Arguments = $"/i \"{msiPath}\" /quiet /norestart";
 process.StartInfo.UseShellExecute = false;
 process.StartInfo.CreateNoWindow = true;
 process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
 process.Start();
 process.WaitForExit();
edis1409
  • 149
  • 1
  • 7
0

HTTP Error 500.19 – Internal Server Error

Error Code: 0x8007000d

The requested page cannot be accessed because the related configuration data for the page is invalid.

This problem occurs because the ApplicationHost.config or Web.config file contains a malformed or unidentified XML element. IIS can't identify the XML elements of the modules that are not installed. For example, IIS URL Rewrite module. For example: URL Rewrite module、ASP.NET Core module、CORS module.

Delete the malformed XML element from the ApplicationHost.config or Web.config file. Check the unidentified XML elements, and then install the relevant IIS modules. You can also refer to this article by Lex Li, maybe this will be helpful to you.

Similar thread: asp.net core web api published in IIS after moved to different IIS server pc gives error 500.19 (0x8007000d)

YurongDai
  • 1,362
  • 1
  • 2
  • 7