private void btnGenerateBinding_Click(object sender, EventArgs e) { /*List<Type> types = new List<Type>(); * types.Add(typeof(int)); * types.Add(typeof(float)); * types.Add(typeof(long)); * types.Add(typeof(object)); * types.Add(typeof(string)); * types.Add(typeof(ValueType)); * types.Add(typeof(Console)); * types.Add(typeof(Array)); * types.Add(typeof(Dictionary<string, int>)); * types.Add(typeof(Dictionary<ILRuntime.Runtime.Intepreter.ILTypeInstance, int>)); * types.Add(typeof(TestFramework.TestStruct)); * ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(types, "..\\..\\AutoGenerate");*/ ILRuntime.Runtime.Enviorment.AppDomain domain = new ILRuntime.Runtime.Enviorment.AppDomain(); using (FileStream fs = new FileStream(txtPath.Text, FileMode.Open, FileAccess.Read)) { domain.LoadAssembly(fs); //Crossbind Adapter is needed to generate the correct binding code ILRuntimeHelper.Init(domain); string outputPath = ".." + Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "AutoGenerate"; // "..\\..\\AutoGenerate" ILRuntime.Runtime.CLRBinding.BindingCodeGenerator.GenerateBindingCode(domain, outputPath); } }
public void Load(string assemblyPath, bool useRegister) { fs = new FileStream(assemblyPath, FileMode.Open, FileAccess.Read); { var path = Path.GetDirectoryName(assemblyPath); var name = Path.GetFileNameWithoutExtension(assemblyPath); var pdbPath = Path.Combine(path, name) + ".pdb"; if (!File.Exists(pdbPath)) { name = Path.GetFileName(assemblyPath); pdbPath = Path.Combine(path, name) + ".mdb"; } _app = new ILRuntime.Runtime.Enviorment.AppDomain(useRegister ? ILRuntime.Runtime.ILRuntimeJITFlags.JITImmediately : ILRuntime.Runtime.ILRuntimeJITFlags.None); _app.DebugService.StartDebugService(56000); fs2 = new System.IO.FileStream(pdbPath, FileMode.Open); { ILRuntime.Mono.Cecil.Cil.ISymbolReaderProvider symbolReaderProvider = null; if (pdbPath.EndsWith(".pdb")) { symbolReaderProvider = new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider(); }/* else if (pdbPath.EndsWith (".mdb")) { * symbolReaderProvider = new Mono.Cecil.Mdb.MdbReaderProvider (); * }*/ _app.LoadAssembly(fs, fs2, symbolReaderProvider); } ILRuntimeHelper.Init(_app); ILRuntime.Runtime.Generated.CLRBindings.Initialize(_app); _app.InitializeBindings(true); LoadTest(); } lastSession = this; }
private void OnBtnLoad(object sender, EventArgs e) { if (txtPath.Text == "") { if (OD.ShowDialog() == DialogResult.OK) { Properties.Settings.Default["assembly_path"] = txtPath.Text = OD.FileName; Properties.Settings.Default.Save(); } else { return; } } try { using (FileStream fs = new FileStream(txtPath.Text, FileMode.Open, FileAccess.Read)) { var path = Path.GetDirectoryName(txtPath.Text); var name = Path.GetFileNameWithoutExtension(txtPath.Text); var pdbPath = Path.Combine(path, name) + ".pdb"; if (!File.Exists(pdbPath)) { name = Path.GetFileName(txtPath.Text); pdbPath = Path.Combine(path, name) + ".mdb"; } using (var fs2 = new System.IO.FileStream(pdbPath, FileMode.Open)) { Mono.Cecil.Cil.ISymbolReaderProvider symbolReaderProvider = null; if (pdbPath.EndsWith(".pdb")) { symbolReaderProvider = new Mono.Cecil.Pdb.PdbReaderProvider(); } else if (pdbPath.EndsWith(".mdb")) { symbolReaderProvider = new Mono.Cecil.Mdb.MdbReaderProvider(); } _app.LoadAssembly(fs, fs2, symbolReaderProvider); _isLoadAssembly = true; } ILRuntimeHelper.Init(_app); ILRuntime.Runtime.Generated.CLRBindings.Initialize(_app); LoadTest(); UpdateBtnState(); } } catch (Exception ex) { MessageBox.Show("[Error:]" + ex); } }
private void OnBtnLoad(object sender, EventArgs e) { if (txtPath.Text == "") { if (OD.ShowDialog() == DialogResult.OK) { Properties.Settings.Default["assembly_path"] = txtPath.Text = OD.FileName; Properties.Settings.Default.Save(); } else { return; } } try { using (FileStream fs = new FileStream(txtPath.Text, FileMode.Open, FileAccess.Read)) { var path = Path.GetDirectoryName(txtPath.Text); var name = Path.GetFileNameWithoutExtension(txtPath.Text); using (var fs2 = new System.IO.FileStream($"{path}\\{name}.pdb", FileMode.Open)) { _app.LoadAssembly(fs, fs2, new Mono.Cecil.Pdb.PdbReaderProvider()); _isLoadAssembly = true; } ILRuntimeHelper.Init(_app); _app.RegisterValueTypeBinder(typeof(TestVector3), new TestVector3Binder()); _app.RegisterValueTypeBinder(typeof(TestVectorStruct), new TestVectorStructBinder()); _app.RegisterValueTypeBinder(typeof(TestVectorStruct2), new TestVectorStruct2Binder()); LoadTest(); UpdateBtnState(); } } catch (Exception ex) { MessageBox.Show("[Error:]" + ex); } }
private void OnBtnLoad(object sender, EventArgs e) { if (fs != null) { fs.Close(); } if (fs2 != null) { fs2.Close(); } if (txtPath.Text == "") { if (OD.ShowDialog() == DialogResult.OK) { Properties.Settings.Default["assembly_path"] = txtPath.Text = OD.FileName; Properties.Settings.Default.Save(); } else { return; } } try { fs = new FileStream(txtPath.Text, FileMode.Open, FileAccess.Read); { var path = Path.GetDirectoryName(txtPath.Text); var name = Path.GetFileNameWithoutExtension(txtPath.Text); var pdbPath = Path.Combine(path, name) + ".pdb"; if (!File.Exists(pdbPath)) { name = Path.GetFileName(txtPath.Text); pdbPath = Path.Combine(path, name) + ".mdb"; } _app = new ILRuntime.Runtime.Enviorment.AppDomain(cbEnableRegVM.Checked ? ILRuntime.Runtime.ILRuntimeJITFlags.JITImmediately : ILRuntime.Runtime.ILRuntimeJITFlags.None); _app.DebugService.StartDebugService(56000); fs2 = new System.IO.FileStream(pdbPath, FileMode.Open); { ILRuntime.Mono.Cecil.Cil.ISymbolReaderProvider symbolReaderProvider = null; if (pdbPath.EndsWith(".pdb")) { symbolReaderProvider = new ILRuntime.Mono.Cecil.Pdb.PdbReaderProvider(); }/* else if (pdbPath.EndsWith (".mdb")) { * symbolReaderProvider = new Mono.Cecil.Mdb.MdbReaderProvider (); * }*/ _app.LoadAssembly(fs, fs2, symbolReaderProvider); _isLoadAssembly = true; } ILRuntimeHelper.Init(_app); ILRuntime.Runtime.Generated.CLRBindings.Initialize(_app); LoadTest(); UpdateBtnState(); } } catch (Exception ex) { MessageBox.Show("[Error:]" + ex); } }
private void button1_Click_1(object sender, EventArgs e) { if (OD.ShowDialog() == DialogResult.OK) { using (System.IO.FileStream fs = new System.IO.FileStream(OD.FileName, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { var path = System.IO.Path.GetDirectoryName(OD.FileName); var name = System.IO.Path.GetFileNameWithoutExtension(OD.FileName); using (System.IO.FileStream fs2 = new System.IO.FileStream(string.Format("{0}\\{1}.pdb", path, name), System.IO.FileMode.Open)) app.LoadAssembly(fs, fs2, new Mono.Cecil.Pdb.PdbReaderProvider()); ILRuntimeHelper.Init(app); //app.RegisterCrossBindingAdaptor(new TestFramework.ClassInheritanceAdaptor()); //app.RegisterCrossBindingAdaptor(new TestFramework.InterfaceTestAdaptor()); //app.DelegateManager.RegisterMethodDelegate<int>(); ////app.DelegateManager.RegisterMethodDelegate<int, string>(); //app.DelegateManager.RegisterFunctionDelegate<int, int>(); ////app.DelegateManager.RegisterFunctionDelegate<int, int, int>(); ////app.DelegateManager.RegisterMethodDelegate<MyClass2>(); //app.DelegateManager.RegisterDelegateConvertor<TestFramework.IntDelegate>((action) => //{ // return new TestFramework.IntDelegate((a) => // { // ((Action<int>)action)(a); // }); //}); //app.DelegateManager.RegisterDelegateConvertor<TestFramework.IntDelegate2>((action) => //{ // return new TestFramework.IntDelegate2((a) => // { // return ((Func<int, int>)action)(a); // }); //}); /*app.RegisterCLRMethodRedirection(typeof(UnitTest.Logger).GetMethod("Log"), (ctx, instance, param, ga) => * { * Console.WriteLine(param[0]); * return null; * }); * app.DelegateManager.RegisterDelegateConvertor<TestDele.Action2<int, string>>((action) => * { * return new TestDele.Action2<int, string>((a, b) => * { * ((Action<int, string>)action)(a, b); * }); * }); * * app.DelegateManager.RegisterDelegateConvertor<UnitTest.Perform.Action>((action) => * { * return new UnitTest.Perform.Action(() => * { * ((Action)action)(); * }); * }); * app.DelegateManager.RegisterDelegateConvertor<TestDele.myup>((action) => * { * return new TestDele.myup(() => * { * ((Action)action)(); * }); * }); * * app.DelegateManager.RegisterDelegateConvertor<Comparison<int>>((action) => * { * return new Comparison<int>((a, b) => * { * return ((Func<int, int, int>)action)(a, b); * }); * }); */ assembly = Assembly.LoadFrom(OD.FileName); } } }