2

I have a .net core console application named ShowDate.

using System;

namespace ShowDate
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now);
        }
    }
}

After building I get ShowDate.dll rather than ShowDate.exe. I have tested it via terminal

dotnet ShowDate.dll

and it produces date time without problem.

Now I create a second .net core console application as follows.

namespace InvokingShowDate
{
    class Program
    {
        static void Main(string[] args)
        {
            Process p = new Process();
            p.StartInfo.FileName = "dotnet";
            p.StartInfo.Arguments = "ShowDate.dll";
            p.StartInfo.UseShellExecute = false;
            p.StartInfo.CreateNoWindow = false;

            p.Start();

            p.WaitForExit();

        }
    }
}

and it fails to run with the following error.

enter image description here

Question

What is wrong? How to solve it?

Edit:

Of course I have copied the ShowDate.dll and pasted it into the output folder of the second project.

2
  • I believe that you need to use the dotnet publish to actually produce an executable. From the docs: "If the project has third-party dependencies, such as libraries from NuGet, they're resolved from the NuGet cache and aren't available with the project's built output. [...] the product of dotnet build isn't ready to be transferred to another machine to run. This is in contrast to the behavior of the .NET Framework, [...] To have a similar experience with .NET Core, you need to use the dotnet publish command." Commented Mar 2, 2018 at 22:43
  • @mikez: Either published output or normal built output works if both ShowDate.dll and ShowDate.runtimeconfig are available for the second console app. Commented Mar 2, 2018 at 23:01

2 Answers 2

1

Apparently to solve it, I have to copy both ShowDate.dll and ShowDate.runtimeconfig.json and paste them to the output directory of the second project.

Sign up to request clarification or add additional context in comments.

3 Comments

There is a github issue describing this here.
I assumed you had dropped the extension. You are proposing that there are two files associated with .NET core, an app.runtimeconfig and a app.runtimeconfig.json, which produce similar errors in a similar situation? In all likelihood you have windows set to hide known file extensions.
@mikez: You are correct. The file ends with .json. Thanks!
0

Your second console app need to define entry point :

"buildOptions": {
    ...
    "emitEntryPoint": true
  },

2 Comments

which .Net core version you using
hmm, I am checking around. I faced similar issue in context of asp.net core and adding that to json file helped. but with 2017 i agree there is no .json file.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.