473,780 Members | 2,243 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 1487
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
2669
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
2076
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
4965
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
9636
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9931
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
8961
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...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
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
5373
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...
1
4037
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

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.