Jump to content
Sign in to follow this  
JHaughey

ActiveX and C Sharp

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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×

Important Information

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