"No MTS context" error when trying to connect to MQ Queue Manager

Posted on 2008-11-13
Medium Priority
Last Modified: 2013-11-15
I have a C# GUI application and am attempting to connect to an MQ channel using the IBM MQ API (that I have installed on my system).  I have a reference to the amqmdnet.dll DLL in the "C:\Program Files\IBM\WebSphere MQ\bin" folder.

I try to instantiate an MQQueueManager object using the following code:

   IBM.MQ.MQQueueManager qm = new IBM.MQ.MQQueueManager(qmName, channel, connName);

The prototype for the MQQueueManager overloaded constructor used above is:

   public MQQueueManager(string queueManagerName, string Channel, string ConnName);

However, upon executing this line of code, an exception is thrown saying "There is no MTS context available".  I've attached a screenshot.  I've Googled what I've found seems to be the error code for this (0x8004E004), and also a variation on the message ("no MTS object context"), but to no avail.

What's stranger is that I have fetched an earlier version of the code for my project and it works absolutely fine on the same machine.  I've done a diff, but there doesn't appear to be any obvious differences that would impact on this particular function.  I've even done a complete clean and rebuild to force a recompile and relink, and referenced DLLs are the same location on my hard disk.  I'm now at a complete loss.  Can anyone help me with pinpointing what could be causing this particular error?

Thanks for any help!
Question by:Xtreem
  • 4
  • 3

Expert Comment

ID: 22949324
I'm curious if the original code is a Serviced Component (COM+).  Do any of the class definitions look like:
public class MyClass: ServicedComponent

Author Comment

ID: 22949423
No, that base class isn't used anywhere in the project in the new or old code.

A few new forms were added since the old code, but nothing that should impact this - they're just new dialogues.

Expert Comment

ID: 22949478

Do you know if the original working application was a COM+ application.  You should be able to go to Start, Control Panel, Administrator tools, Component Services. Expand Component Services, Select My Computer and expand COM+ Applications.  Scroll through the COM+ applications and see if anything looks like the original application which is working.  
I am almost certain the application is a Serviced Component (COM+).  The System.EnterpriseServices.DLL leads me to believe this.  
A Serviced Component dll needs to be registered in the COM+ Catalog Before it can be registered it must be Strongly Named.  Strong Naming happens from the Visual Studio .Net Command prompt by using the sn command from the directory which contains the dll you created.
Once the dll is strongly named, it can be installed into the Global Assembly Cache (GAC).  While remaining at the Visual Studion .Net Command prompt I would do something like this gacutil /i myDLL.dll This installs the dll into the GAC.  Next, the dll needs to be registered.  I use regsvcs myDLL.dll.
There are also some other considerations that should be taken such as assigning a GUID to your dll and setting the version number of your assembly.  I would recommend reading up on COM+ components.
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.


Author Comment

ID: 22950438
I've done a search in the old project code in every file (*.*) for "ServicedComponent", but nothing found. But even if there was, this wouldn't have been removed in the latest code.

The application is an executable GUI Windows Application (.exe) written in C#/.NET.  So, it definitely isn't a COM+ application.  I've checked the Component Services and it isn't listed (see attached file) - The application is called PDCTradeGenerator; PDCWeb is something different.

Regarding your last three paragraphs, does this apply to a C# Windows Application executable also? Should I be running 'sn', 'gacutil' and 'regsvcs' on my executable?  And also, if so, is it possible that the new code has become unsynchronised with the old code's registering in this way (although, I would have though a complete rebuild would resolve anything like this, and I haven't done anything like this with the old code, I'm simply just building both versions of the project)?

Expert Comment

ID: 22953103
No, if it an executable then it won't be a COM+ component.  You shouldn't register your executable.
I know you reference the amqmdnet.dll .  Do you reference any other's within the program?  

Expert Comment

ID: 22962983
Sorry I had a hard drive which needed to be cloned today and kept me off the net.  I am just getting back on.  I have a few questions which may help me better understand your situation.
(1) What is different between your new application and the old one?  I am trying to understand the need for the new application.
(2) What references do you include within your GUI Windows App?
(3) Did you happen to add database calls within the new one?

Author Comment

ID: 23569161
I found the solution for this eventually, sorry for late update...

The overloaded constructor for IBM.MQ.MQQueueManager always generates a first-chance exception, but it is safe to ignore this.  It's by design I believe.  The difference between my earlier code and current code was that I had breaking switched on for CLR Exceptions.

Please close this Question.

Thanks for everyone's input.

Accepted Solution

Computer101 earned 0 total points
ID: 23629404
PAQed with points refunded (500)

EE Admin

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Eseutil Hard Recovery is part of exchange tool and ensures Exchange mailbox data recovery when mailbox gets corrupt due to some problem on Exchange server.
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question