value of type 'XXX' cannot be converted to type 'XXX'

 I've had this issue with VS2008 lately that is driving me crazy.  I have a website where I built a class that does all my Web Service interaction.  This class returns instances of Web Service proxies, or list of the same. 

In my web page I'll create a temporary variable (Dim - I'm using VB) with the same type that my service class is going to return.  When I assign my variable to the return of the method, I'm getting a message similar to the following

"Value of type 'Namespace.Foo' cannot be converted to type 'Namespace.Foo'.  It's the same type, but for some reason studio keeps showing me this error.  Most times, closing down Studio and opening it back up will fix the problem, but not always.  Even doing a build doesn't fix this.  Funny enough, I can assign the return of the method to 'Object' and then assign that variable to my properly typed variable and that works.  

Anybody ever see this?  It does work fine in VS2005.

 Thanks.

Matt
 


Matt
0
mschumacker
4/21/2008 11:43:18 PM
asp.net.visual-studio-2008 3408 articles. 0 followers. Follow

6 Replies
433 Views

Similar Articles

[PageSpeed] 31

 vs2005 puts compiled copies of objects into a temporary directory and continues to use them.  Well, actually, it continues to create new temporary directories with new objects in them, but will also continue to use the old ones.  It's a "feature". :)

If it's a control on a webpage, you can refresh it (right clicking on it will show the menu option) and it will (often) start using the new version.

Haven't used vs2008 yet, but I would suspect that might be related to the problem.
 

0
david
4/22/2008 5:31:33 AM

Thanks for the information, but I'm still stumped.  Has anybody else seen this?  

Like I said earlier, the weird thing is that I can assign the returned object to a variabled dimmed as Object, then assign that one to the properly created object and VS2008 has no problems with that.  Really weird if you ask me, but really annoying.

 

Matt 


Matt
0
mschumacker
4/24/2008 8:14:27 PM

 

Does the problem come up ONLY when you have changed that class by adding additional properties or methods?
0
david
4/25/2008 7:35:58 AM

 No, it comes up almost all the time.  I was hoping that the VS2008 Service Pack would fix this, but it didn't.

 Anybody else experiencing this?

 


Matt
0
mschumacker
7/2/2008 7:36:01 PM

 It's the same in VS 2003. I've been stuck for 3 hours.

This is a workaround (uggly but worksIck!)

Before:

Me.rdb.parametros.limpiar()

After:

        Dim x As Object = Me.rdb.parametros 'parametros is of type ListaDeSoloUnTipoCS
        Dim z As New ListaDeSoloUnTipoCS(x)
        z.limpiar()
 

Hope it works, 

Not everyone lives - Wallace


"Give thanks to nature, the bountiful, because it has made necessary things easy to procure, while things hard to obtain are not necessary."
Epikouros
0
caracho
11/10/2008 7:23:25 PM

 A little bit shorter:

 

        Dim parche As New ListaDeSoloUnTipoCS(Me.rdb.parametros)
        parche.limpiar()

 

Forgot to write:

dim parametros as ListaDeSoloUnTipoCS

Public Class ListaDeSoloUnTipoCS

...
    Sub New(ByVal unTipo As Object)
        tipoInicial = unTipo    'saca copia
    End Sub

 ....

 

By the way be careful to mix inheritance and polimorphism, they do not work together

Freedom! - Wallace


"Give thanks to nature, the bountiful, because it has made necessary things easy to procure, while things hard to obtain are not necessary."
Epikouros
0
caracho
11/10/2008 7:28:51 PM
Reply:

Similar Artilces:

Cannot convert type 'type' to 'type'
I am learning all of this, so I am still fresh, so please bear with me :)I have a page that has some txtboxes in it, simple registration form, and I have a button that will save those txt boxes to the db. I am using:- I am using Visual Web Developer 2008 Express Edition- C# When I try to compile the project I get error: Cannot convert type 'System.Web.UI.WebControls' to 'String' This is content of my web.config    <profile> <properties> <add name="FirstName"/> <add name="LasttName"/>...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

E2094 'operator+' not implemented in type 'XXX' for arguments of type 'int'
Okay I have a problem; I am trying to extend a string class that I wrote for a friend so I can use it another project I am working on. I have an error that makes absolutely no sense. Here is the code for the copy constructor: String(const String &str) // for copying into a new string object { Size = str.Size; Data = new char[Size+1]; for (int i = 0; i<Size; i++) Data[i] = str[i]; // recieving the following error on the above line: [BCC32 Error] Mystring.h(33): // E2094 'operator+' not implemented in type 'String' for arguments of typ...

