My question is that how can a VB.NET PROGRAM create exe's ?
Suppose in my program i have a button with caption "save as EXE" and when i click that
it saves the form as an executable.
I need this for my programming language????
Any code for that????
You know what's a programming language? Right?
You that it compiles the code into an exe.
I have implemented a programming language using VB.NET and it can create windows forms. But I dont know how to create excecutables of those forms.
Any code or a source for that????
I know how to make a exe file in C#.NET of a module :
Here's the code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
namespace Asharp_Compiler
{
class Program
{
static AssemblyName an;
static AssemblyBuilder ab;
static ModuleBuilder mb;
static TypeBuilder tb;
static _AppDomain ad;
static MethodBuilder meb;
static ILGenerator il;
static void Main(string[] args)
{
ad = AppDomain.CurrentDomain;
an = new AssemblyName("lol");
ab = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.Save);
mb = ab.DefineDynamicModule("Lol", "idk.exe");
tb = mb.DefineType("lolType", TypeAttributes.Public);
meb = tb.DefineMethod("main", MethodAttributes.Public | MethodAttributes.Static);
il = meb.GetILGenerator();
an.Name = "MyApp";
ab.SetEntryPoint(meb);
StreamReader sr = new StreamReader(args[0]);
string Code = sr.ReadToEnd();
foreach (string cmd in Code.Split('\n'))
{
if (cmd.StartsWith("print "))
{
il.Emit(OpCodes.Ldstr, cmd.Substring(6));
il.Emit(OpCodes.Call, typeof(System.Console).GetMethod("Write", new System.Type[] { typeof(string)}));
}
if (cmd.StartsWith("println"))
{
il.Emit(OpCodes.Ldstr, cmd.Substring(8));
il.Emit(OpCodes.Call, typeof(System.Console).GetMethod("WriteLine", new System.Type[] { typeof(string) }));
}
}
il.Emit(OpCodes.Ret);
tb.CreateType();
ab.Save(Path.GetFileNameWithoutExtension(args[0]) + ".exe");
}
}
}
Can i do the same with vb cause i don't know C# well