使用 Silverlight 启动本地应用程序
我想知道是否有任何方法可以使用 silverlight 启动本地应用程序。我在使用 IE 8 中嵌入的用户控件执行此操作时遇到一些安全问题,因此我想将其转换为 silverlight 应用程序。这个小问题阻止了我继续使用 silverlight,所以如果有任何建议,我将不胜感激。
预先感谢..
卡洛斯。
I would like to know if there is any way to launch a local application with silverlight. I'm having some security problems doing this with a user control embedded in IE 8, so I would like to convert this into silverlight app. This little issue is stopping me to go forward with silverlight, so if any suggestion, I would appreciate to hear it.
Thanks in advance..
Carlos.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
这在理论上是可能的,在 SL4 中使用 COM 互操作与 Silverlight OOB,但您仍然会遇到相同的安全问题,此外还会添加一些部署问题。
为了直接从 IE 中执行此操作,您需要创建一个以适当的安全权限安装的加载项。任何“自动”模型都会违反标准的 IE 安全策略,因此没有直接的方法从浏览器->本地系统获取。
This will be, theoretically possible, using COM interop with Silverlight OOB in SL4, but you will still have the same security issues, and in addition, add some deployment issues.
In order to do this directly from within IE, you'll need to make an add-in that gets installed with proper security permissions. Any "automatic" model for this would violate the standard IE security policies, so there is no direct means of getting from browser->local system.
这将使 Silverlight 安全模型完全失效。所以,祝你好运。很确定你做不到。这就是官方所说的“坏事”。
我从侏罗纪公园学到的东西:仅仅因为你可以做某事并不意味着你应该做某事。
this would totally invalidate Silverlight security model. So, good luck with that. Pretty sure you can not do it. This is what officially is known as a "Bad Thing."
Things I learned from Jurassic Park: Just because you CAN do something doesn't mean you SHOULD do something.
使用 Silverlight 4 绝对有可能获得“浏览器外”支持。但是为了访问“主机”计算机上的应用程序,您需要做的是验证 SL4 应用程序是否可信。
这将涉及获得证书。这可以从 CA(或类似的 Internet 应用程序)获得,或者您可以生成自己的证书以供 Intranet 使用,并让用户简单地安装它或通过另一个自动化系统管理样式流程安装它。
最重要的是,当 SL4 应用程序运行 OOB 并且受信任时,它可以访问主机上的任何内容;到某一点。
即使您可以访问文件等,您仍然无法直接调用应用程序。除非它作为 COM 对象安装。
因此,您需要做的是使用“脚本”主机 COM 对象调用应用程序。您创建对脚本主机的引用,然后只需传入将调用应用程序的命令(如果您愿意,还可以传递参数)。
嘿,很快,你打破了墙壁:-)
应该注意的是,用户仍然只能在他们当前允许的计算机上运行应用程序。因此,您将无法对控制权有限的用户调用管理工具。
详情请参阅此处
http://msdn.microsoft.com/en-us/库/dd550721(VS.95).aspx
It is absolutely possible to get "Out of Browser" support using Silverlight 4. But what you need to do in order to access applications on the "Host" machine is the certify the SL4 application as being trusted.
This will involve getting a certificate for it. This could be obtained from CA (or similar for Internet applications) OR you could generate your own certificate for Intranet use and have the users simply install it or have it installed via another automated sys admin style process.
The bottom line is that when the SL4 application is running OOB AND it is trusted, it can access anything on the host machine; to a point.
Even though you can have file access and so forth, you still cannot call the application directly. That is unless it's installed as a COM object.
So what you will need to do is invoke the application using the "script" host COM object. You create a reference to the Script host and then simply pass in the command (and parameters if you like) that would invoke the application.
Hey presto, you broke the wall :-)
It should be noted that the use will still only be able to run the applications on their machine that they are currently allowed to. So you won't be able to invoke Admin tools on a user with limited control.
See here for details
http://msdn.microsoft.com/en-us/library/dd550721(VS.95).aspx
在我看来,您应该提出有关您已有的用户控件的开发的问题。最终,无论您使用什么技术,您都需要让用户手动选择加入。当由浏览器托管时,Silverlight 被设计为生活在良好且安全的沙箱中,无法逃脱。在这种情况下,这不是您问题的答案。
It seems to me that you ought to post a question about the developement of the user control you already have. Ultimately no matter what technology you use you will need to get the user to opt-in manually. Silverlight when hosted by a browser is designed to live in nice and secure sandbox that it can't get out of. It isn't the answer to your problem in this case.
您的 Silverlight 应用程序应该是受信任的应用程序,因为它在浏览器上运行。
如果要在本地计算机中启动应用程序,请使用以下代码:
使用命名空间
System.Runtime.InteropServices.Automation
Your Silverlight application should be a trusted application because it runs on a browser.
If you want to launch an application in your local machine use the below code:
Use the namespace
System.Runtime.InteropServices.Automation