473,503 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

specified case is not valid

I have a class that's a project by itself within a project and I'm
referencing this class in a Windows Application as well as a Windows Service
that are both separate projects of the same solution. I'm able to use the
class just fine in the Window app, but the service returns the exception
"specified cast is not valid". For an additional test I created a brand new
solution and Windows app and that worked... it's just the service that isn't
working with it.

Is there any way to find out a more useful explanation for the problem? I
took a look through the exception in debug mode but didn't notice anything.
Nov 15 '05 #1
6 2257
I am just guessing. Separate projects create separate assemblies. You
may
need to break out the common classes into a separate library.

In other words, if two assemblies contain the same class with the same
fully
qualified name, the runtime still sees the two classes as different
types. In a
sense, I conceptualize this as having the runtime "prepend" the assembly
"name" to the fully qualified class name. Got that? Check here for more
information about InvalidCastExceptions and plug ins, compliments of Jon
Skeet: http://www.yoda.arachsys.com/csharp/plugin.html

Regards,
Jeff
I have a class that's a project by itself within a project and I'm

referencing this class in a Windows Application as well as a Windows
Service
that are both separate projects of the same solution. I'm able to use
the
class just fine in the Window app, but the service returns the exception
"specified cast is not valid". For an additional test I created a brand
new
solution and Windows app and that worked... it's just the service that
isn't
working with it.<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #2
"Jeff Louie" <je********@yahoo.com> wrote in message
news:O0*************@TK2MSFTNGP12.phx.gbl...
I am just guessing. Separate projects create separate assemblies. You
may
need to break out the common classes into a separate library.

In other words, if two assemblies contain the same class with the same
fully
qualified name, the runtime still sees the two classes as different
types. In a
sense, I conceptualize this as having the runtime "prepend" the assembly
"name" to the fully qualified class name. Got that? Check here for more
information about InvalidCastExceptions and plug ins, compliments of Jon
Skeet: http://www.yoda.arachsys.com/csharp/plugin.html

Regards,
Jeff


I don't completely understand, but I did try changing the class name,
project name, and namespace to something else but still have the same
problem. I'm not sure where it would be getting two different ones since
it's a unique name and none of the references have referenced this
particular project with the class.
Nov 15 '05 #3
"Jeff Louie" <je********@yahoo.com> wrote in message
news:O0*************@TK2MSFTNGP12.phx.gbl...
I am just guessing. Separate projects create separate assemblies. You
may
need to break out the common classes into a separate library.

In other words, if two assemblies contain the same class with the same
fully
qualified name, the runtime still sees the two classes as different
types. In a
sense, I conceptualize this as having the runtime "prepend" the assembly
"name" to the fully qualified class name. Got that? Check here for more
information about InvalidCastExceptions and plug ins, compliments of Jon
Skeet: http://www.yoda.arachsys.com/csharp/plugin.html

Regards,
Jeff


I don't completely understand, but I did try changing the class name,
project name, and namespace to something else but still have the same
problem. I'm not sure where it would be getting two different ones since
it's a unique name and none of the references have referenced this
particular project with the class.
Nov 15 '05 #4
Greg... If the class that's a project by itself is creating a _library_
then there
should be no problem with the type of this library referenced from an
application or a service. I suspect that some application calls are not
available
to services.

Regards,
Jeff
I don't completely understand, but I did try changing the class name,

project name, and namespace to something else but still have the same
problem.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #5
Greg... If the class that's a project by itself is creating a _library_
then there
should be no problem with the type of this library referenced from an
application or a service. I suspect that some application calls are not
available
to services.

Regards,
Jeff
I don't completely understand, but I did try changing the class name,

project name, and namespace to something else but still have the same
problem.<

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #6
"Jeff Louie" <je********@yahoo.com> wrote in message
news:u3***************@tk2msftngp13.phx.gbl...
Greg... If the class that's a project by itself is creating a _library_
then there
should be no problem with the type of this library referenced from an
application or a service. I suspect that some application calls are not
available
to services.

Regards,
Jeff


I think I figured out the problem. InteropServices isn't working within my
Windows Service and it looks like the only way to make it work (from what
I've read) is to enable something called interact with desktop, which I'm
not sure I'll be able to do or even want to do.
Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
22550
by: OldGuy | last post by:
Hi All Sendmail 8.12.11 php 4.3.9 Sendmail is installed and works properly. php is NOT in safemode from the command line; mail user@domain.com < testmsg works fine.
1
5807
by: Ron Holmes | last post by:
I posted this question on the Crystal Reports Support site and I am still waiting for an answer. Using Crystal Reports 9.0 Developer Full edition: My Crystal report .RPT file has a Picture box...
9
2136
by: Matt Tapia | last post by:
I having a problem that receives the following error: Specified cast is not valid And I need some help. Here is what is happening: I have a form with a drop-down control that contains a list...
3
10494
by: PK9 | last post by:
I am looking for assistance in pinpointing the cause of the following exception. I am getting a "Specified Cast is not valid" exception on my page. I am trying to populate a datagrid. One of my...
0
623
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
5
360
by: Web Team | last post by:
Can anyone help with this error... "Specified cast is not valid." Which I am getting with this code... (Line 223) Line 221: 'Handles data paging Line 222: Public Sub...
1
1393
by: .Net Sports | last post by:
I have a datagrid codebehind script that takes data from sql dbase and displays it in a footer row as a total. One column has amount_dollars (which works fine), while another has new sales (which...
0
5662
by: Ismail Fatih Yıldırım | last post by:
I modified the RSACSPSample from MSDN to try out a simple commutative encryption model using RSA encryption but when i run the progrem the first encryption command works but during the second...
1
12484
by: Eric Simmons | last post by:
Hello, I am trying to run a .NET 2.0 application that I developed and I am getting the following error: Key not valid for use in specified state I am attempting to retrieve the...
4
1548
by: John Rogers | last post by:
Can someone help me out if possible with this error when running a program. I have this code in the program //------------------------------------------- System.Data.OleDb.OleDbCommand vCommand...
0
7084
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7328
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.