Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMAPI Finder on X64 server

Status
Not open for further replies.

IDLSYS

Vendor
Jun 29, 2007
11
0
0
GB
I have coded a program on my x86 development server that uses the find function - this works fine - the code that you see below works on an x86 PC.
When I try and run the program on an x64 server (win2008) it does not work.
It initally stopped at the Session.init
I overcame this by changing the active solution platform to X86 from any CPU
The program now passes this and now stops on the find.finder statement.

My open code is:
Dim procError As Boolean = False
Try
Session.Init("", "XY", "XY0001", "60A")
Catch ex As Exception
MsgBox("Init Error = " & accpacdbase)
procError = True
End Try

Try
Session.Open("ADMIN", "ADMIN", accpacdbase, System.DateTime.Today, 0, "")

Catch ex As Exception
MsgBox("Open problem " & System.DateTime.Today)
procError = True
End Try

Try
mDBLinkCmpRW = Session.OpenDBLink(tagDBLinkTypeEnum.DBLINK_COMPANY, tagDBLinkFlagsEnum.DBLINK_FLG_READWRITE)
Catch ex As Exception
MsgBox("DatabaseLink error:" & ex.Message)
End Try

My Find Code is:

Dim oFind As AccpacFinder.ViewFinder
Dim SearchArray() As Object = {1, 14} (I have tried Integer here)
Dim DisplayArray() As Object = {1, 14}
Dim ReturnArray() As Object = {1, 14}

Try
Me.Cursor = Cursors.WaitCursor

oFind = New AccpacFinder.ViewFinder
oFind.Session = Session
oFind.ViewID = "AR0024"
oFind.ViewOrder = 0
oFind.SearchFieldIDs = SearchArray
oFind.DisplayFieldIDs = DisplayArray
oFind.ReturnFieldIDs = ReturnArray
oFind.Filter = ""
oFind.Finder() (THIS IS WHERE THE ERROR OCCURS)



The error message is:
System.Runtime.InteropServices.COMException occurred
ErrorCode=-2147467259
Message="Error HRESULT E_FAIL has been returned from a call to a COM component."
Source="Interop.AccpacFinder"
StackTrace:
at AccpacFinder.ViewFinderClass.Finder()
at IDL_0002_COL_ACC_IC_S.IDL_0002_Frm1.btnFindCustomer_Click(Object sender, EventArgs e) in J:\IDL Programs\Colex-New\IDL-0002-SQL-Live-Test\IDL-0002-COL-ACC-IC-S\IDL_0002_Frm1.vb:line 2116
InnerException:


Can anybody tell what I need to do to get this to work on an X64 PC ?????




 
I haven't been able to get the Accpac Finder work in 64 bit environment. It seems to be an OCX thing that won't work with 64 bit development.
 
Thanks for this, but this does not help my client.
There MUST be somebody out there that knows how to get the finder to work on an X64 server.
Is there any other way to get this finder to work ?????????

All help will be most welcome
 
MORE INFORMATION:
I have continued testing.
I am now testing the program from a workstation.
When I run it there, I get the message that there is Invalid Signon Infomation - Make sure you supply the correct user ID and Password.
I DO NOT get this when running the program on the X64 server - It passes this code and only aborts on the find.Finder statement
The user ID and password are the standard, is ADMIN and ADMIN, which I know are correct.
 
I'm running on Vista Home Premium x64 and have no problem with the finder.

Don't forget that the Sample Data for 5.6 and 6.0 is pushed into the year 2019 and 2020. You're trying to sign on to today's date which is likely preventing you from signing on.

This is from an Excel COM Add-in:

