简体   繁体   English

如何在Silverlight代码中确定运行Silverlight实例的位置?

[英]How can I determine in silverlight code where the silverlight instance is running?

I have a silverlight app. 我有一个Silverlight应用程序。

When I develop I have it pick up its data from a local URL : 当我进行开发时,我会从本地URL中获取其数据

http://localhost/theapp/data/ ... http:// localhost / theapp / data / ...

however, when it is online , I want it to pick up its data from an online URL : 但是,当它处于联机状态时 ,我希望它从联机URL中获取其数据

http://www.tanguay.info/ ... http://www.tanguay.info/ ...

Currently I have a variable which I switch before I compile and upload: 目前,我有一个在编译和上传之前要切换的变量

bool silverlightAppIsLive = true;

which I use to determine whether or not to get data from the first or second URL above. 我用它来确定是否从上面的第一个或第二个URL中获取数据。

Is there a way for me to determine this automatically in code without setting the variable manually? 有没有一种方法可以自动确定代码中的代码而无需手动设置变量?

Can you not use this which will give you the location the silverlight control was loaded from and thus determine if you need to load from the internet or localhost? 您是否可以使用方法为您提供Silverlight控件的加载位置,从而确定是否需要从Internet或本地主机加载? This assumes obviously you are hosting the control in different places for development and for live deployment. 显然,这假定您将控件托管在不同的位置以进行开发和实时部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 确定代码是否在Silverlight中运行的编程方式? - Programmatic way to determine if code is running in Silverlight? 我如何在Silverlight中确定是否是用户更改了ComboBox? - How can I in Silverlight determine if it is the user that changed a ComboBox? 在哪里可以找到Silverlight的自动完成文本框代码示例? - Where can I find an AutoComplete TextBox code sample for Silverlight? 确定是否可以安装Silverlight - Determine if Silverlight CAN be installed 如何在Silverlight的“阶段”中添加UserControl的实例? - How can I add an instance of an UserControl to the “stage” in Silverlight? 在哪里可以找到Silverlight 5的“ Silverlight Developer Runtime”? - Where can I find the “Silverlight Developer Runtime” for Silverlight 5? 我在哪里可以获得Silverlight 4的“Silverlight Developer Runtime”? - Where can I get the “Silverlight Developer Runtime” for Silverlight 4? 如何检测运行Silverlight应用程序的浏览器? - How can I detect what browser my Silverlight application is running in? Silverlight如何确定程序集是“Silverlight”? - How does Silverlight determine an assembly is “Silverlight”? 从服务器上后面(aspx.cs)的asp.net代码如何确定客户端上是否安装了Silverlight? - From asp.net code behind (aspx.cs) on the server how can I determine if Silverlight is installed on the client?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM