Jump to content
Server Maintenance This Week. ×

Error using activeX in C#


El_Pablo

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

Recommended Posts

I'm trying to talk to FM10 via the activeX. The problem is when I try to set the value of a FMPRO70Lib.Documents the ActiveX throws an error.

Here's a sample


FMPRO70Lib.Application fmApp;

FMPRO70Lib.Documents fmDocs;



fmApp = new FMPRO70Lib.Application();



fmApp.Visible = 1;



fmDocs = (FMPRO70Lib.Documents) fmApp.Documents; // Error here!



...

Does anyone know why?

Link to comment
Share on other sites

No, works just fine here. You did make a reference to the FM COM object, right?


using FMPRO70Lib;



namespace test_FMactiveX

{

    public partial class Form1 : Form

    {

        public Form1()

        {

            InitializeComponent();

        }



        private void button1_Click(object sender, EventArgs e)

        {

            FMPRO70Lib.Application fmApp;

            FMPRO70Lib.Documents fmDocs;



            fmApp = new FMPRO70Lib.Application();



            fmApp.Visible = 1;



            fmDocs = (FMPRO70Lib.Documents)fmApp.Documents;

            this.label1.Text = fmDocs.Count.ToString();

        }

    }

}

Link to comment
Share on other sites

Haven't had time to test this in 10 but keep in mind that there is known bug in the FM activeX implementation that if you hit it a number of times in quick succession, FM will go deaf and you'll get errors or scripts won't execute when you call them.

The only cure is to quit FM and restart it...

Link to comment
Share on other sites

Even if I quit FM and/or kill the process, I still had the null error. I really needed to reboot the computer. Might be something wrong with the internal addressing.

By the way, do you know how to get the current instance of FM? Or the object will get it automatically when I instanciate it?

Edited by Guest
Link to comment
Share on other sites

yes, it will hook into the running instance of FMP. If FMP is not running it will launch the last version you launched manually. So if you have FMP8, 9 and 10 installed on your machine (or FMP and FMPA) and none is running, the call to FMPRO will launch the last one you used.

Link to comment
Share on other sites

This topic is 5553 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.