| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,6 +192,9 @@ | |||
| 192 | 192 | </ItemGroup> | |
| 193 | 193 | <ItemGroup> | |
| 194 | 194 | <Content Include="python-clear.ico" /> | |
| 195 | + <EmbeddedResource Include="$(PythonBuildDir)\Python.Runtime.dll"> | ||
| 196 | + <LogicalName>Python.Runtime.dll</LogicalName> | ||
| 197 | + </EmbeddedResource> | ||
| 195 | 198 | </ItemGroup> | |
| 196 | 199 | <ItemGroup> | |
| 197 | 200 | <None Include="app.config" /> | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ | |||
| 8 | 8 | // ========================================================================== | |
| 9 | 9 | ||
| 10 | 10 | using System; | |
| 11 | + using System.Reflection; | ||
| 11 | 12 | using Python.Runtime; | |
| 12 | 13 | ||
| 13 | 14 | namespace Python.Runtime { | |
@@ -27,6 +28,30 @@ public static int Main(string[] args) { | |||
| 27 | 28 | return i; | |
| 28 | 29 | } | |
| 29 | 30 | ||
| 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 | + | ||
| 31 | 56 | ||
| 32 | 57 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments