您的位置:首页 > 其它

Silverlight开发中遇到的几个小问题

2010-07-14 07:34 309 查看
1,程序发布时遇到错误:

"Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'"

可能引发此问题的原因:

安装.NET 4后安装IIS

安装.NET 4后安装3.0版本的WCF HTTP Activation Module

重新将asp.net注册到IIS即可,注意一定是4.0框架下的aspnet_regiis.exe /iru 不是2.0框架下的

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe /iru

即可

2,与Socket进行通信时注意端口在4502-4532之间,具体看看策略文件的配置,我因为这个端口问题耽误了一下午,最后才意识到。

3,silverlight的socket方法目前只是提供了客户端的发送和接收方法,如果想做P2P的应用,暂时没有找到解决方法,看到codeplex上有一个 Silverlightp2p的例子,但是代码没有能够运行成功,还请了解silverlightp2p通信的朋友留言相告。

4,silverlight开发中在用到timer时,需要检测控件的线程操作状态才能够赋值,例如




代码

if (this.textBox1.Dispatcher.CheckAccess())

{

this.textBox1.Text += strText + Environment.NewLine;

}

else

{

this.textBox1.Dispatcher.BeginInvoke(() => { this.textBox1.Text += strText + Environment.NewLine; });

}

5,在 Silverlight与WEB相结合时可能需要不同的页面调用不同的silverlight控件,我们可以在silverlight项目中app.xaml.cs中加入




代码

if (!e.InitParams.ContainsKey("InitPage"))

{

this.RootVisual = new RIA.Layout.Layout();

return;

}

Assembly assembly = Assembly.GetExecutingAssembly();

string rootName = String.Format("RIA.{0}", e.InitParams["InitPage"]);

UIElement rootVisual = assembly.CreateInstance(rootName) as UIElement;

this.RootVisual = rootVisual;

然后再具体的web页面中间加入

<param name="InitParams" value="InitPage=Test.Mytest" />

来动态调取 Silverlight 项目中的控件。

随时添加。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息