This is not a simple process of FTPing the report somewhere. Instead, the FEC provides a DLL that serves as the middleman between your program and their servers.
Welcome to the world of Disclose.dll.
Let’s step back to the beginning.
In that beginning the FEC hired a company named NIC (http://www.egov.com/) to write the greater part of their report processing and search software (http://www.egov.com/Partners/Pages/FEC.aspx). In fact if you go to FEC.gov and run a search for FEC report images the result page URL will be hosted on query.nictusa.com.
To work with NIC’s creation the FEC provides any and all developers with access to VendPack. (http://fec.gov/elecfil/vendors.shtml). VendPak is a small, NIC created, SDK of various DLLs, Java based tools, sample applications and readme files that allow you to check your FEC report against the current formatting standard, physically print the FEC report for manual inspection and most important actually upload that report to the FEC’s servers.
The problem is that the Disclose.dll is not exactly the most well-documented program ever created. In fact the documentation will actually destroy your chances of a successful project.
After struggling with implementation for a week I decided for the betterment of programmer-kind to post a rough reference to using Disclose.dll. There are no rights conferred here and if my code destroys everything you ever created then that’s on you. This blog should get you close enough to be able to refactor VendPak’s sample code into your .NET language of choice.
So…….Using Windows 7 Professional 32 Bit / Visual Studio 2010 SP1 / .NET 4.0
After creating a blank project in Visual Studio 2010 your reflex action is going to be to try to add a reference to Disclose.dll from within your project.
Wrong.
Disclose.dll is not a .NET assembly, so you are going to get something that looks very much like this.
A reference to ‘c:\Data\disclose.dll’ could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component.
Next you will head off to the search engines and look for a workaround. Most likely you will try a command line program called regsvr32.exe in an attempt to manually register Disclose.dll.
Let me save you the time and show you the error message that will give you.
The module “c:\data\disclose.dll” was loaded but the entry-point DllRegisterServer was not found.
Make sure that “c:\data\disclose.dll” is a valid DLL or OCX file and then try again”
You see Disclose.dll is not just not a .NET assembly, it’s not even a COM enabled assembly. I have no idea what language it’s written in but my guess is C++ or VB6.
So let’s jump through some of the landmines and required workarounds to work with disclose.dll. I’m going to go non-sequentially to handle the concepts one at a time.
Reference Disclose.dll
To reference this critical assembly you will need to add some code that looks very much like this.
Imports System.Runtime.InteropServices
Blah..Blah..Blah
Dim ParameterAssignmentResult as string
Blah..Blah..Blah
ParameterAssignmentResult = upload_file(FECReportName, FileUploadVariables, FileUploadVariables)
Blah..Blah..Blah
<dllimport("disclose.dll")>_
' Disclose.dll will take over at this point and upload the file
End Function
There’s a couple of things going on here.
First, this snippet creates a function in your code that maps to the existing function of the same name in Disclose.dll.
<dllimport("disclose.dll")>_
Public Function upload_file(ByVal cFilename As String, ByRef nVerify As Integer, ByRef doMd5 As Integer) As Integer
' Disclose.dll will take over at this point and upload the file
End Function
Second, this code invokes that upload_file function you just wrote, which as we’ve seen invokes the upload_file method in Disclose.dll.
ParameterAssignmentResult = upload_file(FECReportName, FileUploadVariables, FileUploadVariables)
Once you invoke this function Disclose.dll fires and handles the transfer of the file to the FEC and returns you a ReportID, or error code, to ParameterAssignmentResult.
Landmine Alert #1 - Make sure that Disclose.DLL is loaded into your C:\Windows\System32 directory so the .NET runtime can find it. If there is a way to hardwire an alternative path for Disclose.dll I have yet to make it work.
Landmine Alert #2 – If you download Dependence Walker (http://dependencywalker.com/) and cruse through Disclose.dll it’s clear that it depends on all kinds of 32 bit dll’s (USER32.DLL, WSOCK32.DLL etc.). I wrote this code on a 32bit machine, my guess is that you will have problems running it on a 64bit one.
Landmine Alert #3 - Make sure that all the other dll’s that are included in VendPak are copied into the same directory as your project is executing in. In other words if you build this project as a console application, you should have these additional .dll’s copied into the directory that the .exe resides in. These dll’s are largely included for encryption of the transmission and consist of pgpw2x_32.dll, pgpwck_32.dll, smplpgp_32.dll, md5_32.dll and ipwssl4.dll
When you first invoke Disclose.dll it’s going to check to see if you have already created the PGP keys. If not then it will ask you to randomly move your mouse across the screen to create those keys. Don’t worry, it saves the results so it’s a one-time deal.
Now that we’ve solved the add reference problem you are probably going to want to go ahead and refactor VendPak’s example code into your .NET language of choice.
Don’t do it.
Landmine Alert #4 - You see, it seems that the example code has not been updated in so long that there are some seriously wrong default values in it. Namely, the FilerPassword, FilerID and TCPHost. Use these values in your code and I guarantee you the loss of several hours.
As a developer you will need to get hold of Ken Lally at the FEC’s Electronic Filing Office. I don’t want to post his live e-mail address and direct line but if you contact me I’ll forward them to you. After a minimum of fuss you will get you very own CommitteeID, Password and the correct TCP host.
Now you can go ahead the refactor the VendPak code into your .NET language of choice. You will need to take all four of the sample code functions (initialize_parameter, initialize_comm_method, upload_file and get_last_server_response) and map up corresponding functions in your code. You should also know that there are different servers for Senate reports (senate.nictusa.com) all other live filers (disclose.nictuse.com) and test filers, that’s you, (testing.nictusa.com).

Did you get your software working?
ReplyDeleteI still cant get it work yet using c#.
I am using Platform Invoke and keep receiving System.Runtime.InteropServices.COMException: The system could not find the environment option that was entered. (Exception from HRESULT: 0x800700CB)
Thanks for posting this. It was helpful.
ReplyDelete