question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not load file or assembly 'Python.Runtime, Version=2.4.0.0...

See original GitHub issue

Environment

  • Pythonnet version: 2.4.00
  • Python version: 2.7.13
  • Operating System: Windows 7

Details

  • Describe what you were trying to get done.

I have used pip install git+https://github.com/pythonnet/pythonnet to install latest python net.

I’ve created a .NET visual studio 2015 project to make calls to Python. I reference the Python.Runtime.dll file in the project. When I let it get copied to the binary directory of my project calls to CPython work fine.

Now, I don’t want to bundle the DLL with my application. As I understand, different versions work with different versions of CPython. I would like to load Python.Runtime.dll from Lib\site-packages so I get version appropriate for version of Python installed on the system. I change properties of the PythonRuntime.dll reference to NOT copy the DLL to bin directory. Now I get the error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in PyRunner.exe
Additional information: Could not load file or assembly 'Python.Runtime, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

This minimal program causes the error.

using Python.Runtime;

namespace PyRunner
{
	class ErrorExample
	{
		static void Main(string[] args)
		{
			PythonEngine.Initialize();
		}
	}
}

I’ve tracked down other issues related to this but none seem to simply be that the DLL is not found.

When I try to install the assembly in the GAC I get

>gacutil /i Lib\site-packages\Python.Runtime.dll
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Failure adding assembly to the cache: Attempt to install an assembly without a strong name

Thanks

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
denfromufacommented, Apr 27, 2018

@tomunger use this tool to strongly sign Python.Runtime.DLL with a key, e.g. the one provided with pythonnet:

https://github.com/brutaldev/StrongNameSigner

0reactions
dmitriysecommented, Jan 12, 2019

Sorry, this branch is not in GH now. And probably I have already delete it from my working computer.

I have spent around 4 working days to carefully add indirection into runtime.cs C-Calls and all other wrapping code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio 2017 - Could not load file or assembly ...
I encounter this issue recently and I tried many things mentioned in this thread and others. I added package reference for "System.Runtime" by ......
Read more >
How to resolve “Could not load file or assembly … or one of its ...
When we use multiple versions of same assembly, it is more likely to encounter this runtime exception. It is easy to resolve provided...
Read more >
Could Not Load File Or Assembly 'System.Runtime, ...
Right-click on the project and select Properties. · In the Properties window, select the Application tab. · In the Target Framework dropdown, ...
Read more >
Cannot load file or assembly 'System.Runtime'
When I try to run the application, I get this error: Could not load file or assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, ...
Read more >
.NET Framework app fails with "Could not load file or ...
Executing a .NET Framework 4.6.1 console app that references a .NET Standard 2.0 assembly fails with Unhandled Exception: System.IO.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found