值不能为空.参数名称:流错误 [英] Value cannot be null. Parameter name: stream Error

查看:415
本文介绍了值不能为空.参数名称:流错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友,
我正在Silverlight 4中开发游戏
并且我创建了一个类stream.cs
我在执行时间上有问题
错误是值不能为空.参数名称:stream Error
这是班
所以请帮我:代码在这里-

公共Canvas LoadSpriteCanvas(string xamlPath)
{
System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream(xamlPath);
return(Canvas)XamlReader.Load(new System.IO.StreamReader(s).ReadToEnd());//错误在这里

}

Hello Friends,
I am developing a game in Silverlight 4
and i have created a class stream.cs
i have problem in execution time
Error is Value cannot be null. Parameter name: stream Error
this is the Class
so please help me: Code is Here-

public Canvas LoadSpriteCanvas(string xamlPath)
{
System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream(xamlPath);
return (Canvas)XamlReader.Load(new System.IO.StreamReader(s).ReadToEnd());// Error is here

}

推荐答案

您应该知道的更好,因为您可以在调试器中运行它并检查操作数:哪个变为空,何时变为.

我猜流s为空是因为xampPath错误或其他原因.
在询问此类问题之前,请始终使用调试器.这样,您可以提供更多确定的信息.通常,在几乎不关心您的运行时行为的情况下,请始终使用调试器.

—SA
You are supposed to know that better, because you could run it under debugger and check up the operands: which one becomes null and when.

I would guess that the stream s is null because xampPath is wrong or some other reason.

Please always use the debugger before asking such questions. This way, you can provide more definitive information. And generally, always use the debugger in case of even a slightest concern of your run-time behavior.

—SA


这篇关于值不能为空.参数名称:流错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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