如何将XAP文件的两个dll的StreamResourceInfo加载到程序集中? [英] How to load StreamResourceInfo of two dlls of a XAP file into a assembly?
本文介绍了如何将XAP文件的两个dll的StreamResourceInfo加载到程序集中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
假设XAP包含5个dll.我们可以将一个dll的StreamResourceInfo加载到如下所示的程序集中.
Suppose if a XAP contains 5 dlls. We can load one dll''s StreamResourceInfo into a assembly like below.
Dim appManifest As String = New System.IO.StreamReader(Application.GetResourceStream(
New System.Windows.Resources.StreamResourceInfo(e.Result, Nothing),
New Uri("AppManifest.xaml", UriKind.Relative)).Stream).ReadToEnd()
Dim doc As XDocument = XDocument.Parse(appManifest)
Dim nspace As XNamespace = doc.Root.Name.Namespace
// parts contains 5 dlls.
Dim parts As List(Of XElement) = (From assemblyParts In doc.Descendants(nspace + "AssemblyPart") Select assemblyParts).ToList()
Dim asm As System.Reflection.Assembly = Nothing
For Each xe As XElement In parts
Dim source As String = xe.Attribute("Source").Value
Dim asmPart As New AssemblyPart()
Dim streamInfo As StreamResourceInfo = Application.GetResourceStream(
New StreamResourceInfo(e.Result, "application/binary"),
New Uri(source, UriKind.Relative))
If source = "WebPortalUI.dll" Then
asm = asmPart.Load(streamInfo.Stream)
Else
asmPart.Load(streamInfo.Stream)
End If
Next
我想将XAP文件的两个dll StreamResourceInfo加载到程序集中.我该怎么做?
I want to load two dlls StreamResourceInfo of a XAP file into a assembly. How can I do this?
推荐答案
您可以创建一个包含所有资源的单个程序集,并在需要时在另一个程序集中加载一个程序集.这就是我要做的方式.
You could create a single assembly with all of the resources in it, and load that one assembly whenever you need it in the other assemblies. That''s the way I''d do it.
这篇关于如何将XAP文件的两个dll的StreamResourceInfo加载到程序集中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文