错误:缺少对象

shootgoal 2007-10-27 09:29:34
我用vs2005的摸板建的silverlight在网页上可以打开。自己做的就不行了,我对照SDK帮助做的下面是代码:Sample.html,myxaml.xaml,Silverlight.js,creatSilverlight.js。
Sample.html
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>A Sample HTML page</title>
<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript" src="createSilverlight.js"></script>

</head>
<body>

<!-- Where the Silverlight plugin will go-->
<div id="mySilverlightPluginHost">
</div>
<script type="text/javascript">


// Retrieve the div element you created in the previous step.
var parentElement = document.getElementById("mySilverlightPluginHost");
createMySilverlightPlugin();

</script>

</body>
</html>

myxaml.xaml


<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Ellipse
Height="200" Width="200"
Stroke="Black" StrokeThickness="10" Fill="SlateBlue" />
</Canvas>

creatSilverlight.js

// JavaScript Document
function createMySilverlightPlugin()
{
Silverlight.createObject(
"myxaml.xaml", // Source property value.
parentElement, // DOM reference to hosting DIV tag.
"mySilverlightPlugin", // Unique plugin ID value.
{ // Per-instance properties.
width:'300', // Width of rectangular region of
// plugin area in pixels.
height:'300', // Height of rectangular region of
// plugin area in pixels.
inplaceInstallPrompt:false, // Determines whether to display
// in-place install prompt if
// invalid version detected.
background:'#D6D6D6', // Background color of plugin.
isWindowless:'false', // Determines whether to display plugin
// in Windowless mode.
framerate:'24', // MaxFrameRate property value.
version:'0.8' // Silverlight version to use.
},
{
onError:null, // OnError property value --
// event handler function name.
onLoad:null // OnLoad property value --
// event handler function name.
},
null); // Context value -- event handler
}
Silverlight.js 是摸板上的那个文件。

我照做电子书和帮助文件做了几个例子都在网页上没显示,画图和helloworld都不行。
...全文
1027 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
蝈蝈俊 2007-11-01
  • 打赏
  • 举报
回复
上次发布 UBB 解析动过地方,结果导致了 > 之前有个空格, 现在已经修正。
如果没有看到效果,需要重新生成一下静态帖子
ClementDik 2007-10-30
  • 打赏
  • 举报
回复
有道理...Silverlight.js文件对于不同版本的格式是不同的。不过...0.8?那是什么版本啊...
楼主的标题是“缺少对象”...
ClementDik 2007-10-29
  • 打赏
  • 举报
回复
我不知道是不是楼主的笔误,xmal文件中:[code=XAML] <Ellipse
Height="200" Width="200"
Stroke="Black" StrokeThickness="10" Fill="SlateBlue" / >
[/code]
最后面,“>”之前,多了一个空格。这样的确会导致运行时错误。(因为破坏了XML的格式)
其他部分貌似也没有什么问题。

如果不是这个问题的话,楼主恐怕需要把错误描述的更详细了。
saucer 2007-10-29
  • 打赏
  • 举报
回复
那个空格是CSDN加的

好像没问题啊,不过把

version: '0.8 '

改成

version: '1.0'

注意,CSDN会加一个空格

8,734

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