“Connection to the server has been reset…” problems with ASP.Net after installing SQL Express 2008

Posted in Programming with tags , , , , , , on January 4, 2010 by ajh1138

The fix: I put these two attributes in the <pages> element in your web.config file…

enableEventValidation=”false” viewStateEncryptionMode=”Never”

Found the solution here after much installing/reinstalling/updating/frustration/hassle/crying/thoughts-of-giving-up-on-web-development-and-becoming-a-security-guard-again:

http://siderite.blogspot.com/2007/08/aspnet-connection-to-server-has-been.html

Now here’s the interesting thing…I removed the two attributes and saved web.config to confirm the fix.  My site still worked.  So I did an iisreset to make doubly sure, and voila – the site broke again without those attributes.  So, as is often the case when you’re trying to convince a laptop with Vista Home Premium that it’s actually a web server, beware false positives, false negatives and any other results you might get.  Clear your browser cache and do an iisreset whenever you fiddle with this kind of stuff.

So why did this work?  I managed to track down the spot where it was breaking, and it was inside a component that’s part of the third-party e-commerce suite we’re using.  It was obviously trying to do some data access that SQL 2008’s components didn’t like.  Why would the ASP.Net forms stuff affect it?  Black Box hoodoo voodoo reasons, I guess.  Was it the attributes that actually fixed the problem, or did my web.config just need to be fiddled with so the site would recompile in a certain way?  Sadly, I am too busy to dig into that mystery.

edit: removed a space from the attributes.

My Doodad-A-Week Project

Posted in Uncategorized with tags , , , , , , , on December 23, 2009 by ajh1138

Pretty simple plan: Make one game a week. Inspired by such projects as Game-A-Week and Thing-A-Week, I decided this will be a good way to get off my butt and start learning the various technologies and techniques I need to.  I was nudged into it by this post on Smashing, as well as recent events and the coming new year.

And I don’t plan on limiting this to just video games.  I’m going to make some board games; pencil-and-paper RPGs; games of skill involving household items.  Anything goes!

The technologies I plan on learning/using are:

  • Silverlight 4
  • Flex 4
  • jQuery
  • YUI
  • Lots of CSS
  • GameMaker
  • BlockLand
  • ASP.Net MVC
  • Python

…and whatever else that catches my fancy.

Micro-Rant: I’m sure a lot of my focus will be on mobile web games.  It’s a market that is woefully underdeveloped – just look at Apple’s mobile web games page.  I think Apple doesn’t emphasize web games/apps because they can be used by anybody with a browser.  And as much as I love their stuff, Apple is all about proprietary.  Notice there’s no Flash on the iPhone?  It’s not a technology issue.  It’s because once an app or game is written in Flash, it’s available to all platforms with little or no additional coding.  So what incentive would a developer have to write something in that god-awful Objective C and Cocoa mess if they could do it in Flash and have it available everywhere? End of Micro-Rant.

Oh by the way, I’ve ditched platform-specific mobile app design in favor of browser-based mobile apps.  We have a little ledger web site I built a few years ago where we keep track of our spending, and converting it to a mobile version was total cake.  I was using it as a test project to learn native iPhone development, but decided I was wasting my time learning something that was so proprietary.  As far as I’m concerned, coding in Objective C is like going back to punchcards – except that the punchcards are wet and you have to punch the holes with a dull pencil that’s held in your teeth.  It’s the least-convenient language I’ve actually tried to learn.  But I have two really great books on iPhone development, though, if anybody’s interested!

I don’t know how long I’ll continue the project, but I’m sure I’ll take breaks and work on more involved projects here and there.  I should make Hauler my first release, as it should only take a few hours polish it up and get it playable.

Edit: I’m expanding the scope of this endeavor.  It was originally just Game-A-Week, but I’d like to not be limited to games.  I have a lot of little tools and handy things I’d like to build and this weeklong development cycle is perfect for them.

Replacing newline characters in Flex 3

Posted in Uncategorized on December 8, 2009 by ajh1138

loremTEXT.replace(/\r\n|\r/gm, “\n”);

That does the trick.  I had to dig quite a bit to get the RegEx that worked.  Finally found it in the comments of this post.

Apparently my computer was using just \r?  Dunno.  Anyway, hope this helps somebody.

Cocoa/Objective C development tips for .Net Folks: Part I

Posted in Programming, Uncategorized with tags , , , , , on October 1, 2009 by ajh1138

