Ashley
Blog - Robert Bogue [MVP]
Rob's Notebook
SharePoint Calendar

Categories

Links

Archives

Other Blogs

Thor Projects LLC - Welcome : Blog - Robert Bogue [MVP]
Thursday, July 30, 2009

How My Opinion of HP Has Seriously Changed

For this to make sense you'll have to realize that I started building a video studio in mid-December of 2008 -- over six months ago. Since that time I've covered a lot of logistical challenges in an attempt to get the first video offering, The SharePoint Shepherd's Video Academy for Planning and Governance together. Since I've started I've dealt with issues in getting a good quality product by working through issues with Sony Vegas and how you can import text from PowerPoint. I've even gone over the top to have a teleprompter custom built to allow me to read from directly in front of the camera so my eyes don't shift.

One of the problems that I never expected was to have problems with the desktop PCs that I am using to repack and process the video. I started trying to do the video processing on my Lenovo T61p ThinkPad. Although it's a great notebook the idea that you would process video on it is a bit ill advised (which is why I think I tried it.) So I found a deal at eCost.com on a refurbished HP Pavilion m9350f machine. It is a quad core machine with 6GB of RAM running Vista x64. The deal was around $660 delivered. Certainly the machine wasn't the latest and greatest, fastest machine on the planet but for the price , there's just no way to beat the deal. And for my purposes I rationalized that I could buy a second one and get better than the performance of the best desktop systems today for less cost than buying one "monster" system today.

Things went well for about the first month. I had managed to get Vista upgraded from Home Premium (which the system shipped with) to Vista Ultimate. (Here's a hint, uninstall the XPS viewer before trying to do the upgrade.) I had installed all of the software I needed from Office 2007, Adobe CS4 Standard, Sony Vegas, etc. I had started processing the video on it and then one morning in early February the performance of the system copying from the camera dropped from 20MB/second to 2MB/second. Houston we've got a problem.

I won't bore you with the details of the four hours of troubleshooting I went through via chat to get the problem resolved. I can say that when diagnostics pass and yet things aren't right -- well, it's hard to explain that. I got to the end and was told that it would take 7-8 business days to repair the system from the day that I shipped it out -- and that they had to ship me a box so I could ship the computer to their repair facility.

Ouch. That means I'd effectively be without the computer for two weeks. However, it gets worse than that. When they went to check the warranty status (on a computer I had owned for about 30 days) they told me the warranty was expired. It was an issue with the machine because it was refurbished. I was told that I needed to send an email to the proof of purchase team with my invoice and within 4-6 hours I'd have to call back in to process the warranty repair.

I called in 6 hours later (by navigating through a byzantine automated operator) and was told that no proof of purchase didn't take 4-6 hours, it took 24-72 hours but they would call me each day to check in with me on the status. (Hey, there's a novel customer service concept, don't make your users keep checking with you for status.) I agreed and subsequently received calls the first two days. The first day I got the call and was busy so I quickly dismissed the call figuring that it didn't matter that much. Why?

Because at this point I had ordered a second computer from eCost. Two weeks was too long for a project I was trying to have done in two weeks. (Which is somewhat laughable now because several months later I still don't have the project done and I don't even have a good feel for the timeline.)

On day two of their call backs, I missed the call. OK, I was ready to charge a windmill. It was 2.5 days and I still couldn't get them to ship me a box so I could ship the computer to them. I called back in and told them I was done, that we needed to solve the problem now. I was of course told that they couldn't do that. I was told that they couldn't transfer me to the proof of purchase team. At this point I'm thinking, "Hey the economy is bad but surely you can afford phones for these people."

I explained that I felt like they weren't honoring their warranty. I even went and filled out a Federal Trade Commission consumer complaint and told them I was about to hit submit. (You can understand how much time I'm spending talking to folks by the fact I was able to fill out a government form while speaking with them.) I ended up hitting submit and asking for a manager when I was told for like the 12th time that they couldn't help me.

The manager proceeded to tell me the same thing -- that they couldn't get me to the proof of purchase team and that he couldn't help me. Before disconnecting he asked if I was "satisfied" -- which is laughable since he was saying that he couldn't help me -- How could I have possibly been satisfied?

