来自WPF中不同应用程序的图像源 [英] Image Source from a different application in WPF

查看:88
本文介绍了来自WPF中不同应用程序的图像源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从不同的Web应用程序路径动态分配Image Source。



我试过以下代码



ImageSourceConverter imgConv = new ImageSourceConverter();

string path =pack:// application:http://upload.wikimedia.org/wikipedia/commons/0/04/Sun_in_the_sky。 jpg;

ImageSource imgSrc =(ImageSource)imgConv.ConvertFromString(path);

image1.Source = imgSrc;



请帮助我。

I want to assign Image Source dynamically from a different web application path.

I have tried following code

ImageSourceConverter imgConv = new ImageSourceConverter();
string path = "pack://application:http://upload.wikimedia.org/wikipedia/commons/0/04/Sun_in_the_sky.jpg";
ImageSource imgSrc = (ImageSource)imgConv.ConvertFromString(path);
image1.Source = imgSrc;

Please help me in this.

推荐答案

不,不,应用程序是不同的进程(即使它是同一个应用程序再次启动),以及进程很好地隔离,它们在不同的地址空间中运行。所以,你不能做这样的事情。相反,您应该检查您的体系结构。



例如,您可以将共享程序集用作为两个应用程序提供映像的库。但是,在这种情况下,您将在两个不同的地址空间中将两个不同的同一文件实例加载到内存中,那么呢?作为回报,它将起作用...... :-)



另外,如果你真的想要分开应用程序,请批判性思考。对我来说,这种情况往往非常有效,总是看起来很可疑。



-SA
No, no, applications are different processes (even it this is the same application started again), and the processes are well isolated, they run in separate address spaces. So, you cannot do such things. Instead, you should review your architecture.

For example, you can have shared assembly used as a library supplying images for both applications. In this case, though, you will have two different instances of the same file loaded in memory in two different address spaces, so what? in return, it will work… :-)

Also, think critically if you really want to separate applications. To me, such cases, often quite valid, always look suspicious.

—SA


这篇关于来自WPF中不同应用程序的图像源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