Jump to content
Server Maintenance This Week. ×

ActiveX and C Sharp


This topic is 4260 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Just begining to explore ActiveX for FM. I have a short console program I'm using to play around with different ideas. However, I can not get the "DoFMScript" method to work. In fact there seems to be a problem with how I'm creating the document object that I can not chase down. Here is the code

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using FMPRO70Lib;

using System.Data.OleDb;

using System.Data.Odbc;

namespace ConsoleApplication1

{

class Program

{

static void Main(string[] args)

{

FMPRO70Lib.Application FMProApp;

FMPRO70Lib.Documents FMProDocs;

FMPRO70Lib.Document FMProDoc;

try

{

FMProApp = new FMPRO70Lib.Application();

FMProDocs = new FMPRO70Lib.Documents();

FMProDoc = new FMPRO70Lib.Document();

FMProApp.Visible = 1;

FMProDocs.Open("C:\\Filemaker\\Job2.fp7", "Admin", "");

So far no problems this all works fine.

Console.WriteLine(FMProDoc.Parent);

FMProDoc.Activate();

FMProDoc.DoFMScript("New_Record");

FMProDoc = null;

FMProApp = null;

FMProDocs = null;

}

catch(Exception ex)

{

Console.WriteLine(ex);

}

}

}

}

This part is the showstopper. Any reference to to the document object "FMProDoc" causes a failure. The error message for this version says "Exception from HRESULT: 0x80010105 <RPC_E_SERVERFAULT>> at FMPRO70Lib.IFMIdocument.get.Parent<>"

What is wrong with my code?

Link to comment
Share on other sites

You initiate the FMProDoc instance here:

FMProDoc = new FMPRO70Lib.Document();

But you never assign anything to it.

Try this:

FMProDoc = FMProDocs.Open("C:FilemakerJob2.fp7", "Admin", "");

If you want to see some working code, download the source code for fmDotNet (www.fmdotnet.org). Buried in there somewhere is commented out code that uses the ActiveX interface. I don't think I ever took it out.

Oh, keep in mind that there is a bug in FM (has been ever since FM8) that if you call a script through the ActiveX interface a few times in relative quick succession (as you will do I'm sure in testing), the ActiveX interface will go deaf. At some point the script will not fire. When you see that, you have restart FM.

Link to comment
Share on other sites

This topic is 4260 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.