At this point, I cheated. I went to the HP web site and got to the press relations person and sent her an email explaining that I was preparing to write a blog post titled "HP Doesn't Honor It's Warranties" and asked if she had a comment.

I got three responses the next day. One from the proof of purchase team -- who apparently was confused because no one had ever tried to send them a PDF of their invoice before they expected it on the fax machine. I got a call from HP's PR firm to tell me that normally HP does a great job at service but they're always trying to learn and improve. (Really, that's surprising from a PR firm.) Finally, I got a call from a guy who offered to "do what it takes" to get the warranty repair setup.

A few days later I got the box, shipped out the first unit, and was happily setting up the second computer that I had purchased. That was until it started having random lockup issues. Back to technical support only to be told that upgrading to Vista Ultimate wasn't supported (the box remember shipped with Home Premium.) I was told the drivers wouldn't be installed right -- I explained it was an in place upgrade. After many hours of chatting I finally was able to determine that there was no way to do a burn-in test with the diagnostics they provided. I could run things through once and they figured if that passed then the system must be good. (Wrong.)

With some help from some of my buddies at Internet.com I found Sandra diagnostics. Although this wouldn't run from a Linux boot (like I had hoped) it does do burn in tests. So I restored the system to factory condition and installed Sandra. Of course, a short time after starting the test the system locked up.

Another call to Jeff from HP (the guy who said he'd "do what it takes") and I ended up sending this computer off. I'll spare you some of the communications gaffs that took days to resolve.

So now, I'm in this project and I've got two computers both of which are at HP at the same time for repair. This was mid-February. My goal was the first of March for the MVP summit in Redmond.

Eventually the machines returned and I was back in town. I started working on the first machine and didn't really notice any issues. (Aside from upgrading Vista again.) The second machine arrived and it had the same random lockup issues that it had when it left. As a point of fact it wouldn't even complete the out-of-box setup. That prompted me to look at the first machine more closely and when I did I realized that they had mis-partitioned the hard drive so that I didn't have access to 120GB of storage. I asked for a new hard drive for it and for another box for the second machine.

Instead of a hard drive for the first machine I got a box to send it back. Not what I wanted but whatever. The second system's box to ship it back came as well. I sent them both off. The second machine had a very large note about running burn in diagnostics. It wasn't bordering on obnoxious at this point I was all over being obnoxious to get what I needed.

Both machines have arrived again. The first system was finally correct. The second system has the same random lockup issues. I've been promised a replacement system but I've not seen it yet and Jeff, the escalation engineer, who had once committed to making things right has not yet figured out how to get the replacement processed. He's been late on all of his commitments except for the first one. To the point where I've recopied the PR firm more than once about responsiveness issues.

So, he's my perspective on what went wrong in the process and what HP needs to do to resolve what I see as some major customer service problems:

  1. Allow customers to exit out of the automated operator to a real live human being capable of rational thought. Ultimately this issue caused me to go to the press relations person to get help -- I can do that but not everyone can.
  2. Hold reps accountable for solving customer problems.
  3. Wishful thinking does not create happy consumers. Working on the process issues does. When you have multiple systems that don't get fixed after multiple times of being to a repair center -- you have a problem.

Interestingly the end of the story has a happy ending. Even though the first machine ended up having the same hard drive performance issues. Even thought it took me over a month. HP eventually bought both systems back and I built my own system from parts. The machine I built has a few quirks (mostly related to energy management -- which given the machine is only powered up to do heavy lifting with video, I don't care about.) The machine was much more expensive but also much more powerful.

Where am I with HP? Well, on the one hand I struggle with the quality problems that plagued the hardware I had. I'm disturbed that the repair process was completely ineffective. I'm shocked that even the escalated status of my case still meant weeks and weeks of waiting. (It was 14 calendar days of waiting since the second repair was ineffective when we finally processed the buy-back instead of looking for replacement systems.) On the other hand, with a few months of reflection (and sitting on this blog post) I am troubled that there's an organization that is trying to do the right thing but is so caught up in the market and what the market is trying to do to step outside and see the really bad service that they're giving their customers and the impact that it will have on their long term viability. (Just ask Packard Bell, Gateway, Acer, etc.) I want them to be successful -- on the server side of the business they make good stuff. Hopefully they'll figure out the issues with their desktop PC business and grow.


Categories: Professional | 4 Comments
 
Thursday, July 30, 2009

Corrupt WAV Files, Media Player Library, and Programming

A few weeks back I was doing a recording for a buddy of mine and unplugged my Edirol R-09HR sound recorder... and for whatever reason it powered off immediately. Yes there were batteries in it but it decided that it just wanted shut of immediately. The problem is that it was still recording a file. Making things a tad bit more annoying, it corrupted the WAV file it was writing. None of the tools that I had wanted to read the wave file because the sizes that are supposed to be written into the header never got written.

I ended up doing some research on the WAV file format and wrote a utility that sets the two lengths that are required in the header based on the file length. If anyone else needs this send me an email and I'll send you a copy (to use at your own risk.) The utility does at least verify that the file is a WAV file -- but it could still be pretty destructive. It would be really nice if the audio editing software would just allow you to fix this on the fly when you open it since it has to be a fairly common problem when the recording is interrupted. Of course, the tools don't do that. The fix that I'm doing in this program is painfully simple. I'm comparing the length of the file and using that to write out the header values. Every one of the tools that I tried to use, including my preferred audio editor Sound Forge, refused to fix the file. There were tons of tools that claimed to fix WAV files but the "obvious fix" for the header wasn't one of the supported fixes.

For me this was an annoyance. It was something that took me a few hours to fix. (I had to remember my binary file reading skills and find an accurate format for the WAV file.) However, it occurred to me that someone who wasn't a developer -- and a developer with a background in reading binary files -- would have been completely stuck. Something that is relatively easy would be a seemingly insurmountable challenge. The good news is that the invention of the Internet is making it easier to address these issues (with a bit of luck someone with a corrupt WAV file will be able to email me and I can send them the fix tool.)

In a strikingly similar situation I wrote a tool a few weeks ago for a good friend of mine. He had been using Windows Media Player to index his music files. He plays the part of a DJ occasionally and needed a print out that he could hand party goers in an attempt to help them pick a song that he had. Strangely, Media Player doesn't have a way to print out a list of the songs that it has in its index. This was painful enough for him that he was willing to pay my hourly rate to build him a tool to get the data out -- and he knows what my hourly rate is. So I needed a distraction from some of the other stuff I was doing so I picked up the Windows Media Player 9 Series SDK. 45 minutes later I had a working tool that would create a CSV file from all of the data in the Windows Media Player Library. To be clear, it's not what I would call commercial grade software. It requires that you run as an administrator. It doesn't filter out the library for you -- the library contains stuff other than music like photos. It also dumps literally every field of data in the library -- including a lot of duplicate data. However, 45 minutes of work removed the essential barrier that he was having to being able to have a listing to take to his gigs. (If you want this tool email me and I'll get it to you -- the same thing applies here. Use at your own risk and there is no support.)

My point is to say that a few hours of development can make the insurmountable seem possible. There are things that just simply can't be done without writing a little bit of code -- and neither of these utilities would be considered good from a software development perspective. They're hacks. They're not elegant -- however, they get the job done. Sometimes developers get caught up in creating the big solutions -- the massive architectures -- and we forget that any solution is sufficient. I'm going to be thinking about that "less is more" thing for a while...


Categories: Professional | 0 Comments
 
Wednesday, July 29, 2009

Book Review: Outliers

I've read Malcom Gladwell's other two works: The Tipping Point and Blink. I figured that Outliers would be interesting and entertaining. Why not? The other two books were. What I didn't expect was that it would change the way I see myself and the world around me. In retrospect that's what Blink did. It changed my perception of perception – of how we make decisions and how the lines aren't as clean as we would like them to be. Outliers was different though because the book was talking about me. It was talking about me as someone who doesn't fit the norm who doesn't fall into the normal categories. Through my history I've been called odd, abnormal, and several other things… so I can identify with the idea of being an outlier.

The two main sections of the book are: the opportunity and the legacy. I translate the legacy into hard work. Not hard work in terms of difficulty but meaningful work over long periods of time. I won't rehash the book' main points, but I do want to explain it from my perspective. I should say that I don't believe that I have done – or will do – extraordinary things. My world is comfortable. I'm blessed by the opportunity to work with good people. That being said – I've never followed the easy path.

So if we start first with opportunity. I can remember having powdered milk on cereal. (I don't recommend this.) I can remember drinking out of plastic butter "cups." There are dozens of other memories that can remind me that growing up we didn't have an abundance of money. However, my mother by the time I was in the fifth grade managed a Commodore 64 computer. I, of course, wanted to play games. Her response was that I could play anything I wrote. Of course, that broke down at some point but the message was clear enough.

In High School, her work had a computer for her at home. I used it to learn programming again. (It was C and assembly back then.) I had the opportunity to use the modem to connect to BBSs. The high school had a program with the local community college that allowed high school students to attend classes at the community college. This was advantageous for two reasons. First, it allowed you to get high school credits which in turn meant you didn't need to take many classes at high school. Second, you could start getting a college education while in high school.

So opportunity is about the opportunity for hard work. During my tenure at high school I had one semester where I was carrying 10 credit hours at the community college and going to high school all day. I can remember taking my college homework into my high school speaking class and working on it while the other students were at the front of the room doing their turn. I also had a stretch where I was working 40 hours a week on top of high school.

I should point out at this point that this was completely against child labor laws – but we manipulated the system so that it appeared I had only worked 20 hours and that my rate was doubled. I suspect that the co-op program coordinator knew but I'm also sure that since the work was actually as a consultant/developer for a local computer company everyone looked the other way. However, I kept my grades up. I didn't give the teachers any problems. I got along well with my counselors and the principal. So no one had any reason to expose what was going on.

I should also say that during this time the high school had an "open attendance policy." This means that you weren't considered for disciplinary action for not attending classes as long as your grades were acceptable. At one point I racked up 157 unexcused absences in a single semester. That doesn't count the few that were excused and a handful more which were "school related" which means that the principal asked me to talk to another kid, or we there was some other reason I wasn't in my normal class. This is a tad confusing until you realize there were 7 classes a day so an absence is only an absence from a single period. I only missed 22 days worth of classes. However, that's not really correct either. In truth I missed most of my economics class after the teacher – I want to say his last name was Ryan – had a heart attack. I'd find out if there was a test – if there wasn't I'd get the homework and not show up. The principal asked me about this once and I explained that the class wasn't useful. She told me that the substitute was following the same lesson plan. I told her that the substitute was probably teaching the same breadth of material – just not to the same depth.

So high school was busy for me. I was sleeping about 4 hours a night – maybe 5 – back then. I had an alarm that, it was said, could wake the dead. I was on the 3rd floor of the house in the old maid's quarters and my parents would have to yell up at me to wake up because my alarm had been going off for 15 minutes. I was living in Bay City Michigan at the time which had one of the lowest property values in the nation – so the idea were living in a house that used to have maids quarters isn't as impressive as it sounds.

I left high school half a year early and came back to Indiana to work. A part of that deal was supposed to be that I'd go to college – although that didn't happen. I got a job working on a VAX writing C. I stayed with family in Terre Haute, IN and then Greenwood, IN for a few months before getting an apartment in Carmel, IN where I was working – and where I live today. If you fast forward a bit I changed jobs and met a marketing manager at the company who introduced me to her husband who was a product development specialist at New Riders Publishing. He asked me if I was interested in doing some tech editing of books. Tech Editing he explained meant fact checking. It was following the steps to make sure things were right. It was trying things out.

Over the next SEVERAL years I was doing a lot of tech editing, some writing and some development editing. (A summary of my book work is on my site.) I estimated that at one point I was editing 16,000 pages per year – in addition to my full time job. It was busy but perhaps not as busy as during high school. I learned a ton of what I know about computers through the process of reading, trying, and verifying those books over the years.

Jumping forward again, my schedule today is – for the most part – getting up at 5:30. In my office by 6AM and leaving my office between 6PM and 6:30 PM for dinner and time with the family. I come back out for an hour after my son is in bed – to give my wife some quiet time to herself before we spend time together. My neighbor asked what time I got into my office because he would go out and get his newspaper and the lights in my office would already be on. When I told him he thought that it was pretty early. My wife has asked why I get up so early (particularly during the brief respites where I don't feel overwhelmed.) The honest answer is that I enjoy what I do – and I even more importantly love the time of a morning when I can do things like this blog post – I can contemplate things and work on projects uninterrupted.

Back to the book… The book talks about how Bill Gates had opportunity – and hard work. The Beatles had opportunity – and hard work. There are less popular examples but the pattern remains the same opportunity + hardwork => Success. Of course, you'll need to define for yourself what hard work is. The number recommended in the text is 10,000 hours of "practice." I don't know that I got 10,000 hours of practice in working on the tech editing of books – but I know I'm grateful for the opportunity.

If you're trying to figure out how success was made in other people. If you're trying to understand your own success – Outliers is a new perspective.


Categories: Professional, Book Review | 0 Comments
 
Tuesday, July 28, 2009

Book Review: SharePoint 2007 Development Recipes

Some folks like to cook from recipes. You get a predictable result and you know what to expect. My wife will attest that that's not exactly the kind of guy I am. I've created meals that are good and a fair number of them that weren't fit for the dog to eat – literally the dog wouldn't eat them. Still, I recognize the value of recipes. That's why I think SharePoint 2007 Development Recipes: A Problem-Solution Approach is a good read if you're trying to wrap your hands around SharePoint.

One of the problems with typical computer books is that they'll tell how WHY something works but not HOW to make it work or WHEN to use it. (My own personal rebellion to this is The SharePoint Shepherd's Guide for End Users which is all about HOW to do things.) That's why I like the style which shows you how to do practical things. You can read the details of some interface on MSDN, you don't need a book for that. What you need a book for is HOW you should use it.


Categories: Professional, Book Review | 0 Comments
 
Monday, July 27, 2009

Article: Performance Improvement - Caching

"If you're looking at performance and you want to get some quick wins, the obvious place to start is caching. Caching as a concept is focused exclusively around improving performance. It's been used in disk controllers, processors, and other hardware devices since nearly the beginning of computing. Various software methods have been devised to do caching as well. Fundamentally caching has one limitation — managing updates — and several decisions. In this article, we'll explore the basic options for caching and their impact on performance."

Read More at http://www.developer.com/design/article.php/3831821


Categories: Professional, Articles | 0 Comments
 
Saturday, July 25, 2009

Article: How to Leverage the Gravity of Your Intranet

"Most of us have learned about the concept of gravity through our schooling in Newtonian physics. Although, most of us remember it as Sir Isaac Newton getting hit on the head by an apple. We know that objects draw other objects in. Despite the fact that we've learned this we're confronted with our daily observation where we see that two objects sitting on a desk don't appear to be zooming towards each other through this attraction.

This explains our challenge with understanding gravity as it applies to our Intranets. The concept is one that makes sense -- but it's difficult to see and get a tangible feel for. However, despite its elusive nature gravity does have a profound impact on our lives -- and it can have a profound effect on your Intranet.

In this article we'll talk about how gravity works on the scale of planets and galaxies so that we can see how we can make our intranets larger."

Read the rest at http://www.intranetjournal.com/articles/200907/ij_07_24_09a.html


Categories: Articles, Professional | 0 Comments
 
Monday, July 20, 2009

Article: Performance Improvement – Session State

"In the first part of this series a discussion was presented on what performance is, and some of the techniques that can be used to improve or monitor performance in your application. In this article the focus is specifically on managing session state and the things that you can do to maintain performance in your application.

There are two key areas to understand in session state management. First, you need to understand the options you have for maintaining session state. Second, you have to consider the different kinds of information that need to be managed in session state and how the different needs for maintaining session state impact how you might choose to manage it."

Read the rest at http://www.developer.com/design/article.php/3829586


Categories: Professional, Articles | 0 Comments
 
Monday, July 20, 2009

What does an OutOfMemoryException in .NET (on 32 bit) really mean?

I can remember writing code in C on PCs years ago and when I got an out of memory exception I just blindly accepted that it meant there was literally no more memory for me to use. I realize now that this wasn't the case – really. It really meant "hey, I don't have that much memory left that's all together." Looking back allocating and deallocating memory had made the memory in the computer look like swiss cheese where I was using some memory locations and not other locations. At some point when I asked for a bit of memory that was larger than one of the holes I had the whole thing came crashing down.

Today in an era where we have virtual memory operating systems where quite literally our hard disk appears to be memory it would seem that this wouldn't be a problem. Sure we would waste some amount of memory with gaps where we've deallocated objects but surely if we've got a hard disk to fill we won't run out of memory – right? Well, yes, but we run into another problem. Whether you have 512 MB of memory of 8 GB when you're running a 32 bit operating system no one process is going to get more than 2GB of RAM. (I'm purposefully ignoring PAE/AWE since it's a whole different ball game that doesn't apply to .NET developers.) How does that work? Well, the addressing of memory is still 32 bits. 32 bits gets you access to 4GB of RAM. The operating system lops off the top 2GB for its own use (Basically if the topmost bit of the 32 bits is a one the address belongs to the system) so any given process can have access to 2GB of its own memory. (There's a switch to change where this split occurs so that the process gets 3GB and the operating system gets 1GB but it's not supported for every situation.) So even if we have several TB of storage any one 32 bit process can only see 2GB of RAM.

How does this all impact .NET getting an OutOfMemoryException? Well, the first problem that I used to have with C programs .NET tries to help solve. The garbage collector (GC) in addition to getting rid of objects that are no longer in memory will pull objects together that are in memory but spaced out. The easiest way to think of this (for me) is to think of any presentation that you've been in. When the room fills up it fills up relatively randomly but there are generally spaces between people. (Memory actually fills up mostly sequentially but the spaces remain.) When the room starts to get full you'll eventually get the presenter ask everyone to squeeze together to eliminate all of the spaces. This is what the garbage collector is doing; it's squeezing together the objects. (For those of you wondering how, double dereferencing of pointers is the key here.)

However, just like in a presentation there are occasionally stubborn people who refuse to move. In the garbage collector's case it's that there are a set of objects that are pinned in memory – they can't be moved. Why would that be? Well, generally it's because something outside of .NET is holding a reference to that location. It knows that some memory buffer, resource handle, or something exists in that location. Since the garbage collector can't tell something outside of .NET that the object has moved it stays in its spot. The net effect is that you get a little bit of space under those objects which remains unallocated.

If .NET's GC is cleaning up memory for us shouldn't we always stay underneath the 2GB memory limit of a 32 bit process? Well, maybe yes and maybe no. There are lots of other issues with the garbage collector and how good (or poorly) that it works that I won't go into. For our discussion we need to know that the garbage collector is getting rid of objects and pushing objects together. We also need to know that this isn't an instantaneous process. For objects without a finalizer (also known as a destructor) as soon as there are no more references to the object it can be discarded by the garbage collector. However, if the objects have a finalizer the finalizer has to be run. There's a single thread per process that runs finalization. Thus even if an object is ready to be finalized and thus give up its memory, it may not be able to quick enough as Tess Ferrandez explains. The problem is that until the objects are finalized they can't be removed and if they can't be removed memory usage will keep creeping up. By the way, the use of the IDisposable interface and a call to GC.SuppressFinalize() in the Dispose() method can prevent the need for the finalizer to run on your objects (even if one is defined) and therefore allow the GC to free your object out of memory sooner. (Unfortunately, I've been in situations where even this wasn't enough because the GC itself wasn't running fast enough – but that was in .NET 1.1 – the algorithms are much better now.)

It's also important to know that the .NET object heaps aren't the only thing consuming memory in the process. There are still a ton of COM objects that get used by .NET for the actual work. These COM objects allocate their own memory on their own heaps outside of .NET's visibility and control. These objects take up memory. They don't always take up memory that you're going to see in task manager. Task manager shows, by default, private working set. That is the bytes that the process is actively working on (please excuse my gross oversimplification of this.) The real number to watch is the virtual bytes – which you have to access from performance monitor's process object. This counter tells you how much memory has been allocated from the system by the process. In other words, how many addresses have been used up by the process. When this number reaches 2GB and there's another request for memory in .NET that it can't fit into an existing allocation from the operating system – you get an OutOfMemoryException in .NET. (If you want to know much more about memory allocation in Windows I recommend the book Microsoft Windows Internals. I've never had a memory question it hasn't been able to answer.)

As a sidebar, the working set for the W3WP (IIS Worker process) tends to get between 800-900MB before it gives an out of memory exception. I've seen processes (with very good memory allocation) drive the W3WP to over 1.3GB before it finally gave up and gave an out of memory exception. Based on what you've seen above what does this mean? It means that working set for the IIS worker process represents roughly half of the virtual bytes that are allocated.

You may have 8GB of physical RAM available and 1TB of disk space. You may actually have tons of space in memory that's become fragmented because of references to COM objects and other non-.NET code who's memory allocation can't be moved. However, if you reach 2GB of allocations (without the /3GB switch to allow the process 3GB of address space) and ask for one more thing – it is game over.

So what do you do if you have this situation happen to you? There are a few things I'd recommend:

  1. If you're using an object that implements IDisposable and you're not calling the .Dispose() method – do it.
  2. If you're using a disposable object and not doing the dispose via a using () { } or a try { } catch {} finally {} block – do it. If you get an exception inside of a method that doesn't use one of these two techniques the .Dispose() method won't get called – if you do have an exception in either of these cases the .Dispose() will still get called.
  3. If you open any kind of a resource make sure you close it. Whether it's a TCP/IP port, a SQL connection, or anything else, they're going to get pinned in memory and need a finalizer … try to take care of that yourself.
  4. Get a dump of your process and look at what objects are in memory. You can do this without a ton of knowledge about debuggers. (Production Debugging for .NET Framework Applications will get you at least this far.)

Categories: Professional | 0 Comments
 
Thursday, July 16, 2009

Custom XML Serialization of a .NET class

I love serialization -- right up to the point where it breaks. I have always found that it's difficult to get right if the out of the box stuff breaks. However, I may have changed my mind. I had to do some of my own serialization because some of the properties that I was working with in my class didn't serialize well. After a long and drawn out look at the problem here's my input:

  1. Implement the IXmlSerializable interface. It contains three methods
  2. GetSchema() has been obsoleted. Just return null. There's a suggestion that you should use an [XmlSchemaProvider] attribute on your class to communicate the method to be used to return the schema for your Xml serialization. My recommendation is to skip it -- if you don't have to validate your Xml (and I don't know why you would) you don't have to have this.
  3. WriteXml() writes the data to an XmlWriter. Use WriteAttributeString(string, string) to write out the attributes you need. You can also write out sub-elements but using attributes is easy enough for non-complex types.
  4. If you need to write out a blob of data in middle of your tag you can use WriteCData() to write the contents of a string to the center of your element tag.
  5. ReadXml() reads the serialized data from an XmlReader. Getting your content out is as simple as doing .MoveToContent() and a set of indexer deferences for attributes (i.e. reader["myAttributeName"]). Finally if you want to read the inner contents you put into a CData section you can do .ReadString().

 

That's all there is to writing your custom Xml Serialization interface. This way you don't have to worry about the dynamic assemblies.


Categories: Professional | 0 Comments
 
Thursday, July 16, 2009

System.Web.UI.Page.IsPostBack and Is This the First Request

Every once in a while I'm surprised by what I don't know. I have been developing in ASP.NET for a while and I've known about Page.IsPostBack to determine whether this is the first request to the page (thus I need to populate controls). However, I had never realized that there was a scenario where this didn't work. It doesn't work when you have another page post to your page. The property sees that it's a POST HTTP request and says "Hey, it's a postback!" -- of course in the scenario when it's another page that's doing the posting this doesn't work so well. So I put together a simple function to use the referrer to figure that out.

public static bool IsFirstRequestToPage()

{

HttpRequest curReq = HttpContext.Current.Request;

 

string referer = curReq.Headers["Referer"];

if (string.IsNullOrEmpty(referer)) // not present - should be present on postback

{

return (true);

}

else

{

// Is referrer current page?

Uri curPage = curReq.Url;

Uri refPage = new Uri(referer);

 

if (Uri.Compare(curPage, refPage,

UriComponents.SchemeAndServer |

UriComponents.Path,

UriFormat.UriEscaped,

StringComparison.InvariantCultureIgnoreCase) == 0)

{

// Same referrer (i.e. postback)

return false;

}

else

{

// Different referer

return true;

}

}

}

Of course, using the referer header is bad because there are scenarios where it won't be transmitted and some browsers that won't transmit it, etc., but in my case it works well enough.


Categories: Professional | 6 Comments
 
 Next >>