Unable to get z4opencfgSTD() method working on USPS AMS (Address matching system) to work under web/vb.net Interop project. Please help
-
Monday, April 27, 2009 10:09 PMHi
I started working on the USPS AMS software and I'm unable to get the z4opencfgSTD working on vb.net client server application. I also tried z4openSTD without success. I know that I'm missing something or I'm doing something wrong because many people are able to get the z4opencfgSTD to work. When calling z4opencfgSTD I get a return code of 2 which means "The USPS Address Matching System has expired".
The USPS dll is written in C and we have to use it in vb.net project
I'm sure that the DVD contents I have is not expired because I have the sample.exe working and also I talked to USPS AMS customer support to make sure everything is ok in terms of keys and codes
I did the unencryption properly and sample.exe is working fine and I'm able to run enquiries on the sample.exe DOS application
I have all the unencyrpted files under the bin folder of the vb.net web app I'm trying to get to work (z4config.dat, zip4_w32.dll etc)
I have all the classes including Z4OPEN_PARM properly written on the vb.net project
I even have config values properly set. I tried many different values on config_parm including the one's posted on the earlier part of this thread by other members
I tried with and without "\" at the end of folder path's etc etc. I made sure all the values are filled before calling the function
Please help me in getting the z4opencfgSTD to work
Thanks in advance
Some parts of my code are below
Public Shared Function z4opencfgSTD()
Dim objz4open_parm As New Z4OPEN_PARM()
objz4open_parm.config.address1 = "C:\USPS\ams_comm\"
objz4open_parm.config.addrindex = "C:\USPS\ams_comm\"
objz4open_parm.config.cdrom = "D:\"
objz4open_parm.config.citystate = "C:\USPS\ams_comm\"
objz4open_parm.config.crossref = "C:\USPS\ams_comm\"
'objz4open_parm.config.system = "C:\USPS\W32_Extract_combined\z4config.dat"
'objz4open_parm.config.system = "C:\MyDocuments\Visual Studio 2008\Projects\WebApplication3\WebApplication3\bin\W32_Extract_combined\"
objz4open_parm.config.system = "C:\MyDocuments\Visual Studio 2008\Projects\WebApplication3\WebApplication3\bin\zip4_w32.dll"
objz4open_parm.config.elot = "C:\USPS\ams_elot\"
objz4open_parm.config.elotindex = "C:\USPS\ams_elot\"
objz4open_parm.config.llkpath = "C:\USPS\lacslink\"
objz4open_parm.config.dpvpath = "C:\USPS\dpvdata\"
objz4open_parm.config.fnsnpath = "C:\USPS\ams_comm\"
objz4open_parm.status = 2
objz4open_parm.dpvflag = "Y"
objz4open_parm.elotflag = "Y"
objz4open_parm.ewsflag = "N"
objz4open_parm.fname = "C:\USPS\W32_Extract_combined\z4config.dat"
objz4open_parm.llkflag = "Y"
objz4open_parm.systemflag = "Y"
Dim rsvd_string As New StringBuilder
Dim rsvd As String = ""
rsvd.PadLeft(124)
Dim rsvd1 As String = ""
rsvd1.PadLeft(50)
Dim rsvd2 As String = ""
rsvd2.PadLeft(511)
Dim cdrom As String = ""
Dim fname As String = ""
'objz4open_parm.confi.rsvd = rsvd
'objz4open_parm.rsvd1 = rsvd1
'objz4open_parm.rsvd2 = rsvd2
'Return USPSAPI.z4opencfgSTD(New Z4OPEN_PARM())
Dim iz4opencfgSTDReturn As Integer
iz4opencfgSTDReturn = USPSAPI.z4opencfgSTD(objz4open_parm)
Return iz4opencfgSTDReturn
End Function
The following is the Interop method
'* open with custom parameters */
<DllImport("zip4_w32.dll", CallingConvention:=CallingConvention.StdCall, EntryPoint:="z4opencfgSTD", ExactSpelling:=False), ReliabilityContract(Consistency.WillNotCorruptState, Cer.None)> _
Public Shared Function z4opencfgSTD(<[In](), Out()> <MarshalAs(UnmanagedType.LPStruct)> ByVal parm As Z4OPEN_PARM) As Integer
End Function
- Changed Type Riquel_DongModerator Monday, May 04, 2009 7:47 AM don't follow up
All Replies
-
Thursday, April 30, 2009 2:52 AMModeratorHi Enggr,
Based on the information and explanation above, we can isolate that the issue is about how to use third party product. Hence I believe that the best answer to this question is to contact the third party support engineer. I didn't use this product, just recommend that you read the following articles about COM Interop and PInvoke for your reference:
1. Calling Win32 DLLs in C# with P/Invoke .
2. Introduction to COM Interop .
The above articles use C#. VB.NET uses same mechanism for these service.
Riquel
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
Monday, May 04, 2009 7:46 AMModeratorWe are changing the issue type to “General Discussion” because you have not followed up. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by changing the type at the top of the post window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions. Thank you!
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us. -
Sunday, August 30, 2009 8:06 AMHi engrr,
Did you ever get this to work? I am also doing a similar project using the USPS but i'm trying to write it in C#. Any luck on your end? -
Monday, August 31, 2009 6:59 PMHi Engr,
I know it's been a while, but can u let me know if you got this to work. I'm struggling with the return code of 2 from this call. I can't get past this. Can you please advise if you got this to work, and if so, how?
Thanks,
SK -
Thursday, August 09, 2012 6:52 PM
Almost 3 year later and I am struggling with the same problem. Has anyone gotten this to work in .NET? If so, can you send me a code sample of at least one of the calls (preferably z4opencfgSTD) in ether VB or C#.
Thanks
Dale
Dale W Scott

