Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions 3 pythonnet/src/console/Console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@
</ItemGroup>
<ItemGroup>
<Content Include="python-clear.ico" />
<EmbeddedResource Include="$(PythonBuildDir)\Python.Runtime.dll">
<LogicalName>Python.Runtime.dll</LogicalName>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
27 changes: 26 additions & 1 deletion 27 pythonnet/src/console/pythonconsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// ==========================================================================

using System;
using System.Reflection;
using Python.Runtime;

namespace Python.Runtime {
Expand All @@ -27,6 +28,30 @@ public static int Main(string[] args) {
return i;
}

}
// Register a callback function to load embedded assmeblies.
// (Python.Runtime.dll is included as a resource)
private sealed class AssemblyLoader {
public AssemblyLoader() {
AppDomain.CurrentDomain.AssemblyResolve += (sender, args) => {
String resourceName = new AssemblyName(args.Name).Name + ".dll";

// looks for the assembly from the resources and load it
using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName)) {
if (stream != null) {
Byte[] assemblyData = new Byte[stream.Length];
stream.Read(assemblyData, 0, assemblyData.Length);
return Assembly.Load(assemblyData);
}
}

return null;
};
}
};

private static AssemblyLoader assemblyLoader = new AssemblyLoader();

};


}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.