I am trying to program a DLL in C#. This DLL should work as a kind of port for Selenium to Visual FoxPro 9 SP2. My goal is to make a DLL (or other libray type) that will work with VFP and can use Selenium. So I searched a lot (all weekend) and I found nothing. For clarification, I found a lot of help, but none of it worked at all. I got to a point, where with regasm I managed to create .reg and .tlb files and run .reg file to create registry entry, but in VFP and function CreateObejct() [acording to some tutorials it's the only way to use .NET DLLs in VFP] it gave error "Entry point for function HelloWorld was not found" (or something similar to that, you got the idea) and same with DECLARE, which worked but function cannot be ran 'cos some issues (don't remeber excatly, something like "Class definiton cannot be found" or "Function defenition cannot be found" or "File cannot be found"). I tried everything that I found. I mainly tried to follow this tutorial: https://www.tek-tips.com/viewthread.cfm?qid=1619542 but I used a lot of other sources.
I tried:
- Registering it using regsv32 (not working with C#) and with regasm (worked but in VFP gave error)
- Before registering use sn -k and then call regasm with it (not worked at all)
- Changing all settings that I found I should change (even in combinations)
- Building with all types of kinds of build settings (I think it should be x86 as 32-bit, register as COM interop = true)
- Combining all above
I actually have no code, 'cos I am trying to make at least working DLL with HelloWordl() and Add() functions.
Thank you for any help
Edit: I am going to add here some code, that I already tried:
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface INarexDLL
{
[DispId(0)]
int Add(int a, int b);
[DispId(1)]
string HelloWorld();
}
[ComSourceInterfaces(typeof(INarexDLL))]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("Narex.NarexDLL")]
[ComVisible(true)]
public class Class1 : INarexDLL
{
public int Add(int a, int b)
{
return a + b;
}
public string HelloWorld()
{
return "Hello world";
}
}
And:
/// <summary>
/// Narex dll.
/// </summary>
[ComVisible(true)]
[Guid("82fb954d-378c-4e3e-9d57-2f812da564bc")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
public interface INarexDLL
{
/// <summary>
/// Hellos the world.
/// </summary>
/// <returns>Hello World</returns>
string HelloWorld();
/// <summary>
/// Add the specified a and b.
/// </summary>
/// <returns>a + b</returns>
/// <param name="a">First number</param>
/// <param name="b">Second number</param>
int Add(int a, int b);
}
/// <summary>
/// Narex dll.
/// </summary>
[ComVisible(true)]
[Guid("bf99a6f7-4a0b-4896-813b-dbea3f75041a")]
[ClassInterface(ClassInterfaceType.AutoDual)]
[ProgId("NarexV4.NarexDLL")]
public class NarexDLL : INarexDLL
{
/// <summary>
/// Hellos the world.
/// </summary>
/// <returns>Hello World</returns>
public string HelloWorld()
{
return "Hello World from C# COM DLL";
}
/// <summary>
/// Add the specified a and b.
/// </summary>
/// <returns>a + b </returns>
/// <param name="a">First number</param>
/// <param name="b">Second number</param>
public int Add(int a, int b)
{
return a + b;
}
}