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

COMException using AccpacFinder.ViewFinder in VB.NET 2

Status
Not open for further replies.

apexearth

Programmer
Apr 5, 2010
13
US
Hi, I'm trying to use the AccpacFinder.ViewFinder

I get an unhandled exception once I get to af.Finder(). No errors show up in af.Session.Errors. I'm using the AccpacCOMAPI on Windows 7 64bit with the program running in 32bit. I've tried everything I can think of but I can't seem to get this working. Any help is appreciated!

The code from within a button click event:
Code:
        Dim af As AccpacFinder.ViewFinder
        Dim SearchArray() As Object = {3, 4, 5, 6}
        Dim DisplayArray() As Object = {3, 4, 5, 6}
        Dim ReturnArray() As Object = {3}

        Me.Cursor = Cursors.WaitCursor

        af = New AccpacFinder.ViewFinder
        af.Session = al.Session
        af.ViewID = "IC0160"
        af.ViewOrder = 3
        af.SearchFieldIDs = SearchArray
        af.DisplayFieldIDs = DisplayArray
        af.ReturnFieldIDs = ReturnArray
        af.Filter = ""
        af.Finder()

        af = Nothing
 
A couple of things I can think of:
- is the session object open and valid;
- use a try ... catch and see if the ex.message returns anything;
- does the user have sufficient rights to read/write accpac data;
- if the data is not local, is there a proper connection to the database;
- Are the fiscal years and periods valid and unlocked
- try commenting out the filter line.

I don't know if any of these suggestions are relevant, but it's worth a look.

If at first you don't succeed, then sky diving wasn't meant for you!
 
Thanks for your Reply Bluejay07.

-The session object is open and valid. I've created IC Transfers with it.
-When I use the try catch, the error is a generic unmanaged COMException. One thing that is odd, is when I use a messagebox to display the error, the entire program crashes, even in debug mode. The message box fails to display.
-The user has admin rights for reading and writing accpac data.
-It is not local, but running since I can post transactions in the same program, I think it is okay. I've also tried running the program on the server, the same problem occurs.

Error from server:
System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at AccpacFinder.ViewFinderClass.Finder()

-The fiscal periods are not locked.
-Commenting out the filter does not fix the problem.


I'll keep fiddling with it, perhaps I'll get lucky and find a solution.

 
When the program errors in Debug mode and I take a look at my watch list, I can see that the view finder creates a datasource from the session. What puzzles me is that the viewid on the datasource is CS0100. I would think it should be IC0160.

Here's all the objects within the datasource, perhaps someone can see a red flag in there?

Active True Boolean
AutoCompose False Boolean
BrowseAscending True Boolean
BrowseFilter "" String
CheckDuplicateKeys True Boolean
ComposeViewIDs Nothing String
ComposeViewIDsArray {System.Array} Object
+CompositeNames {AccpacCOMAPI.AccpacViewCompositeNamesClass} AccpacCOMAPI.AccpacViewCompositeNames
+DBLink {AccpacCOMAPI.AccpacDBLinkClass} AccpacCOMAPI.AccpacDBLink
+DBLinkCompany {AccpacCOMAPI.AccpacDBLinkClass} AccpacCOMAPI.AccpacDBLink
DBLinkFlag DBLINK_FLG_READWRITE {0} AccpacCOMAPI.tagDBLinkFlagsEnum
DBLinkSystem Nothing AccpacCOMAPI.AccpacDBLink
DBLinkType DBLINK_COMPANY {1} AccpacCOMAPI.tagDBLinkTypeEnum
Description "Assemblies" String
DesignOrgID "SAMLTD" String
DesignPWD "ADMIN" String
DesignUID "ADMIN" String
Dirty False Boolean
DisplayName Nothing String
Exists True Boolean
+Fields {AccpacDataSrc.AccpacDSFieldsClass} AccpacDataSrc.AccpacDSFields
FireOnKeyChanged True Boolean
FireOnKeyChanging True Boolean
FireOnRecordChanged True Boolean
FireOnRecordChanging True Boolean
+InstanceExtra "IC0150,IC0165,IC0377,LOCATION=10," {String} Object
InstanceNoncascading False Boolean
InstanceNonheritable False Boolean
InstanceNotify False Boolean
InstancePrefetch 0 Integer
InstanceProtocol VIEW_INSTANCE_PROTOCOL_BASIC_SUPER {64} AccpacCOMAPI.tagViewInstanceProtocolEnum
InstanceRawPut False Boolean
InstanceReadonly False Boolean
InstanceSecurity 31 AccpacCOMAPI.tagViewSecurityEnum
InstanceUnrevisioned False Boolean
InstanceUnvalidated False Boolean
+Keys {AccpacDataSrc.AccpacDSKeysClass} AccpacDataSrc.AccpacDSKeys
LastReturnCode VC_SUCCESS {0} AccpacCOMAPI.tagViewReturnCode
Order 0 Integer
ParentDataSource Nothing AccpacDataSrc.AccpacDataSource
ParentName "" String
ProgramName "OC1000" String
PropertyFilter "" String
+RecordBookMark {System.Array} Object
RecordNumber 0 Integer
ReferentialIntegrity VIEW_REFINT_CASCADE {1} AccpacCOMAPI.tagReferentialIntegrityEnum
Security 31 AccpacCOMAPI.tagViewSecurityEnum
+Session {AccpacCOMAPI.AccpacSessionClass} AccpacCOMAPI.AccpacSession
SystemAccess VIEW_SYSACCS_FINDER {7} AccpacCOMAPI.tagSystemAccessEnum
TemplateDate #10/23/2008# Date
TemplateVersion "56A" String
Type ROTO_VIEW {1} AccpacCOMAPI.tagRotoViewTypeEnum
UniqueIndex False Boolean
UnpostedRevisions False Boolean
UseOpenViewInstance False Boolean
UseProcessServer False Boolean
UseRecordNumbering False Boolean
+View {AccpacCOMAPI.AccpacViewClass} AccpacCOMAPI.AccpacView
ViewID "CS0100" String
 
Do you have all of the proper references in place (eg. Accpac COM API Object, Accpac Finder, etc).

I only have this code in a Accpac 53 environment on Windows XP and it does work. Since this is several versions behind in both Windows and Accpac, you may be missing something that either needs to be referenced or initialized.

I'm also assuming Accpac works fine when using it directly?

If at first you don't succeed, then sky diving wasn't meant for you!
 
The problem appears to be with Windows 2008 & Windows 7. The code seems to work on Windows XP and Windows 2003. I tried it once before on Windows 2003 and it didn't work. I must have changed the code since then as it works fine now.

Thanks for your help on this.
 
I suspect your problem is related to DEP (data execution protection). It is something we came across a year ago when we built a .Net app that called AccpacCOM API UI's.

I've documented the issue on my blog. Here is the post:
Hope that helps!

Chris Zinck, P.Eng.
Zinck Computer Group
 
Excellent tip czinck.
That fully resolved the issue using editbin.exe with /NXCOMPAT:NO


It's good to know why it happens so I can prevent similar problems in the future.


Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top