473,547 Members | 2,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

unable to cast object of type 'x' to type 'x'

Hi everyone,
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,

_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);

I have no idea why this might be the case....can anyone shed any light
on the matter?

Thanks a million!!

Jun 27 '07 #1
10 5506
On Jun 27, 4:29 pm, ron1...@gmail.c om wrote:
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,

_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);

I have no idea why this might be the case....can anyone shed any light
on the matter?
The serialized data probably says which assembly the type belongs to,
and deserialization will honour that. You're then trying to cast it to
a different type - one which is within your main project.

Jon

Jun 27 '07 #2
Hi ro*****@gmail.c om,

Checks that a deserialized object is equal to casted (full type info, using
debugger).

Kind Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com
Hi everyone,
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,
_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);

I have no idea why this might be the case....can anyone shed any light
on the matter?

Thanks a million!!

Jun 27 '07 #3
Hi,

<ro*****@gmail. comwrote in message
news:11******** **************@ o11g2000prd.goo glegroups.com.. .
Hi everyone,
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,

_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);
Must probably you are trying to deserialize in another type.

Do this:

Console.WriteLi ne( _reportDef.GetT ype().FullName) ;
object o = ser.Deserialize (fileStream);
Console.WriteLi ne( _o.GetType().Fu llName);
And see if there is any difference.

Jun 27 '07 #4
Ron
On Jun 27, 9:42 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
Hi,

<ron1...@gmail. comwrote in message

news:11******** **************@ o11g2000prd.goo glegroups.com.. .
Hi everyone,
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,
_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);

Must probably you are trying to deserialize in another type.

Do this:

Console.WriteLi ne( _reportDef.GetT ype().FullName) ;
object o = ser.Deserialize (fileStream);
Console.WriteLi ne( _o.GetType().Fu llName);

And see if there is any difference.
Hi Ignacio,

I have done as you suggested and I have gotten the result I expected
from the Console output;

Rdl.Report
Rdl.Report

Thanks for the suggestion though!
Much appreciated

Jun 27 '07 #5
Ron
On Jun 27, 9:32 am, "Jon Skeet [C# MVP]" <s...@pobox.com wrote:
On Jun 27, 4:29 pm, ron1...@gmail.c om wrote:
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,
_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);
I have no idea why this might be the case....can anyone shed any light
on the matter?

The serialized data probably says which assembly the type belongs to,
and deserialization will honour that. You're then trying to cast it to
a different type - one which is within your main project.

Jon
Hi Jon,

the serialized file which I pass to the fileStream is a report that
was generated using VS2003. I then converted said file to the .rdlc
format and that was using VS2005. I was able to do this locally as I
said, but once moved it suddenly stopped. i was wondering if you had
any further ideas which may help?

Thanks a million!
Ron

Jun 27 '07 #6
Ron
On Jun 27, 9:41 am, Alex Meleta <amel...@gmail. comwrote:
Hi ron1...@gmail.c om,

Checks that a deserialized object is equal to casted (full type info, using
debugger).

Kind Regards, Alex Meleta
[TechBlog]http://devkids.blogspo t.com
Hi Alex,

I have done what was suggested below by Ignacio but to no avail, I got
the same types. I was wondering if you might have adda ny further
ideas?
Thanks a million for the help all the same
Much appreciated!!
Jun 27 '07 #7

"Ron" <ro*****@gmail. comwrote in message
news:11******** **************@ z28g2000prd.goo glegroups.com.. .
On Jun 27, 9:42 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
>Hi,

<ron1...@gmail .comwrote in message

news:11******* *************** @o11g2000prd.go oglegroups.com. ..
Hi everyone,
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,
_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);

Must probably you are trying to deserialize in another type.

Do this:

Console.WriteL ine( _reportDef.GetT ype().FullName) ;
object o = ser.Deserialize (fileStream);
Console.WriteL ine( _o.GetType().Fu llName);

And see if there is any difference.

Hi Ignacio,

I have done as you suggested and I have gotten the result I expected
from the Console output;

Rdl.Report
Rdl.Report
Show

GetType().Assem blyQualifiedNam e

instead.
>
Thanks for the suggestion though!
Much appreciated

Jun 27 '07 #8
Ron <ro*****@gmail. comwrote:
the serialized file which I pass to the fileStream is a report that
was generated using VS2003. I then converted said file to the .rdlc
format and that was using VS2005. I was able to do this locally as I
said, but once moved it suddenly stopped. i was wondering if you had
any further ideas which may help?
It shouldn't matter which version of VS or .NET you were using - the
problem is that you're trying to use a different type to the one which
was serialized. I suggest you leave the types in the different
assembly.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jun 27 '07 #9
Ron
On Jun 27, 11:50 am, "Ben Voigt [C++ MVP]" <r...@nospam.no spamwrote:
"Ron" <ron1...@gmail. comwrote in message

news:11******** **************@ z28g2000prd.goo glegroups.com.. .


On Jun 27, 9:42 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
Hi,
<ron1...@gmail. comwrote in message
>news:11******* *************** @o11g2000prd.go oglegroups.com. ..
Hi everyone,
I have generated (using xsd) the c# code version of the report
definition used for 2005 version of reports in reporting services. I
was using it locally and I was able to deserialize already created
reports. I then move the code (only) into my main project. I access
the rdlc files just fine, i can read them no problem, but the minute I
try the following I get the above error,
_reportDef = (Rdl.Report)ser .Deserialize(fi leStream);
Must probably you are trying to deserialize in another type.
Do this:
Console.WriteLi ne( _reportDef.GetT ype().FullName) ;
object o = ser.Deserialize (fileStream);
Console.WriteLi ne( _o.GetType().Fu llName);
And see if there is any difference.
Hi Ignacio,
I have done as you suggested and I have gotten the result I expected
from the Console output;
Rdl.Report
Rdl.Report

Show

GetType().Assem blyQualifiedNam e

instead.


Thanks for the suggestion though!
Much appreciated- Hide quoted text -

- Show quoted text -- Hide quoted text -

- Show quoted text -
Hi Ben,

Thanks a million for the help!! Its much appreciated!
I have done as you suggested and to find again the same result as
before. Both the object I am casting into and the object I got after
deserialization returned the same result for the above mentioned
suggestion.
Thanks again though!

Jun 27 '07 #10

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

Similar topics

0
7367
by: Pankaj Jain | last post by:
Hi All, I have a class A which is derived from ServicesComponent to participate in automatic transaction with falg Transaction.Required. Class A is exposed to client through remoting on Http channal hosting into IIS. There is a class B which is also available through remoting hosted on IIS on the same URI. B creates new of A inside a function....
3
12958
by: Imran Aziz | last post by:
Hello All, I am getting the following error on our production server, and I dont get the same error on the development box. Unable to cast object of type 'System.Byte' to type 'System.String'. here is the code that I used to create a table and then add columns to it later, later I populate the rows in the table.
8
6498
by: | last post by:
I have the following class : Public Class MyTreeNode Inherits TreeNode Dim mystring As String End Class Now, when I try to do this : ''''''''''''nodes is a TreeNodeCollection, s is string
0
1562
by: sam | last post by:
Hi: I am not sure if this is the right place to post this question. Please let me know if it is not and I appreciate if someone could point me in the right direction. I am getting this error after converting to .NET 2.0. Unable to cast object of type 'Oracle.DataAccess.Client.OracleCommand' to type 'System.Data.Common.DbCommand'
0
1620
by: hlyall1189 | last post by:
Hi, I recently started upgrading some of my old vs 2003 apps to vs 2005 and used the conversion tool but now i get the following error after building the page. I have typecasted the lines as follows: ((StyleSheetProvider)this.Page).GetStyleSheetPath(); Is there some different way of typecasting that needs to be done in vs2005? Thanks in...
2
13564
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) { this.Url = url;
3
10243
by: keithb | last post by:
What could be causing this? this code: String Com = ""; if (Com != (String)rw.ItemArray) fails at runtime with the error message: Unable to cast object of type 'System.Int32' to type 'System.String'.
10
2506
by: mypetrock | last post by:
Has anyone run into this error message? Unable to cast object of type 'Foo.Bar' to type 'Foo.Bar'. I'm trying to cast an object of type Foo.Bar that I got out of a hash table into a variable of type Foo.Bar. Foo.Bar data = (For.Bar)input; Thanks,
1
3937
by: miller.brettm | last post by:
Hi, I'm working with an ActiveX serial component that fires an event when data is received. I need to continue to use this component because it contains the ability to do Xmodem1k an d XmodemCRC comms The RX even fires and passes an Object (Type: Object) parameter. When looking @ the Locals window it shows the Type as: Object { byte } ...
1
2327
by: =?Utf-8?B?U2NvdHQ=?= | last post by:
Hello, Using VS2008 in a C# web service application, a class has been created that inherits from the ConfigurationSelection. This class file has been placed in the App_Code folder. The web.config has been updated with the necessary section. Using System.Web.Configuration.WebConfiguration.GetSection(), the config information is returned...
0
7507
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7698
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7947
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7794
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5361
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3472
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1922
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 we have to send another system
1
1046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.