Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

embed Python.Runtime.dll in nPython#38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tonyroberts merged 1 commit intopythonnet:developfromtonyroberts:develop
Apr 10, 2014
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionspythonnet/src/console/Console.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionpythonnet/src/console/pythonconsole.cs
View file
Open in desktop
Original file line numberDiff line numberDiff 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();

};


}

[8]ページ先頭

©2009-2025 Movatter.jp