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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMAPI / XAPI DLL Hell

Status
Not open for further replies.

Georen

Programmer
Jan 17, 2005
4
US
Hello everyone,

I have development experience creating DLLs and .NET assemblies as well as ASP and ASP.NET web pages.
The reason I am writing is because I am having difficulty with the ACCPAC xapi/comi dlls and getting them to work in a .NET assembly.

I have been able to create objects and browse views using the xapi inside a .asp page without any trouble, but I want to encapsulate this logic in a dll and I am not having problems.

I am coding in VB.NET and some sample code would be:

Code:
Dim theSession As AccpacSession

Sub Login(ByVal Username, ByVal Password, ByVal Database)

Try
   theSession.Open("ADMIN", "ADMIN", "SAMINC", dNow, 0)
            
Catch ex As Exception
   retVal = retVal & "Error Initializing the Session." & _
   theSession.Errors.Item(0).ToString
   theSession.Errors.Clear()
End Try

End Sub

When I create an object that contains this code the page loads for about 15 seconds then comes up with the following error:

Error Type:
Microsoft Active Server Pages (0x80004005)
The "Session" object was not opened.
/xapitest/xapitest.asp, line 4

sample xapitest.asp code is as follows:
Code:
Set ACCPAC = Server.CreateObject("Test.Test")
ACCPAC.Login("ADMIN", "ADMIN", "SAMINC")
I am not sure why I am getting these errors, but there is very little support in the way of documentation and I noticed there were a few developers on this forum with a good amount of knowledge. If possible can you please write me back and point me in the right direction?

Thanks
-A
 
Hey guys,

Regarding my last thread I have an update.
I am able to successfully create an ACCPAC Session through the xapi, but I cannot create any xapiview objects.

When I try I get the following error:

Error Type:
Test (0x80040154)
COM object with CLSID {25E6B455-8B9D-11D1-B5A9-0060083B07C8} is either not valid or not registered.
/xapitest/xapitest.asp, line 35

When adding the xapi library I have a choice between 2 dlls
1) ACCPACXAPI 1.0 Type Library
and
2) ACCPACXAPI 1.1 Type Library

Which is the prefered dll?

1) If select the first one then I have the interop dll added to my list of detected dependencies and I can build and run my code creating an accpac xapisession object but I can't create any xapiview objects

2) If I select the second one then I have the interop dll and the a4wcomex.dll added to my list of dependencies. I can still build the project fine but when I attempt to create xapiview objects I still get the same error.

I am not sure why this is?
Does anyone have any ideas?

Thanks
-A
 
To be honest i haven't worked with the ACCPAC and VB.Net yet. However I would recomment using the COMAPI instead of the xAPI. The xAPI (ACCPACXAPI 1.1 Type Library) hasen't changed much since before ACCPAC had .Net compliance (used loosley). The COMAPI is basically a wrapper around the xAPI giving you increased functionality and better .Net compatibility.

The only draw back is that the COMAPI is not neccessarily backward compatible. ACCPAC claims that it is forward compatible. In other words the COMAPI written in 5.2 will work on 5.3 but not neccessarily the other way around. Espicially if you use newly added features.

zemp
 
Zemp,

I have added the COMAPI dll to the project instead and the only lines I have in there are

Code:
Imports AccpacCOMAPI

Public Class Test

    Dim ACCPAC2 As New AccpacSession

    Public Sub New()
        MyBase.New()
    End Sub

    Function Login(ByVal Username, ByVal Password, ByVal Database)
        Dim retVal As String = ""
        Dim dNow As Date = Now.Date

        Try
            ACCPAC2.Open("ADMIN", "ADMIN", "SAMINC", dNow, 0, "")
        Catch ex As Exception
            retVal = retVal & "Error Initializing the Session.<br>" & vbNewLine & _
                     "<br>" & _
                     ex.Message & vbNewLine & _
                     "<br>" & vbNewLine & _
                     ex.ToString & vbNewLine & _
                     "<br>" & vbNewLine & _
                     ex.StackTrace & vbNewLine & _
                     "<br>" & _
                     "AccPac Error Count: " & ACCPAC2.Errors.Count & vbNewLine & _
                     "<br>" & _
                     ACCPAC2.Errors.Item(0).ToString
            ACCPAC2.Errors.Clear()
        End Try

        Return retVal
    End Function

End Class

when I attempt to create an object of this type from an .asp page such as:

Code:
<%@ Language="VBScript"%>
<%
	Response.Write("Starting Page ... <br>")
	
        dim ACCPAC
	Set ACCPAC = Server.CreateObject("Test.Test")
	
        ACCPAC.Login "ADMIN", "ADMIN", "SAMINC"
	Response.Write("Logged In ... <br>")
		
	Response.write("Page End ... <br><br>")
%>

I get the following error:

Error Type:
Accpac.Session.1 (0x80004005)
Unknown Error
/xapitest/xapitest.asp, line 77

Any ideas on what I can do to troubleshoot / debug this problem?
I've been reading through these forums a ton in the last few days and I've noticed you are somewhat of a guru in here. I would greatly appreciate your help in this matter.

Thanks
-A-
 
The 5.3A SDK has a number of .Net samples including ASP.Net (using C#). With .Net you can either talk to the ACCPAC COM API using the .Net Interop or talk directly to the AAS ACCPAC.Advantage.dll .Net assembly.

Unfortunatly I don't have visual Studio .Net installed on this machine, so I can't open the samples. On my machine the SDK installed them in the 'PLUSWDEV\SAMPLES\DOTNET\ASPDotNet' folder.

I would recommend downloading the SDK. Use the following link.


zemp
 
Uh, Zemp, you have to be a Development Partner to download it. I'm sure lots of people are going to try and fail.

Jay Converse
IT Director
Systemlink, Inc.
 
Yes, my oversight. Thanks for pointing that out Jay.

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top