Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can VFP be part of DotNet without loosing it's IDE?
Message
From
15/07/2003 09:44:57
 
 
To
14/07/2003 15:33:09
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00809892
Message ID:
00810185
Views:
20
David,

Problem solved ;-) the VFP community can now generate .NET framework executables from VFP's IDE. Compile the following class library for use from VFP through the interop layer.
using System;
using System.Runtime.InteropServices;
using System.CodeDom.Compiler;
using System.Reflection;
using Microsoft.CSharp;      


namespace VFPInteropSample
{
	[ClassInterface(ClassInterfaceType.AutoDual)]
	[ProgId("VFPInteropSample.Compile")]   
	public class Compile
	{
		public Compile()
		{
		}

		public int CompileScript(string SourceCode)
		{
			ICodeCompiler CSharpCompiler = new CSharpCodeProvider().CreateCompiler();
			CompilerParameters CompilerParams = new CompilerParameters();

 			CompilerParams.ReferencedAssemblies.Add("System.dll");
			CompilerParams.GenerateExecutable = true;
			CompilerParams.GenerateInMemory = false;
			CompilerParams.IncludeDebugInformation = false;
			CompilerParams.OutputAssembly = "c:\\generatedcode.exe";

			CompilerResults CompiledResults = CSharpCompiler.CompileAssemblyFromSource(CompilerParams, SourceCode);

			return(CompiledResults.Errors.Count);
		}
	}
}
Now create the following (c:\source.cs) source file.
using System;

class Hello 
{
   static void Main() 
   {
      Console.WriteLine("Hello World!");
   }
}
Now enter the following in VFP and voila! a ready to go C# compiler built using Microsoft Visual FoxPro technology <g>
loCodeGenerator = CreateObject("VFPInteropSample.Compile")
lcSourceCode = filetostr("c:\test.cs")
? loCodeGenerator.CompileScript(lcSourceCode)
It does need at least a weekends worth of work before we could call it production quality!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform