I’d encountered a few anomalies with the Exchange 2010 server over the last few weeks, so took the opportunity yesterday to upgrade it to SP1 and the latest Update Rollup. This revealed an annoying feature of – or bug in – Microsoft’s code that loads Transport Agents causing my RegExCatchAll Agent to crash. I also learned something I didn’t know about Powershell.
The bug I found is that if you try to install a Transport Agent that is built with Exchange 2010 pre SP1 binaries on an Exchange 2010 SP1 server you will get an error:
The TransportAgentFactory type "RegExCatchAll.CatchAllFactory" doesn't exist. The TransportAgentFactory type must be the Microsoft .NET class type of the transport agent factory. Parameter name: TransportAgentFactory + CategoryInfo : InvalidArgument: (:) [Install-TransportAgent], ArgumentException + FullyQualifiedErrorId : 6F5E297B,Microsoft.Exchange.Management.AgentTasks.InstallTransportAgent
This error occurs because when you install the assembly Exchange Server checks for the Types associated with the Transport Agent Assembly. This means it looks for the versions of Microsoft.Exchange.Data.Common.dll and Microsoft.Exchange.Data.Transport.dll it was compiled with. Since they were pre SP1 DLLs it won’t find them on the SP1 system. This is also true if (as in my case) you had already successfully installed the Transport Agent on a non SP1 system and subsequently upgraded Exchange to SP1. Once Exchange starts as SP1 for the first time, your Transport Agent will fail to start and crash the Exchange Transport Service.
The fix, for now, is to recompile the Transport Agent using the SP1 copies of the two DLLs which you’ll find on the Exchange Server in:
C:\Program Files\Microsoft\Exchange Server\V14\Public
Once you have a fixed DLL, you’ll need to replace the running copy on your Exchange Server. This took me several attempts – and for about 20 minutes I thought there was an error with my code as I continued to get the error message above. It turned out that because I had tried to install the broken DLL once in my Powershell session, and hadn’t exited and restarted Powershell, it was in some sense “caching” the failure. In the end I issued an IISRESET from within Powershell, then tried to install the DLL again.
This time it worked perfectly and now my Transport Agent is running happily under Exchange Server 2010 SP1.