"Unable to open company file" message returned

Hi all,

We're developing a  COM-aware .Net assembly that is used in a legacy VB6 app and keep getting the above message when opening a connection via SDKInstanceManager.Instance.OpenDatabase. When we call our method from inside another .Net assembly this does not happen, the call to open works fine. Below is the class we use:

    [ComVisible(true)]

    [ClassInterface(ClassInterfaceType.AutoDual)]
    [ComSourceInterfaces(typeof(IMyClass_ThreadedEvents))]
    [Guid("A8F518D8-6446-11E2-BC88-724F6188709B")]
    public class MyClass : IDisposable
    {    
        public string OpenConnection()
        {
            string retVal = string.Empty;

            try
            {
                retVal = "OpenConnection|@@|*NOERROR*|@@|*ALLOK*|@@||@@|";

                string conInstallFolder = @"C:\Users\Public\Documents\Simply Accounting\2017\Samdata\Pro";
                string conCompany = "Universl";
                string conUserName = "sysadmin";
                string conPassword = "12345";
                string conVersName = "Sage 50 Accounts";
                string conVersNumber = "2017";
                string conVersCountry = "Canada";

                bool allok = SDKInstanceManager.Instance.OpenDatabase(conInstallFolder + @"\" + conCompany + ".SAI", conUserName, conPassword, true,
                    conVersName + " " + conVersNumber + " " + conVersCountry, "SASDK", 1);
            }
            catch (Exception ex)
            {
                retVal = "OpenConnection|@@|*ERROR*|@@|" + ex.Message;
            }
            return retVal;
        }
    }

My VB6 code:

Private Function RunTestTasks()

Dim MyClass As New MyDLL.MyClass
Dim retval As String

retval = MyClass.OpenConnection()

Call MyClass.CloseConnection

Set MyClass = Nothing

End Function

The .Net assembly only references Sage_SA.SDK, Sage_SA.Domain and Sage_SA.Domain.Utility and targets x86. No instances of Sage or app is accessing the company file. The VB6 code runs as Windows administrator.

Is there anything we're missing? We're stuck and would like to fix this issue. Many thanks.

Parents
  • 0

    I'm not sure I am going to be any help but the problem seems to stem from connecting the VB6 app to the com dll.  So all I have are questions to look at, I don't have the answers.

    1) Does the com dll need a Declare Function statement in your VB6 app is correct or are you referencing directly to the dll?

    2) Because you are using the 2017 version of the Canadian Sage 50 program, do you have the correct SDK including the suffix eg. 2017.2 if your file is from 2017.2?

    3) Do you have the Sage 50 program installed on the machine you are running the program on?  Probably since it worked in a different program.

    4) When you do run it from within another .NET assembly do you see the process.pid file created under the *.saj folder?  This usually indicates the file is started and running.  You can also look for the mysqld.exe process in the windows Task list on the computer where the *.sai file is located.  When you close your program, the mysqld.exe process will disappear if no other program is accessing the database.

    5) Was your other .NET assembly also C#?  If so, what happens if you create a small VB.Net program to use the dll?  Will it work?

    Unfortunately, I can't really help directly with your programming.  I do program in VB.Net but I haven't touched VB6 since before 2010 and never did any interop and custom dll work with other languages to speak of.  I also gave up on using the SDK over 15 years ago because I didn't have enough programming knowledge to get it to work.  So none of my programming uses it.

  • 0 in reply to Richard S. Ridings

    4) When you do run it from within another .NET assembly do you see the process.pid file created under the *.saj folder? Yes the file appears

Reply Children