No, this isn’t about using .Net to make iPhone apps!  It’s just a set of observations that might make it easier for people like me who currently use .Net (specifically, ASP.Net) at work, but want to start fiddling around with some Objective C, Cocoa, etc.

Keep in mind that this is from the perspective of someone who got into web development without traveling down the formal education route (when some of my buddies were learning C, COBOL and PASCAL in CompSci 101, I was sucking sand through a gasmask, patrolling some godforsaken ammo dump or airfield in the middle of nowhere).  I have no pure C language knowledge or insight, so all of this stuff is new to me.  I know many web developers in the same situation, so maybe this will help some people make the connections between Obj C and the types of languages they’re used to.

- “Actions” are event handlers.
- “Outlets” are properties that can be bound to your user interface widgets.  They are objects of the same type as the given widget. So if you have a RoundedButton on your UI, you’ll probably have a RoundedButton in your .h/.m code if you want it to actually do something.

From what I can tell, you don’t need to name the specific buttons in the UI part…you associate the button with its corresponding outlet via a drag-and-drop in the UI editor (“Interface Builder”).  I’m pretty sure you can do it manually/dynamically via code, too.  In the .Net world, you’d set the name of the button in the UI editor or in your HTML code, and Visual Studio would automatically make the corresponding code additions.  I haven’t seen that ability in XCode/Interface Builder, but I’m totally new to this so don’t take it to mean that it doesn’t happen.

You can think of the .xib file (known as a “nib” file by Cocoa vets to honor the former file extension) as needing a code-behind page.  The nib is your UI, and the .h and .m files need to be told “Hey, I have these do-dads on the UI.”  After all, if you dig through the code that ASP.Net automatically generates, you’ll find the same kind of definitions for each UI item in the code-behinds.  Same-same.  Don’t let the EXTREMELY WEIRD BRACKET-HEAVY SYNTAX scare you.

Speaking of which, here’s a brief bit of learnin’ about the syntax.  Let’s take apart this function…

-(IBAction) openThing: (id) sender
{
// code that does stuff
}

The hyphen is there on purpose.  (Don’t ask me why.)  (IBAction) is the return type, openThing is the name of the function.  (id) is the type of the argument and sender is the argument itself.  To call a function, use brackets like this:
[myObject doSomething:5];
myObject being the object, doSomething is the function being called, and 5 is the argument.

By the way, the “id” type in Obj C corresponds to Object in our world.  It could be anything.  You’ll need to cast it to whatever type actually sent the event if you want to use it.

If you ask me, the brackets clutter up things, and dot notation isn’t supported enough in Objective C.  They added it to 2.0, but I think it could be used more than it is.  You still need to use brackets for functions if I’m not mistaken.  Of course, you can’t just change the entire syntax of a language without peeving your developer base!

On a side note, I’ve found XCode to be a sweet IDE to work in.  At first I found it a little annoying to have to switch between two completely separate programs to do coding vs. UI work, but then I realized some benefits to it.  Unlike Visual Studio, you can open up just the stuff you want to work on.  VS gets more bloated and resource-hoggy with every iteration, and it would be nice if you could completely rip out the Design mode when you’re working on ASP stuff.  You know it’s lurking in memory somewhere, ready to reformat your clean, hand-written tags the moment that you accidentally summon it.

Another advantage to having two separate programs is that it reinforces the separation of concerns between code and UI.  This premise lies at the very heart of how iPhone programming works – it uses the Model-View-Controller pattern!  I have used this pattern extensively, and although I’m not a design patterns guy, I have to say that it makes for fairly clean distinctions between the various pieces in an app.  If you haven’t used it yet and you’re an ASP.Net developer, you’re in luck.  ASP.Net has an official MVC implementation!  Grab it, build some stuff with it.  Understand it. It’ll help you see how things work in the iPhone (“Cocoa Touch”) world.

The books I’m reading on the subject are Beginning iPhone 3 Development by Dave Mark and Jeff LaMarche, and Programming in Objective C 2.0 (2nd Ed.) by Stephen G. Kochan.  I’ve found both of them to be very, very good books.  I will say that getting about halfway through the Objective C book first will make your life a lot easier.  I’m currently switching back and forth between them.

I’ll be posting more stuff as I wrap my head around this.

Shoot _with_ your family, not at them.

Posted in Airsoft on September 29, 2009 by ajh1138

