Solved

COM+ error System.InvalidCastException

Posted on 2004-08-31
3
367 Views
Last Modified: 2012-06-27
Hi All,
 I have a COM component that i have installed as a server component. I create an instance of the component in my .aspx file. It worked fine for some time, then i changed another component that the com calls and i started getting a message
System.InvalidCastException: Specified cast is not valid
[InvalidCastException: Specified cast is not valid.]
   System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo) +0
   System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType, Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri) +581
   System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType)
   System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj) +74
   intersoft.ptList.WebGrid1_InitializeDataSource(Object sender, DataSourceEventArgs e) in c:\inetpub\wwwroot\uilayer\ptlist.ascx.cs:179
   ISNet.WebUI.WebGrid.WebGrid.OnInitializeDataSource(Object dataSource)
   ISNet.WebUI.WebGrid.WebGrid.OnLoad(EventArgs e)
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Control.LoadRecursive()
   System.Web.UI.Page.ProcessRequestMain()

Can somebody help me with this problem,
Thanks,
Preetham.
0
Comment
Question by:kingpreetham
3 Comments
 
LVL 7

Accepted Solution

by:
NipNFriar_Tuck earned 50 total points
Comment Utility
There is a good possibility that when you changed the code the GUID for the class changed.  You can prevent this from happening by adding a GUID attribute [GUID("###")] to the classes and interfaces used in the com piece also in the code that the com piece calls...

Another possiblity is of the namespace changed then even though the class is exactly the same you will not be able to cast from one to another...

Anyhow, these are two situations that I have ran into that may explain what is happening to you...
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now