?
Solved

COM+ error System.InvalidCastException

Posted on 2004-08-31
3
Medium Priority
?
393 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
1 Comment
 
LVL 7

Accepted Solution

by:
NipNFriar_Tuck earned 200 total points
ID: 11953561
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

749 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