Problem with C#  
Author Message
RAYMOND KNIGHT





PostPosted: Visual C# Express Edition, Problem with C# Top

Is it possible to create a DLL using C# that can be declared and run in FOXPRO:

I am using the following C# code to create TESTCODE.DLL :

using System;

using System.Collections.Generic;

using System.Text;

using System.IO;

class DirectoryLister

{

public static void Main(string[] args)

{

int i = 0;

String FILE_NAME = "C:/Test.txt";

String path;

String name;

name = " ";

int j = args.Length;

Console.WriteLine("HIT SPOT A " + j.ToString());

if (args.Length > 1)

{

Console.WriteLine("HIT SPOT B");

Console.WriteLine(args[0]);

Console.WriteLine(args[1]);

if (Directory.Exists(args[0]))

{

path = args[0];

}

else

{

return;

}

FILE_NAME = args[1];

FILE_NAME.Trim();

if (File.Exists(FILE_NAME))

{

File.Delete(FILE_NAME);

}

StreamWriter sr = File.CreateText(FILE_NAME);

DirectoryInfo dir = new DirectoryInfo(path);

foreach (FileInfo f in dir.GetFiles()) i = i + 1;

if (i == 0)

{

sr.WriteLine("NO FILES FOUND THAT MEET SPECS");

}

else

{

sr.WriteLine(i.ToString());

sr.WriteLine(path);

sr.WriteLine(FILE_NAME);

foreach (FileInfo f in dir.GetFiles())

{

name = f.Name;

long size = f.Length;

DateTime creationTime = f.CreationTime;

sr.WriteLine(name);

}

}

sr.Close();

}

}

}

When I attempt to run the DLL in FOXPRO:

DECLARE INTEGER main IN TESTCODE.DLL
I = main()

After attempting to run the FOXPRO program, I get the following message:

Cannot find entry point in main in the DLL.



Visual Studio Express Editions44  
 
 
NeederOfVBHelp





PostPosted: Visual C# Express Edition, Problem with C# Top

correct me if I'm wrong, but dlls aren't supposed to have entry points, right That's the difference between a dll and an exe
 
 
RAYMOND KNIGHT





PostPosted: Visual C# Express Edition, Problem with C# Top

Yes, and that seems to be my problem. FOXPRO can't find the entry point. I don't know if this has something to do with C# or FOXPRO.
 
 
NeederOfVBHelp





PostPosted: Visual C# Express Edition, Problem with C# Top

Visual fox Pro doesn't claim to be CLR compatible does it I don't think you can get a C# dll to work with visual fox in the first place, although I may be mistaken
 
 
nobugz





PostPosted: Visual C# Express Edition, Problem with C# Top

C# cannot create a traditional DLL. It can however create a COM (ActiveX) component, newer versions of Foxpro should be able to use those. Create a class library project, Project + properties, Build tab, check "Register for COM Interop". Not sure if the Express version allows you to do that...