Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7006319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:27:45+00:00 2026-05-27T21:27:45+00:00

I need to call a Foxpro (VFP 8) COM object from C# The vfp

  • 0

I need to call a Foxpro (VFP 8) COM object from C#

The vfp code looks like this:

Define Class x2 As session OlePublic
    Function testInteropServer()
    ENDFUNC
Enddefine

The C# code looks like this:

[TestFixture]
public class TestFixture
{
    [Test]
    public void TestXtmBase()
    {
        xtmbase.x2 xtmBaseX2 = new xtmbase.x2();
        xtmBaseX2.testInteropServer();
    }
}

The COM server is compiled as an executable (not a dll). I can load it from Fox. It loads the object into .Net but I can’t seem to call any of it’s methods. I am importing the COM reference through the GUI in VS 2005. It recognizes all the methods and properties of the object. I just can’t access them.
I am getting the following error:

Test 'TestProject/TestFixture/TestXtmBase' failed:
    Execute
    System.Runtime.InteropServices.COMException: The server threw an exception.
        (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
    ErrorCode: -2147417851
    at xtmbase.x2Class.testInteropServer()

To remove the possibility of it being related to a COM executable I created a MT dll with the following code:

Define Class MTx2 As session OlePublic
  Function testInteropServer()
  ENDFUNC
Enddefine

I then created a console app:

class Program
{
    static void Main(string[] args)
    {
        mtx2.mtx2 mtx2 = new mtx2.mtx2();
        mtx2.testInteropServer();
        Console.WriteLine("Done");
    }
}

and it fails:

System.Runtime.InteropServices.COMException was unhandled
Message="The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
Source="Interop.mtx2"
ErrorCode=-2147417851
StackTrace:
   at mtx2.mtx2Class.testInteropServer()
   at ConsoleTest.Program.Main(String[] args) in E:\development\iisx2\ConsoleTest\Program.cs:line 12
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Any ideas why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:27:46+00:00Added an answer on May 27, 2026 at 9:27 pm

    It was due to DEP (Data Execution Prevention) (thanks pst) which seems to be a problem with Foxpro code.

    You can manually add your app to the DEP exception list via the GUI, but I needed a programmatic way of doing it so:

    Add the exe to the exclusion list using a registry key:
    HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
    “fullPathToExe”=”DisableNXShowUI”

    If DEP is active you have to reboot to make it work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to call an external dll from c#. This is the header definition:
I need to call a const function from a non-const object. See example struct
I need to call the initialize method of the parent class, from inside the
Can anyone tell me the best way to call FoxPro 9 code from a
I need to call some javascript code from my java app, can I do
I need to call CPython code from Java. What tools/APIs/libraries exist out there to
I need to call some PL/SQL procedures from my Java application. I can do
I need to call some methods in Wininet.dll from a Java program. I can
I need to call a web service from Javascript of a html page whose
I need to call Java web service from .Net application and that web service

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.