So I have been quiet lately, lots of things going on and I have no time for much of anything that isn’t critical. However, I am riled up and needed to write a couple of quick blog entries….
Ok, so on to part 1 of 2 new reasons why Exchange annoys me.
So back at the end of last year I was contacted and told that ExchMbx was failing on any machines where the Exchange Server 2003 SP2 binaries were loaded. The tool worked fine against an SP2 Server as long as the client running the tool had the pre-SP1 binaries on it. Ok this obviously meant something changed in cdoexm libraries but I was unable to figure out what. Through a series of events I ended up finding out that the IMailBoxStore::MoveMailBox method which I am absolutely REQUIRED to use since there is no other documented way to move mailboxes takes THREE (3) parameters instead of ONE (1) parameter. Imagine my surprise as I look at every piece of documentation of the method and every code example and they all show ONE (1) parameter instead of THREE (3).
I start digging into it and I find that in the support\cdo folder of the Dec 2004 Exchange 2003 SDK the file cdoexm.h had been changed. I didn’t do a comprehensive check but the specific change that I am entirely not thrilled about is the definition of MoveMailBox.
Prior to that specific SDK the definition was
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE MoveMailbox(
/* [in] */ BSTR HomeMDBURL) = 0;
The definition is now
virtual /* [helpstring][id] */ HRESULT STDMETHODCALLTYPE MoveMailbox(
/* [in] */ BSTR HomeMDBURL,
/* [defaultvalue][in] */ VARIANT_BOOL FCrossAG = FALSE,
/* [defaultvalue][in] */ long lMaxBadItemsToSkip = 0) = 0;
Now what could I be riled about here? Wow they added some new functionality!!! Well I am riled because you don’t muck with existing interface definitions of interfaces you publicly expose for others. This means don’t dork with parameters unless you are the only one using those parameters. This is obviously not the case here, lots of people use this interface.
The interesting thing is that the code that utilizes this new function got instantiated around November 2004 according to MSKB 883652, however it just started breaking my and other folks apps with SP2.
The specific error is a completely non-descript, “The parameter is incorrect”.
So, what is the fix? Use the new definition. It seems to work against Exchange Server 2000 or Exchange Server 2003.
The way this should have been handled is with a new method in a new interface called MoveMailboxEx with the additional params. Whomever did this to MoveMailBox needs to start reading the Microsoft Guidelines MS gives to everyone else to read on their website concerning interface design guidelines. They could quickly get to the point by searching on immutable.
To make things easy, here is what they say on one page:
In addition, the following rules apply to all interfaces implemented on a COM object:
They must be immutable. Once they are created and published, no part of their definition may change.
…
Interfaces Are Immutable
After it is published, the interface contract associated with a particular IID can never change.
Oh yeah, so we can all agree on the definition, this is straight from MW.
Main Entry: im·mu·ta·ble
Pronunciation: (“)i(m)-‘myü-t&-b&l
Function: adjective
Etymology: Middle English, from Latin immutabilis, from in- + mutabilis mutable
: not capable of or susceptible to change
A few final comments
1. This isn’t documented anywhere in MSDN online nor in downloadable Exchange 2003 SDK (any version). It is only in the header file, and we all know everyone is always scanning through the header files, especially for changes to existing functions…
2. Note that you don’t have to download the E2K3 SDK to use CDOEXM calls, the header file is included with the other Windows header files by default in several compilers. Funny thing, it appears that the latest C++ compiler from MS which is in Visual Studio 2005 (VC++8) had a version of CDOEXM.H included with a time stamp of April 2005, 4 months after the release of the Dec 2004 SDK and it didn’t have the right definition. So just looking at the file date isn’t even enough to know if you have the right one.
3. Why in the world is the cdoexm.h file in E2K3 SDK in the support\cdo folder instead of the include folder?
Altering published COM interfaces is a _BIG_ no-no. As you point out, it breaks all kinds of running applications.
Have you reported this as a bug?
Hey Alun, yes, I sent this in through two separate channels including Ladybug. Honestly though, I don’t expect to see anything on it as I have reported several Exchange bugs in the last 12 months that have simply been responded to as won’t fix, move to E12 when it is available.
I am experiencing the problem described here, but I dont see a clear solution to fixing this problem on my system. Would you provide explicit information how I might corret this issue?
Are you using ExchMbx? If so, use it from a non-SP2 updated system until I get a chance to test the modifications and release a new version of ExchMbx. When I have released the new version, I expect April, then I will announce it on the blog.