Posts
417
Comments
233
Trackbacks
42
October 2011 Entries
COM Interop Memory Leaks With Outlook 2007 VSTO Add-ins

Memory leaks can cause strange and unexpected behaviors in your applications.  Of course in this day of managed code we don’t see it as often as we used to and many of us are getting rusty in our skill to eliminate these problems.

Recently I ended up with a misbehaving Outlook 2007 add-in which resulted in time spent with Microsoft support.  The first thing that came out of that was a way to detect if an Outlook 2007 is experiencing memory leaks.  Below is a command line command that seems to report back which email items were involved in memory leaks if any occur.

Outlook /reportleakedrenitems

So how do you handle the problem?  Since the unmanged code in this case are COM interop object  you use Marshal.ReleaseComObject from the the System.Runtime.InteropServices namespaces.  Any place where you are explicitly creating an object out of the from the Microsoft.Office.Interop.Outlook namespace you need to explicitly release it using this method.  If all goes well this will exercise the ghost from your system.

Here are a couple of links related to the topic for further reading.

• ReleaseComObject - How it works
http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.marshal.releasecomobject.aspx

• OOM.NET: Part 1 - Introduction and Why Events Stop Firing...
http://blogs.msdn.com/mstehle/archive/2007/12/06/oom-net-part-1-introduction-why-events-stop-firing.aspx

• OOM.NET: Part 2 - Outlook Item Leaks
http://blogs.msdn.com/mstehle/archive/2007/12/07/oom-net-part-2-outlook-item-leaks.aspx

http://blogs.msdn.com/mstehle/archive/tags/OOM.NET/default.aspx

Posted On Wednesday, October 26, 2011 9:38 AM | Comments (0)
Exploring NuGet

NuGet is a topic that I have been hearing about for a while, especially from Clark Sell.  I figured it was about time to take a dive into it and see what it was all about.

The description of NuGet makes it seem like magic to add dependencies to your code projects.  Of course there is always an explanation for how the trick works.  In this case it is by using a package and a definition of how resources should be added to your project.

One of the interesting aspects of using NuGet is the UI.  The fact that you can get a list of NuGet packages allows you to find things that you may not have used before.  Add to that the fact that packages could be located on the web or on a corporate server only increases its power.

image

Packages are actually zip files which seems to be the standard these days. After spending a lot of time with OOXML I have learned that this is a handy approach.  When you install one of these packages that information is added to the packages.config file in your solution which allows you to not have to check in all of your dependencies.  A developer can pull down the required dependencies simply by going through this configuration file.

There are a variety of things that a NeGet package can do.  On top of adding assemblies they can also modify your application’s configuration file so that you don’t have to make these changes by hand.

Lastly, you can create your own packages and deploy them.  This is a great way to create consistency across your company or to help support your customers.

To get started with NuGet head to NuGet.org.  There is also an interesting video here.

del.icio.us Tags: ,
Posted On Thursday, October 20, 2011 9:29 AM | Comments (0)
October 2011 Chicago IT Architects Group Recap

It was another engaging presentation at this month’s CITAG meeting as Joe Hummel presented functional programming and its implementation using F#.  Some times it is fun to attack a mind bending problem and this was one of those times.  Leaning about functional programming caused about the same brain cramps as moving from procedural to object oriented for the first time.  Of course when you start to get it the effect is almost euphoric.  I would suggest that if you haven’t looked into functional programming that you should check out Joe’s information below.

Joe’s information
http://www.joehummel.net/downloads.html

Please be sure to join us for our next presentation and if you enjoyed this month please bring your colleagues next time.

Posted On Wednesday, October 19, 2011 8:48 AM | Comments (0)
(Technology) Holy Wars

As the song says “War! What is it good for?”.  Well, maybe not absolutely nothing, but it is definitely a distraction.  Whether we are talking about Apple vs. Microsoft, C++ vs. Java vs. .NET, Lotus Notes vs. Microsoft Exchange, Nikon vs. Canon, Cubs vs. White Sox or Bears vs. Packers our world is filled with fan boys ready to go to battle.  Just cheering for your favorite isn’t a problem.  It is when you have a driving need to put the other guy down and prove that you are behind the winner.  Let’s take a look at a few thoughts around these conflicts.

The first thing people have to remember is that every tool has its place.  Every product has its strengths and weaknesses.  One of the best examples of this is when people ask me which camera they should buy.  The first question is what they want to do with it.  The second is how much do you want to pay.  You don’t need the professional model if you are just taking snapshots. 

Discussions of the differences between products can be productive.  There are so many technologies being pushed out so fast that no one can follow them all.  Divide and conquer is the only way to get through it all.  Cooperation and spirited competition get us a lot further than put downs.

Of course I think part of the reason we do this is that we as IT people love to take jabs at each other.  It isn’t about which is better.  It is about pushing someone else’s buttons.  I have to admit this is a fun sport.

In the end I would say as long as it is friendly and not a consuming pursuit then championing our favorite technologies and hearing the reason why others stand behind their favorites can be profitable.  Just make sure you stop before the mud starts flying.

Posted On Tuesday, October 11, 2011 8:42 AM | Comments (1)
Why Windows Phone Rocks

