c# - 如何获取用于启动 XBAP 的 URL?

标签 c# wpf xbap

如果有人从 http://myserver/folder/application.xbap 启动我的 xbap,我想获取 http://myserver/folder/ 部分来自应用程序中的 url。

我该怎么做?

我试过:

  • System.IO.Directory.GetCurrentDirectory()
  • System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName)
  • Environment.CurrentDirectory
  • System.Reflection.Assembly.GetExecutingAssembly().Location
  • AppDomain.CurrentDomain.BaseDirectory
  • System.Windows.Application.Current.StartupUri.AbsolutePath
  • System.Environment.GetCommandLineArgs()[0]
  • System.Deployment.Application.ApplicationDeployment.CurrentDeployment.DataDirectory

它们都返回 xbap 下载并运行的我机器上的本地位置,或者执行程序集的位置,例如 C:\Windows\SysWOW64

如何从应用程序本身访问用于启动 xbap 应用程序的 URL?

最佳答案

我相信是 BrowserInteropHelper.Source :

Gets the uniform resource identifier (URI) for the location from which a XAML browser application (XBAP) application was launched.

关于c# - 如何获取用于启动 XBAP 的 URL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13708594/

相关文章:

c# - 动态 T 的通用方法

wpf - 应用 LayoutTransform 与 RenderTransform 对性能的影响?

javascript - 如何在嵌入 WinForm 的 WebBrowser 控件中启用 JavaScript,而 WinForm 又嵌入 XBAP 页面?

c# - 如何在 XBAP 应用程序中使用 BinaryFormatter 反序列化流?

c# - 如何使用 "is"来测试类型是否支持 IComparable?

c# - 如何在Swashbuckle中添加API描述?

c# - C# 中私有(private)构造函数的需求是什么?

wpf - TemplatePart发现

wpf - ComboBox ItemTemplate 仅在下拉列表中工作

c# - 如何在 XBAP 或 ClickOnce 应用程序中获取引荐来源网址?