473,471 Members | 1,728 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

InvalidCastException from IBM-MQ COM component when running in thr

I have just started using VB.Net and I am developing a class to provide data
to clients from an IBM-MQ queue.

I have developed a class which connects to the queue and issues a read. When
a message comes in an event is raised back to the client containing (at the
moment) only the message id.

This all works fine but the MQ read call blocks and prevents other processing.

To overcome this I have created the object and then start the listening in a
thread. The MQ session object is created but then the first call to any
property on that object causes and InvalidCastException to the be thrown from
within QueryInterface.

Any advice much appreciated.
Nov 21 '05 #1
5 1465
Geoff,

Start with setting Option Strict On in top of your program.

Than you are not using late binding, what means that it is showed in your
code where those errors can be.

I hope this helps,

Cor
Nov 21 '05 #2
Cor

Thanks for the suggestion. I do have Option Strict On at the start of the
code.

The code works fine when the class is run in the main thread, it is only
when I try and run it in a thread of its own using.

Dim thrd As Thread
thrd = New Thread(New ThreadStart(AddressOf myQueue.StartListening))
thrd.Start()

Regards
Geoff
Nov 21 '05 #3
Geoff,

I have the idea that I use somewhere a thread as well very much recursive,
however, is that queue method a queue method that change the queue and
therefore needs a synclock.

It is just a gues

Cor
Nov 21 '05 #4
A bit more info.

The exception is coming as it appears it cannot find the IMQSession200
interface in the IBM-MQ ActiveX component.

I have looked in the object browser and the interface is shown as Public
when 'Show Hidden Member' is selected.
Nov 21 '05 #5
Cor

Thanks for that, I'll have a look at locking. It's the next thing in the
chapter of the book I'm reading now :)

I've trawled the net a bit more and there are other documented issues with
using the IBM-MQ ActiveX control within a .Net thread, so it may be that I'm
trying to do something that is limited by the control.

I've looked at the different threading models (MTA,STA) for the thread and
played about with those to no joy.

I've hacked the code about so that it runs in a thread but doesn't make use
of MQ (pointless class but to prove it wasn't my misunderstanding of threads)
and all works fine.

There certainly seems to be some problem when trying to instantiate an
MQSession object. I did read in the docs that theInvalidCastException error
can be thrown by mscorlib when failing to access an interface in a COM
component. I believe that this is where the problem lies.

Regards
Geoff
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Kevin | last post by:
Hi I try the following program and I get InvalidCastException at the line MyByte b = (MyByte)obj; If I change it to MyByte b = (MyByte)d;
1
by: Brian Conway | last post by:
Hope someone can help. I am trying to get a submit button working and getting this error now System.InvalidCastException: Object must implement IConvertible. This is showing up on the...
5
by: WangHF | last post by:
hi , The Code like this: public static Mapping Deserialize(string strXmlFilePath) { XmlSerializer s = new XmlSerializer(typeof(Mapping)); using (StreamReader sr = new...
1
by: Rhino | last post by:
Is there any way to install the IBM Distributed Debugger V9.2 on Windows XP without first uninstalling DB2? I installed the IBM Distributed Debugger V9.2 on my Windows XP box in the hopes of...
0
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
0
by: Lester Knutsen | last post by:
A two-day IBM Informix and DB2 User Group Technical Conference - Friday and Saturday, December 8-9, 2006 We are very please to announce our Keynote Speakers...
0
by: Lester Knutsen | last post by:
A two-day IBM Informix and DB2 User Group Technical Conference - Friday and Saturday, December 8-9, 2006 Location - Fairview Park Marriott, Falls Church, VA (near Washington D.C.)...
2
by: SimoneB | last post by:
Hy, everyone! I'm trying to install eClient, installation is done but during configuration of Web Aplication server i receive the error: " the configuration of...
0
by: SimoneB | last post by:
I'm trying to install eClient v 8.3 but during configuration Web application server i get the error: "the configuration of eclient failed while creating the web aplication server....
8
by: Joe HM | last post by:
Hello - I was wondering that the "cleanest" way is to determine whether a CType() will throw an InvalidCastException? I have data I receive as an Object and I want to convert it to a String...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.