无法将'x'类型的对象转换为'x'类型 [英] unable to cast object of type 'x' to type 'x'

查看:85
本文介绍了无法将'x'类型的对象转换为'x'类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经生成(使用xsd)报告的c#代码版本

定义用于报告服务中的2005版报告。我

在本地使用它,我能够反序列化已创建的

报告。然后我将代码(仅)移动到我的主项目中。我访问

rdlc文件就好了,我可以读它们没问题,但是一分钟我就试试以下内容我得到了上面的错误,


_reportDef =(Rdl.Report)ser.Deserialize(fileStream);


我不知道为什么会出现这种情况....任何人都可以放弃任何关于这个问题,这是什么意思?


万分感谢!!

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(fileStream);

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

Thanks a million!!

推荐答案

6月27日下午4:29,ron1 ... @ gmail.com写道:
On Jun 27, 4:29 pm, ron1...@gmail.com wrote:

我已经生成(使用xsd)c#代码报告版本

定义用于报告服务中的2005版报告。我

在本地使用它,我能够反序列化已创建的

报告。然后我将代码(仅)移动到我的主项目中。我访问

rdlc文件就好了,我可以读它们没问题,但是一分钟我就试试以下内容我得到了上面的错误,


_reportDef =(Rdl.Report)ser.Deserialize(fileStream);


我不知道为什么会出现这种情况....任何人都可以放弃任何光亮

就此事?
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(fileStream);

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



序列化数据可能说明了类型所属的汇编,

和反序列化将尊重这一点。然后你试着把它投到

a不同的类型 - 一个在你的主项目中。


Jon

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


您好 ro*****@gmail.com


检查反序列化对象是否等于铸造(完整类型信息,使用

调试器)。


亲切的问候,Alex Meleta

[TechBlog] http://devkids.blogspot.com
Hi ro*****@gmail.com,

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

Kind Regards, Alex Meleta
[TechBlog] http://devkids.blogspot.com

大家好,

我已经生成(使用xsd)报告的c#代码版本

报告服务中用于2005版报告的定义。我

在本地使用它,我能够反序列化已创建的

报告。然后我将代码(仅)移动到我的主项目中。我访问

rdlc文件就好了,我可以读它们没问题,但是一分钟我就试试以下内容我得到了上面的错误,

_reportDef =(Rdl.Report)ser.Deserialize(fileStream);


我不知道为什么会出现这种情况....任何人都可以放弃任何光线
有关此事?


万分感谢!!
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(fileStream);

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

Thanks a million!!



您好,


< ro ***** @ gmail.com写信息

新闻:11 ************ **********@o11g2000prd.googlegr oups.com ...
Hi,

<ro*****@gmail.comwrote in message
news:11**********************@o11g2000prd.googlegr oups.com...

大家好,

我已生成(使用xsd)报告的c#代码版本

定义用于报告服务中的2005版报告。我

在本地使用它,我能够反序列化已创建的

报告。然后我将代码(仅)移动到我的主项目中。我访问

rdlc文件就好了,我可以读它们没问题,但是一分钟我就试试以下内容我得到了上面的错误,


_reportDef =(Rdl.Report)ser.Deserialize(fileStream);
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(fileStream);



你可能想要在另一种类型中反序列化。


这样做:


Console.WriteLine(_reportDef.GetType()。FullName);

object o = ser.Deserialize(fileStream);

Console.WriteLine(_o.GetType ().FullName);

看看是否有任何区别。

Must probably you are trying to deserialize in another type.

Do this:

Console.WriteLine( _reportDef.GetType().FullName);
object o = ser.Deserialize(fileStream);
Console.WriteLine( _o.GetType().FullName);
And see if there is any difference.


这篇关于无法将'x'类型的对象转换为'x'类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