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

Different behaviour of simple script when compiled #1745

Open
johnnyontheweb opened this issue Oct 16, 2023 · 2 comments
Open

Different behaviour of simple script when compiled #1745

johnnyontheweb opened this issue Oct 16, 2023 · 2 comments

Comments

@johnnyontheweb
Copy link

johnnyontheweb commented Oct 16, 2023

Prerequisites

The issue tracker is used to report bugs and request new features, NOT to ask questions.

Questions should be posted in Discussions or to the users mailing list which can be accessed at
https://ironpython.groups.io/g/users.

  • [ Y ] Are you running the latest version?
  • [ Y ] Are you reporting to the correct repository?
  • [ Y ] Did you perform a cursory search?

Description

In loading a .NET dll, I get a SystemError that does not come out when compiling with ipyc. See code below.

Steps to Reproduce

Code used in file testIPY.py

import clr
# import my api
clr.AddReferenceToFileAndPath("myClass.dll")
import myClass
tt=myClass.API() # instance of my object
print(tt.version()) # return version
input("Press key to close...")
  1. if I run ipy testIPY.py I get:
Traceback (most recent call last):
  File "testIPY.py", line 6, in <module>
SystemError: L'inizializzatore di tipo di 'myInnerClass.innerClass' ha generato un'eccezione.
  1. if I compile with ipyc /main:testIPY.py /target:exe, I can run testIPY.exe flawlessly. Output is:
1.00000000000001
Press key to close...Error occurred: unknown encoding: cp850

Version Information

If you are using the ipy console program, provide output of executing ipy -VV. If it is a local build, provide also the git hash of the commit used to build IronPython. Additionally, provide the type of the operating system used.

ipy -VV
IronPython 3.4.1 (3.4.1.1000)
[.NETFramework,Version=v4.6.2 on .NET Framework 4.8.9181.0 (64-bit)]

Ufortunately I cannot share the DLL, which is obfuscated. Debug DLL does not exhibit the same problem.

@johnnyontheweb
Copy link
Author

I made other tests, unfortunately all unsuccessful:

  1. When libraries are not obfuscated, everything works

  2. The problem is related to the differences in IronPython code in loading .net dlls.l, because as told, the compiled scripts works fine, but .py script does not. I believe this should be corrected, as the same obduscated libraries load unfaulty in Pythonnet, and one should expect the same behaviour

  3. Since dlls are obfuscated, the only way possible to debug is to add these command line flags to ipy exe

ipy -X:ShowClrExceptions -X:ExceptionDetail testIPY.py

By doing this, I found out that a dependency dll cannot be found, which is also obfuscated.

  1. My dlls have a custom Assembly resolver, which may help in loading assemblies. Since the error described at point 3. happens in the constructor, it seems that ipy is the only responsible to find the assembly. I tried to have ipy.exe and its dependencies in the same folder of my dlls, and also to add folders to path. Nothing changed.

I hope this may help in finding a solution, the main problem to me is to assure that the same assembly loading mechanism has to be used both for compiled and non compiled scripts.

@johnnyontheweb
Copy link
Author

Anyone having the same problem?
I'm still seeking for a solution, but I believe the different behaviour of compiled and interpreted script is due to a bug in IPY - it seems Assembly loading mechanism is behaving differently...

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

1 participant