Skip to content

Fixed FileLoadException when trying clr.AddReference('/full/path.dll') #1573

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

Merged
merged 1 commit into from
Sep 28, 2021

Conversation

lostmsu
Copy link
Member

@lostmsu lostmsu commented Sep 27, 2021

What does this implement/fix? Explain your changes.

Before trying to load an assembly by its full path we were trying to call Assembly.Load on it. Assembly.Load interprets its argument as a valid AssemblyName. However full paths are not valid assembly names, so that call would throw FileLoadException, which we did not handle.

The fix is to separately try to parse input string into an AssemblyName and only try Assembly.Load when it succeeds.

Does this close any currently open issues?

9d5f579#commitcomment-57061082

Any other comments?

Related: #1514

@lostmsu lostmsu force-pushed the add-ref-fullpath branch 5 times, most recently from 2c33d22 to ebb5772 Compare September 27, 2021 23:22
…/path.dll')

Before trying to load an assembly by its full path we were trying to call `Assembly.Load` on it. `Assembly.Load` interprets its argument as a valid `AssemblyName`. However full paths are not valid assembly names, so that call would throw `FileLoadException`, which we did not handle.

reported in pythonnet@9d5f579#commitcomment-57061082

Related: pythonnet#1514
@lostmsu lostmsu merged commit fc989d5 into pythonnet:master Sep 28, 2021
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

Successfully merging this pull request may close these issues.

1 participant