Thursday, August 22, 2013

ASP.NET - Error When Switching To A Precompiled Application

When changing an ASP.NET web application from being dynamically-compiled to being precompiled, a runtime error cropped in my staging environment, which did not occur in my development environment. The error is an InvalidOperationException that reads:

The type specified in the TypeName property of ObjectDataSource 'MyDataSource' could not be found.

There are lots of suggestions for fixing this to be found on StackOverflow and elsewhere.  Some involve qualifying the type name in your ObjectDataSource declaration.  For me, it was already fully-qualified, using the name assigned by ASP.NET.

Another suggestion was to change the application from a virtual directory to an application in IIS.  In my case, it was already an application.

So, none of the suggestions I found fixed the problem.  For me, the problem fixed itself.  In about an hour, the error just went away.  I'm guessing this is because something cached on ASP.NET.  Maybe restarting the application in IIS would also fix the issue.  I don't have access to doing that in the staging environment on my PC, so I can't verify.  But if you're getting this error and don't see what the issue is, just try waiting. In one case, it took about 12 hours for the error to fix itself.

Of course, is the error is occuring on production, try restarting the application in IIS. Just keep in mind that if you're going from dynamically-compiled to precompiled, this runtime error is likely to occur if your application uses ObjectDataSource controls.

No comments:

Post a Comment