I’ve been itching to teach my sons about my favorite sport – shooting – since before they were born.  (And if I had any daughters, you can be darn sure they’d be trained in the ways of firearms as well.)  They’re 8 and 10 years old now, and I’m not quite comfortable with the idea of taking them to a real shooting range to fire real guns just yet.

My dad bought me a .22 bolt-action rifle when I was 7 (a Sears-branded Savage if I remember correctly), and he took me to a small range outside of Medicine Lodge, KS to teach me which end the bullet came out of.  From what I remember, we didn’t cover sight picture, breath control, maintenance, or any other aspects of shooting besides basic bolt-action operation, how to load the 6-shot magazine, and most important of all: SAFETY.

I was naturally inclined to be cautious around, and interested in, guns.  So my dad was able to take me to the range at an early age.  My boys, however, are going to need a bit more muzzle discipline and training in range safety, etiquette and protocol before they’re ready for real shooting.

I am a huge gun safety freak.  My dad is a hunter safety instructor, and has always reinforced the proper ways of handling firearms.  I hope my boys will have that same sense of reverence about guns – so that even if they don’t take a shine to the sport they still know how to handle a gun safely and effectively if they have to.  To that end, we bought four airsoft guns a few weeks ago, one for each member of the family.

My wife and the boys got Crosman p9 pistols, which are worthy copies of the Walther P99.   They’re very accurate, which is important for instilling confidence in new shooters and teaching proper sight picture.  I told the boys that the front fight is like a mouse pointer that you put right under the target, and just make sure it’s between the rear sights.  It seems that my advice worked.  They’re becoming very good shots.  My wife is a natural dead shot, and while she doesn’t spend as much time in our makeshift range she definitely tears it up when she’s there.

The P9 comes with a really nice holster, too.  Bonus!

I got a Crosman R34, which is an eerily accurate copy of the short, collapsible-stock version of the venerable M-16 assault rifle.  I cannot say enough good things about the R34.  It’s just like the guns I carried in the Air Force when I was a Security Specialist.  I carried the standard, regular size old-school M-16A just about every day for the duration of my 4 years in the service, and when I hold that short version I find myself absently fiddling with the foregrip retaining ring or tugging on the magazine to make sure it’s seated, just like the old days.  In the Air Force this shorty M-16 is known as a GAU (also referred to as a “Commando” or XM-177).

The R34 is a single-shot, spring operated airsoft rifle that cocks uses the charging handle, just like the real thing.  The safety has 3 positions and is a tad flimsy, but for $39 USD I cannot complain, especially considering how great the rest of the gun is.  That retaining ring I mentioned actually pulls back to release the foregrips.  The spring tension and feel of the magazine ejector button is spot-on.  When you cock it, the spring makes a tonnnnngggg sound that reminds me of a real M-16 when it fires.  The foregrips have Picatinny rails, which makes for easy mounting of a variety of accessories, and it even comes with an adjustable combat-style sight that you can mount on the top rail.

OK, enough gushing about the R34.  It shoots high and to the right, and I’m still trying to fiddle with the sights.

I set up a makeshift range in our garage that puts the targets at about 5 or 6 meters.  We bought a Crosman electronic target and it provides good feedback for adjusting fire.  I don’t want to seem like a Crosman shill here…that’s pretty much all they sold at the sporting goods store we went to, and frankly I’ve always been impressed with the quality of their stuff.

I also set up some fun targets to shoot.  A small metal canister (I think it was used for developing film) provides a pleasant TING! when you shoot it.  I hung up some old, scratched up data CDs on the target stand with some duct tape.  They’re great to blast apart.  If you spraypaint them black, they also provide good feedback kinda like metal silhouette targets.

While it’s a fun hobby, the boys know that it’s not playtime.  The first day we were shooting, my 10 year old shot me in the thumb as I was adjusting the electronic target.  There’s a reason Crosman calls their guns “Stingers” – that sumbitch hurt!  After the requisite cursing (not directed *at* him, mind you), I asked him “What if we were at a real range, and that was a real gun?”  He was already mortified, and that question really got to him.  I’m glad it happened.  It was well worth getting a (large) welt on my thumb for a couple of days.

You see, I had already breifed the boys on range safety, what you’re supposed to do when somebody goes downrange, etc.  But that incident drove the point home.  It’ll stick.  I think within a couple of years, my older boy will be ready to fire on a real range and the younger boy soon after.

This new hobby has been a real treat.  The guns are cheap (well…you can actually sink a LOT of money into the mid-to-high-end models), the ammo’s cheap, I get to hang out with my kids, and I get to go shooting whenever I want!  And they’re learning safe habits and vital knowledge that will help them when they’re older.

Backup your iPhone data. Right now.

Posted in Uncategorized on September 27, 2009 by ajh1138

Fortunately I didn’t have much on my iPhone.  What I did have was completely lost today.  It started with a  failed iPhone update (3.0 to 3.1).  My phone got bricked, and I frantically scoured the net for solutions to the problem.

It seems a lot of users on both Mac and Windows get this “1604″ error when trying to perform an update on their iPhone/iPod Touch.  Honestly, I expect Apple stuff to work a lot more smoothly.  My wife and I *always* have trouble whenever there’s an OS update to our phones.  That’s why I had waited so long before finally grabbing 3.1.

I uninstalled and reinstalled iTunes about 5 times I think, as was suggested by several sites on teh intartubes, and even Apple’s support site.  Eventually, I had to boot my PC into Mac mode to get it to work.  (Yes, it’s a freakin’ Hackintosh.  I have it just for situations like this, and for testing web sites.)

I had a mistaken assumption that when iTunes synchronizes the phone will use the data on the computer instead of clobbering the computer’s data with whatever’s on the iPhone.  It turns out that you can restore your iPhone from an earlier backup just by right-clicking on it in iTunes…but you need to have data to restore from.  Over the course of several re-installs, I found out where my backup data was (on XP it’s in c:\documents and settings\yourusername\application data\apple computer\MobileSync\Backup\{big long string of characters}) and I moved my most recent data onto my desktop for safekeeping.  So when iTunes started up again, it saw that there was no recent folder in there and created a new one.  Later on I was trying to figure out how to restore my old data, and I move my folder back into the Backups folder and restared iTunes.  Then I synced data with the phone…then I cried.  Well, I didn’t actually cry, but I was kicking myself for moving the actual folder in there instead of a copy.  It got clobbered with blankness.

SO…go backup your iPhone data right now before you do any updates, etc.  Go to the path I mentioned above and make a COPY of your backup folders and put them somewhere safe (backup your backups).  Learn how to restore your iPhone data from backup.  Then, write Apple a letter telling them to make updates a little smoother.

Hauler v.005, and the Glory of callLater()

Posted in Uncategorized on August 17, 2009 by ajh1138

Here’s the latest iteration of Hauler. I worked on it all frickin’ weekend.

New Stuff

  • Overhauled combat system.  Still needs lots of work, but it’s a lot more fun than it was.
  • Models for several ships (including two that you won’t see yet!)
  • Explosions!
  • Character avatars for the pirates.  Nothing for the player to choose yet, however.
  • One-letter-at-a-time text with nifty sound.

The combat screen now has two modes – an “action” mode where you see the ships, lasers, explosions, etc. and then “dialog” mode, where it shows the pirate’s avatar a bit larger and they say stuff.  I got the ships and some temporary explosions, but no lasers yet.  I’m looking at some open-source Flash building tools to do the animations for lasers and explosions.

I used Second Life to build the ship models and character avatars.  As I’ve said before, I can’t draw, but I can bodge up models in SL pretty quick.  I just took some snapshots of the models/avatars and applied a Mosaic filter to get them all pixely.  Turned out pretty nice if I do say so myself.

Ship Models

Faux Millenium Falcon

Faux Millenium Falcon

Inspired by various Star Trek ships

Inspired by various Star Trek ships

NOO-B Class starter shuttle

NOO-B Class starter shuttle

Juggernaut - huge and bristling with guns!

Juggernaut - huge and bristling with guns!

A large, sturdy cargo ship

A large, sturdy cargo ship

The large cargo ship and Juggernaut are not yet seen in the game.  One of my next steps is to add the ability for the player to purchase new ships.  I also need to develop a system that pits you against pirate ships of similar firepower/size.

Technical Notes

I was having a dickens of a time trying to debug a sequence wherein the player loses a battle.  At the end of the fight, the pirate talks some smack, then it shows the player (eventually I hope to have a dejected-looking expression on the avatars)  and explains the consequences of their defeat.  During that change from pirate dialog to player dialog, it kept locking up.

