-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApplication.xaml.vb
29 lines (20 loc) · 1.08 KB
/
Application.xaml.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
Imports System.Reflection
Imports System.IO
Class Application
' Application-level events, such as Startup, Exit, and DispatcherUnhandledException
' can be handled in this file.
Private Sub Application_Startup(sender As Object, e As StartupEventArgs)
AddHandler AppDomain.CurrentDomain.AssemblyResolve, New ResolveEventHandler(AddressOf ResolveAssembly)
End Sub
'No Need To Copy DLLs To Startup Path (New In Version 10.6)
Private Shared Function ResolveAssembly(sender As Object, Args As ResolveEventArgs) As Assembly
Dim ParentAssembly As Assembly = Assembly.GetExecutingAssembly()
Dim Name = Args.Name.Substring(0, Args.Name.IndexOf(","c)) & ".dll"
Dim ResourceName = ParentAssembly.GetManifestResourceNames().First(Function(s) s.EndsWith(Name))
Using Stream As Stream = ParentAssembly.GetManifestResourceStream(ResourceName)
Dim Block As Byte() = New Byte(Stream.Length - 1) {}
Stream.Read(Block, 0, Block.Length)
Return Assembly.Load(Block)
End Using
End Function
End Class