initial version of custom hosting code

This commit is contained in:
Peter Honeder
2015-07-29 17:31:24 +02:00
parent a31af1e301
commit 72bcbd9eea
9 changed files with 44 additions and 8 deletions
@@ -2,4 +2,5 @@ using System.Runtime.CompilerServices;
using System.Reflection;
[assembly:InternalsVisibleTo("System.Management.Automation")]
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]
@@ -2,3 +2,4 @@ using System.Runtime.CompilerServices;
using System.Reflection;
[assembly:InternalsVisibleTo("System.Management.Automation")]
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]
@@ -8,6 +8,7 @@ using System.Reflection;
[assembly:InternalsVisibleTo("Microsoft.PowerShell.CoreCLR.AssemblyLoadContext")]
[assembly:InternalsVisibleTo("ps_test")]
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]
//
@@ -0,0 +1,4 @@
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]
@@ -0,0 +1,4 @@
using System.Runtime.CompilerServices;
using System.Reflection;
[assembly:AssemblyFileVersionAttribute("1.0.0.0")]
[assembly:AssemblyVersion("1.0.0.0")]
@@ -8,6 +8,7 @@ using System.Management.Automation.Runspaces;
using System.Management.Automation.Host;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
namespace ps_hello_world
{
@@ -456,8 +457,11 @@ namespace ps_hello_world
public static void init()
{
string psBasePath = System.IO.Directory.GetCurrentDirectory();
PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(psBasePath);
//string psBasePath = System.IO.Directory.GetCurrentDirectory();
//PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(psBasePath);
//Assembly a = Assembly.Load(new AssemblyName("System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"));
//Console.WriteLine("##########################\nloaded assembly a=" + a + " during init\n#########################");
// PH: this debugging requires a change in the core PS stuff that was stashed away
// during source cleanup
@@ -520,6 +524,19 @@ namespace ps_hello_world
}
}
public static void UnmanagedMain(int argc, [MarshalAs(UnmanagedType.LPArray,ArraySubType=UnmanagedType.LPStr,SizeParamIndex=0)] String[] argv)
{
init();
List<String> allArgs = new List<String>();
for (int i = 0; i < argc; ++i)
{
allArgs.Add(argv[i]);
}
test2(allArgs.ToArray());
}
static void Main(string[] args)
{
// important: