NO

Sign in to follow this  
  • entries
    145
  • comments
    222
  • views
    138267

Inherited Forms. .NET 1.1 and Microsoft Office

Sign in to follow this  
Tape_Worm

16 views

For those of you that don't know (i.e. everyone): I write database crap for a living. Our company is great, very flexible hours, laid back atmosphere, good pay and beer in the fridge at all times. So what's the down side? Microsoft Access. I seriously hate that thing. I'd like to find the person who came up with the idea of Access and beat the ever living fuck out of them. I'd seriously like to show them the true meaning of suffering (as if Access isn't punishment enough, I think it should be a human rights violation). So what does this have to do with my company? Everything. We write.. *sigh* I'm so ashamed... Access applications. And you wouldn't believe the money people are willing to throw at Access development, it boggles the mind. However it does keep a roof over my head, well, in my case, 60% of the time it keeps the roof over my head as I get to write the fun shit at the office that no one else can write (that's great for the ego).

So, for the last 6 months I've been working on porting our VBA library code (we have a LOT of library code) for our applications into .NET 1.1. I tell you, compared to Access, .NET + VS2003 is a wet dream come true. Why am I using 1.1 when the glorious and magnificent .NET 2.0 has been out for a while and .NET 3.0 is around the corner? Well, as much as I like to think I have some degree of control over what I do at work, ultimately our clients call the shots. .NET 1.1 is proven and been around for a while, 2.0, not so much (while I'm sure it's 100% better and blah blah blah, whatever). Thus they limited us to 1.1. No big deal, it's still like landing in a pile of pillows (.NET) after going through a wheat trasher (Access).

So what's the problem? .NET 1.1 is not without its ... peculiarities (sp?) And it's not really .NET so much as it's the IDE and/or VB.NET (yet another design choice I got thrust upon me). For example, have you ever tried to use inherited forms/controls? Sure you haven't. You'll quickly find that things don't work so well in designer land. Namely forms stop being forms sometimes and just appear as code modules (easy to fix, but fucking annoying). Then there's the odd behaviour of it to just start including code from the parent modules in the child modules. That's always a fucking blast let me tell you:

Picture this, Sicily, 1892... I write this great base form, a true work of art. I inherit said base form. Base form has a button 'commandSave'. Button is protected friend. Child form has complete access to button should I need it. I compile. Things stop working. I check the designer code in the form, "what the fuck?" I say, loudly. There at the top: 'private commandSave as C1.Win.Command' Ok, that won't compile, duplicates are bad. I remove it. I recompile, same error, I check the module, same fucking thing!!! So, just to get it to stop, I switched its access level to private. Voila, it compiles. Go me. I run, I click, nothing. Again "What the fuck!?" The button isn't working, it has events assigned to it, etc... how is this possible? After about an hour of looking around trying to solve the issue I finally look in the designer code. There it is: 'commandSave = new C1.Win.Command'. Well la-de-fucking-da. It was destroying the previous instance in the base class with the an instance in the child class. Apparently, not only did it add the declaration, it also added initialization code, isn't that thoughtful? I wiped it out, and all was good.

So I finally have a fairly good handle on getting around the quirks of the IDE and VB.NET. Today however was a show stopper. I spent all afternoon on this one. I add some new stuff to my base code, it's magical and works properly. So I decide it's time to add a child form based on the new base forms. I right click, I select Add Inherited Form... I name it, I select the proper base class and .... "Cannot add reference to . Please check that the reference is the correct version or isn't already added." What the shit? I try it again, same thing, I try many different things, nothing. So I build the inherited form by hand (one line of code, so it's not a big deal), and voila. It works. So I think, "that's just odd." And as further punishment I decided to try and add a test form via the IDE again. And the fucker blew up. *Sigh* After hours of searching, reading, poking, proding, etc... I realized it was this:

All of our applications (including our Access shitboxes) have the ability to export data to an excel spreadsheet. Easy to do, interop is pretty good between office apps and even .NET apps if you're careful. This Excel stuff is working fine in my .NET app, however... When I removed the reference to the Excel interop assemblies I was able to add a new child form from the IDE, I add the reference again, it blows up when I try to add the form. What to do? I poked around online and found a forum that yielded an answer, and it didn't work. Why? Because the answer was to set the reference property "Copy Local" to false. By default, since they're in the GAC, it's set to false anyway. So I thought, fuck it, and set it to True. Lo and fucking behold. It works. I can add forms again. What a shit show. Even when I'm working happily in .NET, Office rears its ugly fucking head and bites me on the ass.

I did run into an error that appears intermittently and causes the IDE to crash. And I don't know why it's there, or how to fix it. The error says something along the lines of "Cannot call method '' of $Icon. Object has been disposed." Apparently it's a quirk with the IDE and VB.NET specifically. If anyone knows how to fix this I'll give them a cookie filled with drugs.

But you know, despite these flaws, I'll gladly use .NET over Access (or VBA in general) any day. Especially since I lost a days worth of work last month because access didn't save the modules (I saved them explicitly, I always do) and didn't inform me that something had gone wrong. Imagine my surprise when I was looking at the modules and not finding the last changes I had made. This isn't the first time Access has failed to save anything, and this is a known bug. At least when .NET fails it does so in such a spectacular fashion you sit there mesmerized by it and you know if you haven't saved your changes, that it's your own damn fault. Or that when you hit save, it actually saves the files. Instead of fucking up and not saying anything about it.

Anyway, my rage is ten fold now after writing this. I'm going to go stab someone (Access guy, I'm coming for you).
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now