Code:
    Private Sub butGLAcct_bar_Click(ByVal sender As Object) Handles butGLAcct_bar.Click
        If lSignonID = 0 Then
            MsgBox("Please log on to Accpac first.")
            Exit Sub
        End If

        Dim fnd As New AccpacFinder.ViewFinder
        Dim VisibleFields() As Integer = {1, 3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
        fnd.Session = Session
        fnd.ViewID = "GL0001"
        fnd.DisplayFieldIDs = VisibleFields
        fnd.ReturnFieldIDs = 1
        If fnd.Finder = True Then
            ExcelApp.ActiveCell.Value = "'" & Trim(fnd.ReturnFieldValues)
        End If
        fnd = Nothing


    End Sub

Code:
    Private Function SignOnToAccpac() As Boolean
        SignOnToAccpac = True
        If Not (Session Is Nothing) Then
            Exit Function
        End If
        lSignonID = 0 ' MUST be initialized to 0 since you don't have a signon ID yet
        sessmgr = New AccpacSessionManager.AccpacSessionMgr
        With sessmgr
            .AppID = "XY"
            .AppVersion = "56A"
            .ProgramName = "XY0001"
            .ServerName = "" ' empty string if running on local computer
            .ForceNewSignon = True
            .CreateSession("", lSignonID, Session) ' first argument is the object handle (if you don't have one, pass "")
        End With ' mSessMgr
        If IsNothing(Session) Then
            SignOnToAccpac = False
        Else
            OpenAndComposeViews()
        End If

    End Function
 
Hi DjangMan;
Thanks for your help here - I have seen this code before as I have spent many days going through all of the forums.
- I am not using demo data, but client data which is valid for todays date.
- I have tried to play around with your code, but can not get the code to work.
I am using the COMAPI in .NET VS2008
Dim Session As New AccpacCOMAPI.AccpacSession
Dim mDBLinkCmpRW As AccpacCOMAPI.AccpacDBLink
so I do not think that this calling method will work ???

Please can you tell me what your connection is to "sessmgr" so that I can then use your code

THIS IS WHAT I HAVE NOW
Private Function openSession() As Boolean
Dim SignOnToAccpac As Boolean = False
Dim lsignonID As String = 0
SignOnToAccpac = True
If Not (Session Is Nothing) Then
Exit Function
End If
lsignonID = 0 ' MUST be initialized to 0 since you don't have a signon ID yet
'sessmgr = New AccpacSessionManager.AccpacSessionMgr
Dim sessmgr As AccpacCOMAPI.AccpacSession
sessmgr = New AccpacCOMAPI.AccpacSession
With sessmgr
.AppID = "XY" - (ERROR - Property APPID is read only)
.AppVersion = "56A" As above
.ProgramName = "XY0001" As above
.ServerName = "" ' empty string if running on local computer
.ForceNewSignon = True
.CreateSession("", lsignonID, Session) ' first argument is the object handle (if you don't have one, pass "")
End With ' mSessMgr

Much appreciated for your help !!!!!!!!!!!

 
Have you imported interopservices?

Code:
Imports System.Runtime.InteropServices

Please can you tell me what your connection is to "sessmgr" so that I can then use your code

I don't understand what you mean by 'your connection'.

Maybe they've changed something with 6.0 that makes APPID read only. I haven't run my code against a 6.0 database.

Something else to watch is that the earlier version of Accpac (or any other version) cannot be found on the PATH.

Outside applications accessing the COMApi can load the wrong version of Accpac very easily.
 
This the code - I was asking for the DIM for sessmgr;
Dim sessmgr As AccpacCOMAPI.AccpacApplication
sessmgr = New AccpacSessionManager.AccpacSessionMgr
Is the above correct ?? as I get the following error - see below;
In References I have declared the Accpac dlls;
COMAPI / Data source control / Finder / Session manager / Signon Manager/ (Am I missing anything)

ERROR MESSAGE:
Unable to cast COM object of type 'AccpacSessionManager.AccpacSessionMgrClass' to interface type 'AccpacCOMAPI.AccpacApplication'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B5C56173-9214-11D3-9FBC-00C04F815D63}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

This really upsets me as my old code works perfectly on X86 !!!!!
Much appreciated.
 
Sorry - forgot to mention.
Putting in the Dim for accpac application sorted the .APPID, etc errors.
Thanks
 
That tells me that your session manager isn't installed correctly. Try running the regacc program in the runtime folder to register all of the controls.