Occaisonal Build problems (type 'xxx' exists in both 'yyy.dll' and 'xxx.dll')?
Hello: Been working with Express for about 2 months now -- and it generally works fine -- but I occaisonally get this error message when I rebuild projects to rerun it: ------ Rebuild All started: Project: http://localhost/TestIV/, Configuration: Debug .NET ------ Build Web Beginning D:\DEV\DEV_NET\CS\SITES\TestIV\portal.aspx(9,31): error CS0433: The type 'ASP.Portal' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\Temporary ASP.NET Files\testiv\2bc5e680\fdf16dd9\f3iai7un.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.40607\Temporary ASP.NET Files\testiv\...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

table_info('','','','%') cannot return any types
I was recently confirming table_info special cases and discovered the case for getting table_types cannot work. table_info('','','','%') should return a list of table types but it returns a list of empty strings instead: my @types = $h->tables('', '', '', '%'); print "all types:\n", join("xxx\n", @types), "\n"; # should output something like: # "dbo" # "INFORMATION_SCHEMA" # "sys" # and actually outputs: xxx xxx It seems to be down to the following ...

'''''
Name: mario Email: ramar17atfastwebnetdotit Product: Gran Paradiso Alpha 2 Summary: ''''' Comments: K: Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a2) Gecko/20070206 GranParadiso/3.0a2 ...

Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'
Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error... Dim EmailBodyTxt As New StringBuilder EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td>...

Value of type 'String' cannot be converted to 'System.Net.Mail.MailAddress'
My code is below:Protected Sub btnSendMsg_OnClick(ByVal Source As Object, ByVal E As EventArgs) Dim myMessage As New System.Net.Mail.MailMessage Dim myAttachment As System.Net.Mail.Attachment Dim myMail As System.Net.Mail.SmtpClient If Page.IsValid() Then myMessage.From = txtFromEmail.Text myMessage.To = txtToEmail.TextWhat can I do to fix this? MailMessage.To represents a collection that you Add addresses to.Dim recipient As MailAddress= new MailAddress(txtToEmail.Text) myMessage.To.Add(recipient)    Mike Banavige~~~~~~~~~~...

Unable to cast object of type 'TYPE' to type 'TYPE'.
I've got a custom class and collection...I want to use them to databind a Grid, and persist the state using a Session variable.  However I keep getting the above error **Sometimes...There will be times when it works fine, and times when it totally craps out.System.InvalidCastException: Unable to cast object of type 'ApprovalCycleCollection' to type 'ApprovalCycleCollection'. This should work fine, no?  I want a property to use in all my foreach loops   public ApprovalCycleCollection NewApprovalCycle { get { if (Se...

Operator '*' is not defined for type 'DBNull' and type 'Decimal'.
 I am getting an error from the following line   <asp:Label ID="Label1" runat="server" Text='<%# String.Format("{0:C}", Eval("ProductQty") * Eval("Price"))   %>' ></asp:Label> I think I may need to convert/define the Variables but not quite sure how to do it. Any help would be great. it's not a matter of converting...its the fact that the value from the DB is Null... You'll have to wrap an IF check around it or change your query to return 0 instead of Null. If the field ...

Operator '=' is not defined for type 'Char' and type 'Boolean'.
Hello, In my application when i click the button i'm getting this " Operator '=' is not defined for type 'Char' and type 'Boolean'. " But when i test it locally there is no problem at all!!!! Please tell me why this error is occuring...Thanks SwapnaPlease click "mark as answer" if this post helped you. swapnasamsonvarkey: Hello, In my application when i click the button i'm getting this " Operator '=' is not defined for type 'Char' and type 'Boolean'. " But when i test it lo...

Value of type 'Integer' cannot be converted to 'Double'
 Hi,     I'm getting this error on my paging class "Value of type 'Integer' cannot be converted to 'Double'."    --error in bold--PaginatedList.vbPublic Class PaginatedList(Of T)    Inherits List(Of T)    Private _PageIndex As Integer    Public Property PageIndex() As Integer        Get            Return _PageIndex        End Get      ...

Unable to cast object of type 'System.Web.Security.FormsIdentity' to type 'XXX'
I got following        protected void Application_AuthenticateRequest(object sender, EventArgs e)        {            if (Request.IsAuthenticated)            {                var user = Membership.GetUser();                var identity = new CustomIdentity(user.UserName, new Guid(user.ProviderUserKey.ToString()));&nb...

Web resources about - value of type 'XXX' cannot be converted to type 'XXX' - asp.net.visual-studio-2008

Resources last updated: 12/27/2015 10:26:52 AM