When in Doubt Clear Your Bin

This is a reminder to myself, and anyone facing down a weird error message when trying to build their ASP.NET application: you need to try clearing out your Bin folder and rebuilding it. I've 'fixed' probably a dozen build problems so far just by clearing out my Bin and rebuilding the application. To clear your Bin folder:

  1. Find your project file in Visual Studio and left click it.
  2. Go up to the icons in your Solution Explorer and click 'Show All Files'.
  3. Find your Bin folder in your project, and right click it.
  4. Click 'Open File in Windows Explorer'.
  5. Select everything in the folder (Ctrl + A) and delete it.
  6. Rebuild your application.

I've got no idea why there were errors with my applications, or why this fixed them, but its always a good first line of defense. If you've got an error message you can't figure out, clean out your bin.

 

ASP.NET Error Message: Invalid postback or callback argument

If you're trying to create a post-back from Javascript in ASP.NET, you might have come across the following error:

Invalid postback or callback argument. Event validation is enabled using in configuration or in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

This message is caused because ASP is attempting to validate that a given post-back that was initiated from Javascript is really supposed to be happening; basically, it is an attempt to try to prevent cross-site scripting from issuing post-backs. You can do as the message says and register the callback, you can edit your web.config file, or you can do what I do, and add the following line to your Page directive in your .aspx page like so:

<%@ Page EnableEventValidation="false" ... %>

Be aware that by setting EnableEventValidation to false, you're opening a hole in your security. I'm using this in a situation where the risk has been minimized, but if you're including external scripts, you might want to actually go through the trouble of registering the event.

 

My First WPF Application

Well, not really my first application, but the first that I'd show to the public. Its a simple die rolling program that can handle rolling multiple dice, multi-sided dice (meaning dice that don't have 6 sides, I know all dice are multi-sided), additive/subtractive dice rolls, and roll modifiers. I've not been able to test it on other machines, so if it doesn't work, let me know. It probably requires .NET 3.5 to be installed on your machine, but if your reading my blog, you probably have it already.

Dice Roller v4.15
Example .NET 3.5 WPF Application

If any of you are wondering, dice rolling apps are my staple "hello world" app when learning a language/framework. They don't talk to a database (or at least this one doesn't), but they do involve string parsing, handling of arrays, visual layout, styling concerns, and "persistence" of settings when available (add some die rolls, close the app and open it again).

 

ASP.NET First Thoughts

I'd announced a few weeks back that I was taking a role as a .NET desktop developer, but I've found that I'm actually going to be doing a good bit of ASP.NET web development as well (w00t!). As such, I've shifted gears a bit and dropped my studies of WPF for ASP.NET, and although I'm certainly not an expert yet, I thought I'd share my first thoughts.

 

SQL Server Variable Declaration Gotcha

Part of my new job is to work more with Transact-SQL than I've ever done before, so I've been making stored procedures and batches of SQL commands all over the place. Today I ran into a nice little "gotcha" that had me stumped

 

SQL Server 2005, "5(Access Denied)" Error

I got the following error this morning trying to restore a SQL Server backup file:

Additional information: System.Data.SqlClient.SqlError: The operating system returned the error '5(Access is denied.)' while attempting 'RestoreContainer::ValidateTargetForCreation' on 'c:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\[my database name].mdf'. (Microsoft.SqlServer.Express.Smo)

And a little bit of Googling brought me to a page which set me straight; it turns out SQL Server was trying to put the files into the wrong directory. You can read more about it here, in the original post where I found the info.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.