none
Compiling an application with .net DLLs dependencies. How I can run application without ".NET Core runtime" installation. RRS feed

  • Question

  • Hello, I usually write scripts in powershell, however the task requires writing an agent in C#.

    After publish application I have files: firefoxWatcher.dll and firefoxWatcher.exe

    If I run application, it returns me error

    "A fatal error occurred. The required library hostfxr.dll could not be found"

    I understand that is the code I use libraries that are not on the destination computer.  If I install ".NET Core runtime", problem is gone, But I can`t install Dotnet on each computer :) it is over 500 Mb, for run 200 Kb application?

    I try to find what DLL I need using process monitor. Program trying toch a lot off dll in "C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\3.1." and other folders.

    How I can run application without ".NET Core runtime" installation. Please HELP :)

    here code:

    using System;
    using System.Diagnostics;
    
    namespace firefoxWatcher
    {
        class firefoxWatcher
        {
            public static void Main()
            {
                // Start the process.
                using (Process myProcess = Process.Start("C:\\Program Files\\Mozilla Firefox\\firefox.exe"))
                {
                    // Display the process statistics until
                    // the user closes the program.
                    System.Threading.Thread.Sleep(5000);
                    Process[] localByName = Process.GetProcessesByName("firefox");
                    foreach (Process theprocess in localByName)
                    {
    
                        Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
                        Console.WriteLine($"Started process: {theprocess.HasExited}");
    
                        do
                        {
                            if (!theprocess.HasExited)
                            {
                                // Refresh the current process property values.
                                theprocess.Refresh();                         
                                Console.WriteLine();
    
                                // Display current process statistics.
    
                                Console.WriteLine($"running process: {theprocess.Id}");
                                Console.WriteLine("-------------------------------------");
    
    
                                if (theprocess.Responding)
                                {
                                    Console.WriteLine("Status = Running");
                                }
                                else
                                {
                                    Console.WriteLine("Status = Not Responding");
                                }
                            }
                        }
                        while (!theprocess.WaitForExit(5000));
                    }
                }
            }
        }
    }


    Sunday, February 23, 2020 7:29 PM

Answers

  • Unfortunately, that's the cost of playing in the .NET playground.  You can't just install a couple of DLLs; the Core is too interdependent.

    Your application is quite simple.  You might consider rewriting it in native C++, which does not have such a massive runtime.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Sunday, February 23, 2020 7:31 PM
  • you could Publish self-contained, but thats still 150MB.

    or you target .NET Framework 4.5 instead of .NET Core, as this is included on all supported Windows versions.

    Sunday, February 23, 2020 9:10 PM
  • Also it can be done with publish options

    Sunday, February 23, 2020 11:57 PM

All replies

  • Unfortunately, that's the cost of playing in the .NET playground.  You can't just install a couple of DLLs; the Core is too interdependent.

    Your application is quite simple.  You might consider rewriting it in native C++, which does not have such a massive runtime.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Sunday, February 23, 2020 7:31 PM
  • Unfortunately, that's the cost of playing in the .NET playground.  You can't just install a couple of DLLs; the Core is too interdependent.

    Your application is quite simple.  You might consider rewriting it in native C++, which does not have such a massive runtime.


    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    I don`t know C# or C++ :) I need some luck for this

    But I will try to rewrite application.

    Thank you.


    Sunday, February 23, 2020 9:06 PM
  • you could Publish self-contained, but thats still 150MB.

    or you target .NET Framework 4.5 instead of .NET Core, as this is included on all supported Windows versions.

    Sunday, February 23, 2020 9:10 PM
  • you could Publish self-contained, but thats still 150MB.

    or you target .NET Framework 4.5 instead of .NET Core, as this is included on all supported Windows versions.

    Thank you.

    But Microsoft .NET Framework 4.5 is already a part of this operating system.  

    :) my application become 64 MB.


    Thanks for the advice, yesterday I tried to find all the necessary DLLs. This is useful knowledge.


    Sunday, February 23, 2020 9:29 PM
  • Also it can be done with publish options

    Sunday, February 23, 2020 11:57 PM