Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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 June 22nd, 2007, 07:44 AM
Registered User
 
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot implicitly convert type ...

Hi fellow developers,

I have this error message: Cannot implicitly convert type 'Hotelplan.BO.Hotel' to 'Hotel'. The strange thing is that the code did build and did run until I tried to change the name of some other class (HotelplanManager to HotelplanRecManager). I'm trying to follow a design from Imar Spaanjaars (http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=416).

And yes, it's the same hotel-class.

Because I couldn't figure out what was going on I did make a new solution and designed everything for the second time. At first it did build and run and after renaming a class I got the error message again.
In trying to solve it I did remove all of the temporary files at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temp orary ASP.NET Files but no result!

Who can help me?

thanks Leon

Leon
 
Old June 22nd, 2007, 08:35 AM
Registered User
 
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, After "View in Browser" (and some hour of searching for a solution, restarting the computer ,deleting temp-files and still having the problem) it seems to work again ????

But it still intrigues me, anyone?


Leon
 
Old June 22nd, 2007, 10:47 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This seems like a fairly strange problem. Either the class is "Hotel" or it isn't. If it is, it should cast without a problem. What is the type of the variable you are trying to cast? Is would appear from your error message that it was an instance of 'Hotelplan.BO.Hotel'. Where is the type 'Hotel' defined? Is it possible that that name is also used in your web application? I've caught myself occasionally with a case like this: I have a "*.BO.Product" class, but I also have a "Product" class that is a web page class. So in the code where you try to cast type "object" to "Product" the compiler doesn't know you meant "*.BO.Product" instead of "MyWebApp.Product". The problem is the name ambiguity.

-Peter
 
Old June 22nd, 2007, 11:20 PM
Registered User
 
Join Date: Jun 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried a hint I got from a fellow developer and I fully qualified my hotel-instance. Succes! After reviewing the project I saw that you were very right Peter: I also have a page that is called: yes Hotel.aspx That must be it.

Thanks for your reaction Peter!

gr Leon

Leon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert "String" type to "Control" type ? kishore_peddi C# 4 January 11th, 2006 01:21 PM
cant implicitly convert type int to bool muskaanbajaj BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 19th, 2005 04:57 PM
Cannot implicitly convert type int to bool muskaanbajaj General .NET 12 May 5th, 2005 03:57 AM
Can't convert type 'bool' to 'int' Gjerstad BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 9th, 2003 10:33 AM





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