Workflow: Object Reference Errors and Why I Get The Same Results
While running a Workflow application recently developed, a problem manifested itself in a couple of different ways. There was first an error:
"Server was unable to process request.--->Object Reference not set to an instance of an Object"
Also, no matter how I varied the input information into the application, the result set always matched the result set that I had obtained the first time I ran the program. It would change if I closed and restarted the Workflow session, or republished the application to the server, and ran it again. But once running, it did not matter how many different iterations of input data I provided, the result set was the same, and that was frustrating.
Upon further review of my project, and specifically a linked workflow model inside of my project, it was discovered that there were two potential culprits for this behavior.
The first culprit was found within the properties of the linked model, specifically the "Use Caching" setting, found on the Caching Tab.
If this is turned on, it will retain and reuse settings stored in cache, and thus you might not see your result set change until the web cache is flushed and reset.
The other potential culprit can be that you may be using Global Variables in your project. While a complete discussion of the proper use of global variables is not the purpose of this article, you should be aware that choosing to use global variables for project properties that change in the process of running your application is an incorrect use of global variables. Global variables should be set at the beginning of your project, and then simply referenced, not changed, as the project completes.
User-defined variables are a better application design and can be modified or updated while in the application.
Once these two items were accounted for, and changed accordingly, the project ran exactly as desired.