473,791 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InvalidCastExce ption 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 InvalidCastExce ption to the be thrown from
within QueryInterface.

Any advice much appreciated.
Nov 21 '05 #1
5 1488
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(Add ressOf myQueue.StartLi stening))
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 misunderstandin g 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 theInvalidCastE xception 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
1424
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
1664
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 ExecuteNonQuery line. Below is the code that I have in my Page_load. I also have no idea of what code I would use in the Submit_Click event to get the insert to work. Any help would be appreciated OleDbConnection conn = new...
5
1320
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 StreamReader(strXmlFilePath)) { object o = s.Deserialize(sr);
1
3008
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 debugging a Java stored procedure. Well, I never got the debugger to work despite my best efforts - see posts earlier this week - so now I'd like to uninstall the debugger. I looked into this but the README says: 3.1 Uninstalling on Windows
0
623
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 not valid.","Microsoft.BusinessIntelligence.Scorecard.ScorecardException: Specified cast is not valid. ---> Microsoft.BusinessIntelligence.Scorecard.ScorecardException: Specified cast is not valid. ---> System.InvalidCastException: Specified...
0
2670
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 --------------------------------------------------- * Friday, December 8, 2006 – Ambuj Goyal, General Manager of IBM Information Management * Saturday, December 9,2006 - Arvid Krishna, Vice President of Database Servers, IBM Information Management These are the top two executives...
0
2077
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.) ************************************************************************************************** Web site at: http://www.iiug.org/waiug/present/Forum2006/Forum2006.html We are very please to announce our Keynote Speakers...
2
2064
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 eclient failed while creating the web aplication server. return code=151" I, also, tried to configure manually and deploy the eClient with Websphere Application Server v 5.1.1, but no good, in log files i get the same error:
0
3082
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. return code=151" i also tried to configure and deploy eClient manually with Websphere, but no good, i got the same error in log files: 2007/06/11 11:09:15 SSD found Name = EC Version = 8.3.00.000
8
4966
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 whenever possible using CType(lObjectDummy, String) otherwise I will just ignore it. I could put a Try/Catch As System.InvalidCastException around it but I was wondering if that is the best solution. I once heard that exceptions should not be...
0
10419
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10201
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9987
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9023
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6770
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5424
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5552
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4100
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3709
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.