I have a new rule when developing in Flex, and it serves me well:  Whenever you spend more than 10 minutes trying to debug a weird problem in Flex, it’s probably a creation timing issue.  Turns out that’s exactly what it was.  I was wiping out the character component’s text box before printing new dialog, and since the component wasn’t finished building itself on the screen yet it freaked out.  I solved it by wrapping the function call with a callLater( ) and bam…works great.

In case you’re wondering, callLater(function_name, [array of arguments]) is a great little function that makes Flash wait until all of the declared components have been placed on the stage, then it calls the function you put in as an argument.  It’s like telling Flash “Hey, do what you need to do to get yourself ready.  When you’re done, do this thing.”

Flex Quirks I Learned About Today

Posted in Uncategorized with tags , , , , on August 15, 2009 by ajh1138

1) Class names in Flex “css” cannot have underscores.
2) backgroundSize is percentage-based, and is based on the size of the container, not the image. Handy! Inconsistent and weird, but handy.

May you be blessed by the deity of your choosing, Mr. Dah.

Posted in Uncategorized with tags , , , , , , , on August 15, 2009 by ajh1138

Tonight was going to be the big night for Hauler. I got a lot of visual content built and photographed in Second Life, and opened up Flex builder to finish up the game. Unfortunately, I ended up spending more than two and a half hours trying to overcome this error dialog:

“Flex Builder cannot locate the required version of Flash Player. You might need to install Flash Player 9 or reinstall Flex Builder.”

I noticed that this happened after I installed IE 8 (I still had IE 6 since I never use IE at home). So I guess Flex Builder lost the path to my debug version plugin when the old version of IE went away.

I tried uninstalling/reinstalling Flash a few times, and fiddled with the paths in Window–>Preferences–>Flex–>Profiler–>Player/Browser but this is NOT the place to do that!!! The correct place to fix this problem was in Window–>Preferences–>Web Browser. I found this tip in the Flex JIRA bug tracker posted by “bahiminin dah” about a year ago. Ya sure got me out of a hole, Mr. Dah. I just checked off Internet Explorer as the browser to open, and the problem went away. (I usually leave Firefox for browsing and IE solely for debugging my Flex junk.)

Here’s a little preview of the new content I’ll be tossing into Hauler this weekend:

FauxTrek_Attacking_128FauxFalcon_Attacking_128

Hauler v.004a – Combat system and swanky logo added

Posted in Game Dev, Programming on August 5, 2009 by ajh1138

Hauler v.004a is available for immediate play.  That’s right, it’s a fully playable game now!

I’ve added the combat system, which was a lot of fun to design.  There are two pirates that can attack your ship, and you choose to fight, flee or surrender during each turn.  The player is punished/rewarded with varying severity based on their actions.  For example, if you surrender the pirate only takes 1/4 of your cash and a random cargo item.  If you attempt to flee, you could lose up to half of your credits and all of your cargo – or you could escape with no penalty.  If you fight and lose, you lose all of your cash and cargo, then your dad sends you 1000 credits to start over again.  If you win a fight, you get a good chunk of cash and your available cargo space is filled with a random trade item.

With this version you’re attacked EVERY TIME you jump to another location. This is so that people can test out the combat system.  It’s not balanced yet, so both the player and pirate tend to miss shots a lot.  I also need to have a visual display that shows the player their remaining shield strength, firepower, etc.

Hauler004_combat

The big purple square is where the pirate’s image will go.  I’d like to have the pirate’s dialog look (and sound) like the dialog from 8-bit games (a’la MegaMan, Legend of Zelda, etc.) where the text comes out one character at a time and makes a little noise.

I need to spend a day going over the visual aspects of the game and do up the buttons, etc. all 8-bit style.

The game’s settings are entirely XML-based, including the pirates’ scripted dialog during the combat parts.  I refactored the combat script/interaction method a couple of times while I was working on it, and actually wrote the XML before I started coding.  I usually try to get at least a basic data structure figured out before I build the application layer.

I have also bodged-up a swanky logo for the game.  It’s based on the classic Mudflap Girl, but with a sci-fi twist.  The chrome needs some help, but I’ve had this logo idea banging around in my head for a couple of weeks and just had to see it for realz.

HaulerLogo1

The feel I’d like to get is a gritty, long-haul trucker culture and environment.  I’m no graphic designer, but I’ll do the best I can.  For this project I’m stretching my visual talents and it’s important that I do it myself.