Type ‘System.Web.UI.WebControls.Parameter’ does not have a public property named ‘DbType’.

I recently got this error after deploying a .NET 2.0 web site from my dev machine to a development web server. It ran fine on my machine, but continuously generated the error:

Type ‘System.Web.UI.WebControls.Parameter’ does not have a public property named ‘DbType’.

on the dev server. I validated that both my dev machine and the web server had the exact same version of the .NET framework AND that the web site on the dev server was configured for the 2.0 framework.

My dev machine is running Windows XP Pro 64bit and the dev server is Windows Server 2003 Standard Edition 32bit. The app was developed with Visual Studio 2005.

As a sanity check, I started my VM with Windows Server 2003 32bit with Visual Studio 2005. I checked in the app from my XP 64bit host to VSS, then retrieved it from VSS in my VM. Compiling and running in the VM worked just fine but deploying it to dev still had the error. I created a new typed dataset, dragged the same table to it and copied the queries from the offending datatable in the original typed dataset. I then changed the code to reference the new dataset. Compiled, ran locally, and it worked (no surprise), then deployed to dev, and it worked! Huh? It still had the DBType in the dataset files… which is where the dev server was pointing me to for the error before. This makes no sense. I then checked that code into VSS from my VM and got the latest onto my XP 64bit host. Compiled locally, ran, and it worked, then deployed to dev and it worked. So, I went back to my original typed dataset and pulled the designer up side by side by the new dataset and examined the fields, the queries, and the parameters… all the same! I then deleted some extra datatables in my dataset that weren’t being used (and had referential links to the offending table), excluded the new dataset from the project (rather than deleting it), then changed the code back to use the original dataset. Now everything works everywhere!

So, I’m not entirely sure what the cause was, but I think removing the linked datatables from the dataset helped solve the problem. Of course, this doesn’t explain why the old version worked differently between my dev machine and the dev server.

Anyway, there you have it. If you run into this problem, try deleting links from your datatables and/or recreate a new typed dataset, one piece at a time, compiling, and deploying one step at a time.