Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 1.0 and Visual Studio.NET > VS.NET 2002/2003
|
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2003, 02:00 AM
Authorized User
 
Join Date: Aug 2003
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default InvalidCastException in Serviced Component

Hi,

I'm trying to do an insert and update of a record in a serviced component.
When I call these methods, I get an InvalidCastException: Unable to cast object of type System.__ComObject to type System.Data.DataSet. Inside these methods, there's really just the basic insert/update stuff. Attaching to my component doesn't work anymore. So I can't step through the code. Executing a select works well.

I'm using framework 1.1.

Where does this error come from? Is this some problem with datasets and serviced components?

Thanks in advance,
Pieter
 
Old September 3rd, 2003, 02:57 PM
Registered User
 
Join Date: Sep 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

schockp-

I've spent a couple of days with the same problem. Here is the solution. You didn't say, but I assume you are running your component as a Server activation, meaning that it runs in it's own copy of DllHost.exe. This is the probelm. The CLR may not be able to find one or more assemblies that are used by the COM+ application. Assemblies that are missing will cause strange errors, including this one.

So: make sure that you put all assemblies that are used by the COM+ application, whether they are serviced or not, into the Global Assembly Cache. You can do this with the "gacutil" utility from the VS command line. You can also add the following to the "Post-Build Event" property associated with the project:

call "C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\vsvars32.bat"
gacutil -u $(TargetName)
gacutil -i $(TargetDir)$(TargetFileName)

You have to change the first line to match where your Visual Studio common files are located, if not on the C drive in the default location. Add this to each project's Post Build event command line that is part of the COM+ app. It will install the assembly with each rebuild, automatically.

Good luck,

Joseph





Similar Threads
Thread Thread Starter Forum Replies Last Post
System.InvalidCastException: Specified cast is not scslarry BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 6 January 18th, 2007 07:34 PM
InvalidCastException in VB.NET? bhavna VS.NET 2002/2003 0 January 16th, 2007 01:39 AM
System.InvalidCastException: QueryInterface for sweta .NET Web Services 5 June 8th, 2006 02:32 AM
Cannot open Sql Connection in Serviced component pawan20041 General .NET 0 June 4th, 2004 04:22 AM
Using Serviced DB object thermans BOOK: ASP.NET Website Programming Problem-Design-Solution 0 March 8th, 2004 01:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.