File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 192192 </ItemGroup >
193193 <ItemGroup >
194194 <Content Include =" python-clear.ico" />
195+ <EmbeddedResource Include =" $(PythonBuildDir)\Python.Runtime.dll" >
196+ <LogicalName >Python.Runtime.dll</LogicalName >
197+ </EmbeddedResource >
195198 </ItemGroup >
196199 <ItemGroup >
197200 <None Include =" app.config" />
Original file line number Diff line number Diff line change 88// ==========================================================================
99
1010using System ;
11+ using System . Reflection ;
1112using Python . Runtime ;
1213
1314namespace Python . Runtime {
@@ -27,6 +28,30 @@ public static int Main(string[] args) {
2728 return i ;
2829 }
2930
30- }
31+ // Register a callback function to load embedded assmeblies.
32+ // (Python.Runtime.dll is included as a resource)
33+ private sealed class AssemblyLoader {
34+ public AssemblyLoader ( ) {
35+ AppDomain . CurrentDomain . AssemblyResolve += ( sender , args ) => {
36+ String resourceName = new AssemblyName ( args . Name ) . Name + ".dll" ;
37+
38+ // looks for the assembly from the resources and load it
39+ using ( var stream = Assembly . GetExecutingAssembly ( ) . GetManifestResourceStream ( resourceName ) ) {
40+ if ( stream != null ) {
41+ Byte [ ] assemblyData = new Byte [ stream . Length ] ;
42+ stream . Read ( assemblyData , 0 , assemblyData . Length ) ;
43+ return Assembly . Load ( assemblyData ) ;
44+ }
45+ }
46+
47+ return null ;
48+ } ;
49+ }
50+ } ;
51+
52+ private static AssemblyLoader assemblyLoader = new AssemblyLoader ( ) ;
53+
54+ } ;
55+
3156
3257}
You can’t perform that action at this time.
0 commit comments