I checked in my code and GUID {B5C56173-9214-11D3-9FBC-00C04F815D63} is related to the IAccpacApplication interface.

Ah - there's likely the problem. Here is declaration:
Code:
    Dim sessmgr As AccpacSessionManager.AccpacSessionMgr
    Dim Session As AccpacCOMAPI.AccpacSession

Yours is listed as:
Code:
    Dim sessmgr As AccpacCOMAPI.AccpacApplication
    sessmgr = New AccpacSessionManager.AccpacSessionMgr

You declared the sessmgr as an AccpacApplication and then try to instantiate it as a AccpacSessionMgr.



 
Thnaks very much for your help - I am slowly getting past each step.
The missing item in the open section is the declaration of the OpenAndComposeViews - I have tried a few settings but nothing works. Please can you let me see what the dim is.
I have noticed when I test this up to this point it asks me to sign in each time I use the finder button ??? this is even when I am actually signed into accpac at the time - which is how the users will use it. How do we stop this ??
Agains thanks for your time and effort - it is all appreciated.


Dim Session As New AccpacCOMAPI.AccpacSession
Dim sessmgr As AccpacSessionManager.AccpacSessionMgr
sessmgr = New AccpacSessionManager.AccpacSessionMgr
'Dim OpenAndComposeViews As ?????????????????
Dim SignOnToAccpac As Boolean = False
Dim lsignonID As Integer = 0
SignOnToAccpac = True
If Not (Session Is Nothing) Then
Exit Function
End If
lsignonID = 0 ' MUST be initialized to 0 since you don't have a signon ID yet

With sessmgr
.AppID = "XY"
.AppVersion = "56A"
.ProgramName = "XY0001"
.ServerName = "" ' empty string if running on local computer
.ForceNewSignon = True
.CreateSession("", lsignonID, Session) ' first argument is the object handle (if you don't have one, pass "")
End With ' mSessMgr
If IsNothing(Session) Then
SignOnToAccpac = False
Else
OpenAndComposeViews()
End If
 
OpenAndComposeViews is a sub-routine that my code uses to open up the Accpac views. It isn't an Accpac COM object.

In my case, the user clicks a button to connect to Accpac, uses the finder to gt data into Excel and then clicks a button to disconnect from Accpac.

My Session variable is global, not declared inside of the button code. If you see the first few lines of my code to run the finder you'll see that I check to make sure that the lSignonID variable has been assigned a non-zero which means that the user is still connected to Accpac. When they disconnect from Accpac I set the lSignonID variable to 0.

[Code Invoking the finder]
Private Sub butGLAcct_bar_Click(ByVal sender As Object) Handles butGLAcct_bar.Click
If lSignonID = 0 Then
MsgBox("Please log on to Accpac first.")
Exit Sub
End If

Dim fnd As New AccpacFinder.ViewFinder
Dim VisibleFields() As Integer = {1, 3, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}
fnd.Session = Session
fnd.ViewID = "GL0001"
fnd.DisplayFieldIDs = VisibleFields
fnd.ReturnFieldIDs = 1
If fnd.Finder = True Then
ExcelApp.ActiveCell.Value = "'" & Trim(fnd.ReturnFieldValues)
End If
fnd = Nothing


End Sub
[/code]
 
FYI Plus more assistance please:
I eventually got this working.
It had NOTHING to do with my code - my code was Good;
It is to do with the new 2008 R2 operating system. I had to turn of DEP by issuing the command (bcdedit /set nx alwaysoff).
The finder now works.
Client does not want this turned off on their server, so I am investigating in putting this in my program.
Apparently you can use the Post Build function to do this.
Is there anybody out there who has done this for .Net on VS 2008, as I have never done this before. I have been trolling the web and it all looks Greek to me.

much appeciated for any help offered.
 
You can turn on DEP for specific programs. Perhaps IT will allow you to run your program without DEP stopping it from functioning.
 
Try this:

With sessmgr.CreateSession("", lsignonID, out Session) ' first argument is the object handle (if you don't have one, pass "")

"out" to reference Session.
 
Chris, you may want to check your blog comments for spam posts :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top