加载资源程序集但不“锁定”文件
我在加载包含资源 xaml 的程序集时遇到问题。 问题是我不允许“锁定”该文件,因为更新可能会在以后替换它。
首先我像这样加载它:
Uri uriProperties;
ResourceDictionary xResources;
uriProperties = new Uri("/xResources;component/xResources.xaml", UriKind.Relative);
xResources = Application.LoadComponent(uriProperties) as ResourceDictionary;
效果很好。文件未锁定。
现在我遇到了另一个问题,我必须将其放入另一个程序集中。使用相对 Uri 加载它不再起作用,我现在有了完整路径。
我尝试过:
Assembly.LoadFrom(xPath + @"/xResources.dll");
xResources = new ResourceDictionary();
xResources.Source = new Uri(@"pack://application:,,,/xResources;component/xResources.xaml");
也适用于应用程序。但它会锁定文件。
如何加载程序集并使用完整路径获取资源字典但不锁定文件?
如果有一个不使用卷影复制或更改内容路径等的解决方案,那就太好了......
I got a problem loading my assembly containing a resource xaml.
The problem is I am not allowed to "lock" the file, because an update may replace it later.
First I loaded it like this:
Uri uriProperties;
ResourceDictionary xResources;
uriProperties = new Uri("/xResources;component/xResources.xaml", UriKind.Relative);
xResources = Application.LoadComponent(uriProperties) as ResourceDictionary;
That worked fine. File is not locked.
Now I got another problem I had to put it into an other assembly. Loading it with the relative Uri does not work anymore, I have a full path now.
I tried:
Assembly.LoadFrom(xPath + @"/xResources.dll");
xResources = new ResourceDictionary();
xResources.Source = new Uri(@"pack://application:,,,/xResources;component/xResources.xaml");
also works in the application. But it locks the file.
How do I load the assembly and get my resourcedictionary with using a full path but without locking the file?
Would be nice if there was a solution without using shadow copying or changing content paths etc...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定这是否能解决您的问题,但值得一试:
Not sure if this will solve your problem, but it's worth the shot: