Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException while creating IronPython engine in referenced project #1778

Open
martinmueller4voice opened this issue Feb 14, 2024 · 4 comments

Comments

@martinmueller4voice
Copy link

Description

When calling

var eng = IronPython.Hosting.Python.CreateEngine();

from inside a referenced project, a

NullReferenceException
   at IronPython.Runtime.Importer.ImportReflected(CodeContext context, String name)

will get thrown.

Continue during debugging in VS does work, though, and will create a usable engine nevertheless.

Steps to Reproduce

Create a Windows Forms Application and a library project.
Install the IronPython NuGet package in the library project and use the code above to create an engine from within the referenced assembly.

Running the code from within the library throws the NullReferenceException in Importer.ImportReflected().

Trying the exact same steps directly in the main application works without problems.

Version Information

  • .NET 4.8
  • Windows Forms application/library
  • IronPython 3.4.1 installed via NuGet
@slozier
Copy link
Contributor

slozier commented Feb 21, 2024

I haven't been able to reproduce the issue. Could you perhaps provide a working example that demonstrates the issue?

@martinmueller4voice
Copy link
Author

I've uploaded a test project to GitHub:
https://github.com/martinmueller4voice/IronPythonTest
Please let me know if you need anything else.

@slozier
Copy link
Contributor

slozier commented Feb 27, 2024

Thanks for the sample. It looks like Visual Studio is trying to be smart and isn't copying IronPython.Modules.dll to the IronPythonTest/bin/Debug folder which is what's causing the NullReferenceException.

@martinmueller4voice
Copy link
Author

Ah, of course!
The NullRefException disappears if I manually copy over all the missing assemblies (IronPython.Modules.dll, IdonPython.SQLite.dll and IronPython.Wpf.dll) to my output folder manually.

Could it be that the nuspec file is missing those references?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants