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

Version 0.7 works with "Microsoft.Dynamics.BusinessConnectorNet.dll" but 0.8 does not (win10 64bit with py3.6 32bit) #23

Closed
lovetheguitar opened this issue Apr 8, 2021 · 3 comments

Comments

@lovetheguitar
Copy link

Hey,

thanks for the nice library. I just had to migrate my setup to a new laptop and after some fiddling around I found out that somehow only the older 0.7 version works "out of the box".

Output with version 0.7 on python 3.6 32bit:

from msl.loadlib import LoadLibrary
net = LoadLibrary("Microsoft.Dynamics.BusinessConnectorNet", "net")
Traceback (most recent call last):
File "C:\Python36\lib\site-packages\msl\loadlib\load_library.py", line 230, in init
self._assembly = clr.System.Reflection.Assembly.LoadFile(self._path)
System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

at System.Reflection.RuntimeAssembly.nLoadFile(String path, Evidence evidence)
at System.Reflection.Assembly.LoadFile(String path)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "C:\Python36\lib\site-packages\msl\loadlib\load_library.py", line 242, in init
raise IOError(msg)
OSError: The library appears to be from a .NET Framework version < 4.0.
The useLegacyV2RuntimeActivationPolicy property was added to C:\Python36\python.exe.config
to fix the "System.IO.FileLoadException: Mixed mode assembly..." error.
Rerun the script, or shutdown and restart the interactive console, to see
if Python can now load the .NET library.

When doing the same thing again it now "just works".

With version 0.8 although, I only always got:

System.IO.FileNotFoundException: Unable to find assembly 'Microsoft.Dynamics.BusinessConnectorNet'.
at Python.Runtime.CLRModule.AddReference(String name)

So apparently no helpful "useLegacyV2RuntimeActivationPolicy property was added to C:\Python36\python.exe.config" magic was done.

Sorry if this is expected behaviour now.

BR.

@lovetheguitar lovetheguitar changed the title Version 0.7 works with "Microsoft.Dynamics.BusinessConnectorNet.dll" but 0.8 does not Version 0.7 works with "Microsoft.Dynamics.BusinessConnectorNet.dll" but 0.8 does not (with py3.6 32bit) Apr 8, 2021
@lovetheguitar lovetheguitar changed the title Version 0.7 works with "Microsoft.Dynamics.BusinessConnectorNet.dll" but 0.8 does not (with py3.6 32bit) Version 0.7 works with "Microsoft.Dynamics.BusinessConnectorNet.dll" but 0.8 does not (win10 64bit with py3.6 32bit) Apr 8, 2021
@jborbely
Copy link
Contributor

Thanks for raising this issue. It is a bug and not a feature in version 0.8.

I have pushed a potential fix. Could you please verify that it "just works" after updating your version from the master branch?

Could you first move the C:\Python36\python.exe.config file to another folder before verifying so that the first run raises the OSError: The library appears to be from a .NET Framework version < 4.0 message and then the library loads properly on the second run.

To update from the master branch you can run:

pip install --upgrade https://github.com/MSLNZ/msl-loadlib/archive/master.tar.gz

@lovetheguitar
Copy link
Author

Thanks for your prompt reply and immediate fix. :)
Positive, after following your steps, I could observe a similar behavior to version 0.7.

@jborbely
Copy link
Contributor

Great. Thank you for verifying.

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