Example #1
0
        public static void Main(string[] args)
        {
            string appBase = @".\\";
            PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(appBase);

            Program p = new Program();
            Go(args);
            //Console.ReadKey();
            Environment.Exit(0);
        }
Example #2
0
        /// <summary>
        /// Starts the managed MSH
        /// </summary>
        /// <param name="args">
        /// Command line arguments to the managed MSH
        /// </param>
        public static int Main(string[] args)
        {
#if CORECLR
            // PowerShell has to set the ALC here, since we don't own the native host
            string appBase = System.IO.Path.GetDirectoryName(typeof(ManagedPSEntry).GetTypeInfo().Assembly.Location);
            return((int)PowerShellAssemblyLoadContextInitializer.
                   InitializeAndCallEntryMethod(
                       appBase,
                       new AssemblyName("Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"),
                       "Microsoft.PowerShell.UnmanagedPSEntry",
                       "Start",
                       new object[] { string.Empty, args, args.Length }));
#else
            return(UnmanagedPSEntry.Start(string.Empty, args, args.Length));
#endif
        }
Example #3
0
        /// <summary>
        /// Managed entry point shim, which starts the actual program.
        /// </summary>
        public static int Main(string[] args)
        {
            // Application needs to use PowerShell AssemblyLoadContext if it needs to create powershell runspace
            // PowerShell engine depends on PS ALC to provide the necessary assembly loading/searching support that is missing from .NET Core
            string appBase = System.IO.Path.GetDirectoryName(typeof(Program).GetTypeInfo().Assembly.Location);

            System.Console.WriteLine("\nappBase: {0}", appBase);

            // Initialize the PS ALC and let it load 'Logic.dll' and start the execution
            return((int)PowerShellAssemblyLoadContextInitializer.
                   InitializeAndCallEntryMethod(
                       appBase,
                       new AssemblyName("Logic, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"),
                       "Application.Test.Logic",
                       "Start",
                       new object[] { args }));
        }
Example #4
0
 public AssemblyLoadContextFixture()
 {
     // Initialize the Core PowerShell AssemblyLoadContext
     PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(AppContext.BaseDirectory);
 }