Hello I have been trying for long to run a method from a dll I created using the powershell ise. Now I already run my dll from cmd by using 'dotnet foo.dll' but I would like to use the powershell as well.
Here is my code: Program.cs
using System;
namespace ConsoleApp1
{
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World!");
Console.ReadKey();
}
}
}
Now I have created a new console app with the .net core framework in VS2017 Enterprise. I only got a dll file after building no executable. I have researched online and found how to load the dll file with [Reflection.Assembly]::LoadFile("pathtofile") btw LoadWithPartialName doesn't work for some reason.
So after loading I try to invoke the Main method with [ConsoleApp1.Program]::Main() and i get this error
Unable to find type [ConsoleApp1.Program].
At line:1 char:1
+ [ConsoleApp1.Program]::Main
+ ~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (ConsoleApp1.Program:TypeName) [], RuntimeException
+ FullyQualifiedErrorId : TypeNotFound
Please help me I can't find any solution to this for hours.