Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can VFP be part of DotNet without loosing it's IDE?
Message
De
15/07/2003 09:44:57
 
 
À
14/07/2003 15:33:09
Information générale
Forum:
Visual FoxPro
Catégorie:
Visual FoxPro et .NET
Divers
Thread ID:
00809892
Message ID:
00810185
Vues:
21
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!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform