Error while connect to Access Runtime

Dec 24, 2015 at 8:25 AM
Edited Dec 24, 2015 at 8:29 AM
Good Morning,

iam developing a windows service with NetOffice.
My Service connects to an Access Applikation and Print the Reports asPDF.

On the developmentsystem is Visual Studio 2013 and MS Office 2013 Professional installed.
This includes a full version of Access 2013.

On the Targetsystem is a Runtime of Access 2010 installed.

On Both Systems i can manually open the Access Database, select the Reports and Print them.
But when i use my Service on the Target System i cant connect to Access and get the following error.

"IDispatch wird nicht vom COM-Ziel unterstützt"

Here is my Connectfunction.
   public bool TryConnect(Logger Log)
        {
            try
            {
                if (Access == null)
                    Access = new Application();

                Eventmessages.BeforeOpenAccessDB(Log);
                Access.OpenCurrentDatabase(this.AccessDBFile);  //Line where the Error Occurs.
                Eventmessages.AfterOpenAccessDB(Log);           
                Access.Quit(AcQuitOption.acQuitSaveNone);
                Eventmessages.QuitSuccessfully(Log,true);
               // Access.Dispose();
                Access = null;
                successfully = true;
            }
            catch (Exception ex)
            {
                int i = 1;
                string Error = i + ")" + ex.Message;
                while (ex.InnerException != null)
                {
                    i++;
                    ex = ex.InnerException;
                    Error += Environment.NewLine + i + ")" + ex.Message;
                }

                Access = null;
                Eventmessages.CouldNotConnectToDB(Log, Error,true);
                successfully = false;
            }

            return successfully;
        }
What can i do against that?

Greeting and Merry Christmas

Cazza
Coordinator
Dec 27, 2015 at 9:38 AM
Hello,

Can you verify it is not an issue with the service?
Because is typical running in LocalSystem/Network Account and this cause issues.
I other words: Have you already test this on your development machine as a real service?
(i have to ask because it is very common developers doesnt do this for debugging support and so on)


*Sebastian
Dec 29, 2015 at 10:03 AM
Hello Sebastian,

the Service is running in the user context on both systems as admin.
I have installed the Service on both machines as WIndows Service.
On my development machine runs the service without errors.
On the target system occurs the Error when i try to open the Database with by
Access.OpenCurrentDatabase(this.AccessDBFile);
Before i Start it, i check wheter the Access DB file exists.
If it not exists, the function wouldn´t be caled.


As a test i have written a basic test programm.
This only connects to the Access Database and export a Report as PDF, here happens the same error.

Cazza
Jan 12, 2016 at 8:43 AM
Its a Savety problem.

When is use a non compiled Access Database and a Full Installed Access 2010 everything works fine.

Greetings
Marked as answer by Cazzador on 1/12/2016 at 1:43 AM