First let me say that this is a “what I like” post and not a comparison of platforms.  The Windows Phone is the first smart phone that I have owned (no, I’m not 100 or 15 years old).  Now that I have done the full disclosure I did want to talk about the features of the Windows Phone that I really enjoy.

I have had the Samsung Focus since shortly after it came out.  I have found it extremely capable and enjoy the performance of the device.  It is light, durable and bright.  My wife has the LG Quantum that feels like a brick compared to the Focus.  But they all seem to be well functioning devices and it is nice to have a choice.

Of course hardware is nothing without the software features to go with it so here are the things I find valuable.

The first thing you may notice are the Bing features.  Vision and Music while not new ideas are fun to have built into the software loaded on the phone.  QR codes have become the new sales tools.  Being able to just point the camera and have it detect QR code, bar codes, album covers and books is great.  Music replaces Shazam and takes you straight the Zune market place.

From there I go to XBox Games.  They are not a deal breaker for me, but it is fun to sit with my son while we are waiting at a restaurant or to get our hair cuts and playing Assassin’s Creed.  Just having great games to preoccupy the kids makes waiting a lot easier.

Having Office preloaded is another win for me.  Not the least of the benefits is having OneNote where ever I go and being able to lookup notes for clients without having to start up my laptop.  Add to that opening the three main document types of the office suit just puts the cherry on top.

The bonus is that the market place is fast building all the popular apps and then some.  It is getting harder and harder to run into a situation that you can’t find an app you are looking for and it is only getting better.

The last area is development.  Personally it is the development story that really attracts me to the Windows Phone (yes, I am a strange techie).  Having spent so much of the past two decades developing with Microsoft technologies means I both have an investment there and understand the benefits of the tools. 

Microsoft may be late to the game, but I think they have combined the strengths of the other platforms and are pushing past.  I would say go check one out and see if they rock for you too.

Posted On Monday, October 10, 2011 9:57 AM | Comments (1)
Accessing Authenticated WCF Services

When you make a service available external to your corporate network sometimes SSL isn’t secure enough.  If you really want to limit the users who can access a service they need to tied to credentials.  One of the most common credentials to tie to is a Windows account.  What if you are the consumer of these services.

When you add a service reference to a Visual Studio 2010 project it does not give you a chance to set credentials.  The following example is how you can apply credentials to a service reference.

ServiceReference1.MyService servicesClient = new ServiceReference1.MyService();
servicesClient.ClientCredentials.Windows.ClientCredential = new NetworkCredential("myUserName", "myPa$$W0rd", "mydomain.com");

While this example has hard coded credentials that is simply for demonstration.  You could easily (and should) replace these parameters with configured values.  As usual we are not talking about rocket science, but hopefully this tidbit will help a few people.

Posted On Friday, October 7, 2011 1:39 AM | Comments (0)
Windows Phone Silverlight Poor Man's Double-Tap

I have seen a lot of articles about gestures but they require third party libraries or complex coding approaches.  What I am going to present here isn’t strictly elegant or necessarily the best approach, but this is the way we would catch this type of event when we were still dealing with message loops.

For the app that I have been working on I need to take action on the double-tap of a list item. The first question you have to ask your self is what a double-tap really is. It is in simplest terms it is two taps within a specified amount of time.  Given that I created a page level variable that holds a DateTime.  If you set it each time the MouseEnter event fires and check it against the previous value you can imply a double tap.  The code below is about as simple as it gets.

private void list_MouseEnter(object sender, MouseEventArgs e)
{
DateTime tempTapTime = DateTime.Now;
if(tempTapTime.Subtract(_lastTapTime).TotalMilliseconds < 250)
{
if (listEvaluations.SelectedIndex > -1)
{
// Do something
}
}
else
{
_lastTapTime = tempTapTime;
}
}

This may be kicking it old school but it gets the job done.  Evaluate it against the other options out there and see what works best for the particular situation.

Posted On Friday, October 7, 2011 12:22 AM | Comments (1)
Upgrading Windows Phone Projects To SDK 7.1

Even though this is one of the simplest tips it is one of the hardest to find someone who has documented it.  So instead of just telling you I am going to take a quick sidebar first.  I wouldn’t want you to feel you got jipped by stopping here.

One thing that happened when I finished running the Mango update on my Samsung Focus was that the apps that I was testing forced me to uninstall them.  Now it turns out that this wasn’t that the SDK needed to be upgraded, but that the device had to be reregistered.  Fortunately Mango is backwards compatible as you would expect.

Now that we have that established if you have a project that you originally developed using the Windows Phone SDK 7.0 and want to upgrade it to SDK 7.1 simply go to the project properties and update the target OS version.

image

It is just that simple.  Go ahead and deploy the changes and test them.  Then you can move onto creating proof of concepts with the latest Mango capabilities.

Posted On Tuesday, October 4, 2011 3:31 PM | Comments (2)

Tim Murphy

Tim is a Solutions Architect for PSC Group, LLC. He has been an IT consultant since 1999 specializing in Microsoft technologies. Along with running the Chicago Information Technology Architects Group and speaking on Microsoft and architecture topics he was also contributing author on "The Definitive Guide to the Microsoft Enterprise Library".



I review for the O'Reilly Blogger Review Program



Technorati Profile

www.flickr.com
Tag Cloud