Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

COM+ error System.InvalidCastException

Posted on 2004-08-31
3
Medium Priority
?
387 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

618 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