Solved

COM+ error System.InvalidCastException

Posted on 2004-08-31
3
380 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 7

Accepted Solution

by:
NipNFriar_Tuck earned 50 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 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