-----------http://dotnet.aspx.cc/article/ad00a2a8-4b01-4be0-b244-5c1c980e3fda/read.aspx
VS在编译时Silverlight 2的应用程序时,会先将cs等文件进行编译成dll,然后会调用Chiron.exe这个打包工具打包成.xap文件。也可以使用它进行动态语言无打包部署。Chiron.exe一般位于C:/Program Files/Microsoft SDKs/Silverlight/v2.0/Tools/Chiron文件夹下,.xap格式的文件其实就是一个zip格式的压缩包,如果将扩展名改为.zip,可以使用解压缩工具进行解压。解压后的文件可以使用Chiron这个工具再进行打包成.xap文件。 例如:将E:/Example1/Mengxianhui/ClientBin/SilverlightApplication1下的文件打包成SilverlightApplication1.xap,命令如下: Chiron.exe /d: E:/Example1/Mengxianhui/ClientBin/SilverlightApplication1 /x: SilverlightApplication1.xap
E:/SilverLight2Example/Example2/default.htm 其中: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>动态 Silverlight 测试页面</title> <style type="text/css"> html, body { height: 100%; overflow: auto; } body { padding: 0; margin: 0; } #silverlightControlHost { height: 100%; } </style> <script type="text/javascript"> function onSilverlightError(sender, args) { if (args.errorType == "InitializeError") { var errorDiv = document.getElementById("errorLocation"); if (errorDiv != null) errorDiv.innerHTML = args.errorType + "- " + args.errorMessage; } } </script> </head> <body> <div id='errorLocation' style="font-size: small;color: Gray;"></div> <div id="silverlightControlHost"> <object data="data:application/x-silverlight," type="application/x-silverlight-2-b1" width="100%" height="100%"> <param name="source" value="app.xap"/> <param name="onerror" value="onSilverlightError" /> <param name="background" value="white" /> <param name="initParams" value="debug=true,reportErrors=errorLocation" /> <param name="windowless" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=108182" style="text-decoration: none;"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none"/> </a> </object> <iframe style='visibility:hidden;height:0;width:0;border:0px'></iframe> </div> </body> </html> app.xaml: <UserControl xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="System.Windows.Controls.UserControl" x:Name="Page" Width="400" Height="300"> <Grid x:Name="LayoutRoot" Background="White"> <Canvas Canvas.Top="20"> <TextBlock Canvas.Top="10" Canvas.Left="20">请输入您的姓名: </TextBlock> <TextBox x:Name="UserInput" Width="200" Height="30" Canvas.Top="40" Canvas.Left="20"></TextBox> <TextBlock x:Name="Msg" Canvas.Top="90" Canvas.Left="20" Foreground="Navy" FontSize="48" ></TextBlock> </Canvas> </Grid> </UserControl> app.jsx: Import("System.Windows.Application") Import("System.Windows.Controls.*") Import("System.Windows.*") var xaml; function App() { xaml = Application.Current.LoadRootVisual(new UserControl(), "app.xaml") } App.prototype.start = function() { //注册事件处理器 xaml.UserInput.KeyUp += handler1; } function handler1(sender, args) { xaml.Msg.Text = "Hello," + xaml.UserInput.Text; } app = new App app.start() 则先切换到E:/SilverLight2Example/Example2文件夹,然后执行: E:/SilverLight2Example/Example2>"C:/Program Files/Microsoft SDKs/Silverlight/v2.0/Tools/Chiron/Chiron.exe" /w Chiron就会启动一个http的Web服务器,将E:/SilverLight2Example/Example2/作为网站的根目录,如图: 单击“default.htm”文件,出现下面的界面: 比较奇怪的是: Chiron的完整参数列表: 通用选项: /d[irectory]:<path> /n[ologo] /s[ilent] 动态语言选项: /z[ipdlr]:<file> /w[ebserver][:<port number>] /b[rowser] /r[efpath]:<path> /m[anifest] |
关键字:Silverlight 2 Silverlight 2学习教程 |