Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Addresses issue #261 with providing more detail information missing d…#298

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed

Conversation

fdanny
Copy link
Contributor

This addresses issue#261 to provide more information when there is a missing assembly dependency. The logic basically does the following

  1. After importing module check if an ImportError exception occured
  2. If it does load the assembly dependencies and try to load each one
  3. if I can't load that assembly I add to the list
  4. At the end I display the list of missing assemblies.

…missing dependencies with ImportError Exceptions
@den-run-ai
Copy link
Contributor

@fdanny can you please add some tests? i.e. you can look at test_import.py file.

@fdanny
Copy link
ContributorAuthor

@denfromufa Yup. I can do that. The way I tested it I created a dll that had a missing dependency. I made assure my ImportError Exception contained the specific missing dependency. Is this something that you were thinking?

@den-run-ai
Copy link
Contributor

den-run-ai commentedDec 2, 2016 via email

Yes, that's right!
On Thu, Dec 1, 2016, 4:35 PM fdanny ***@***.***> wrote: @denfromufa <https://github.com/denfromufa> Yup. I can do that. The way I tested it I created a dll that had a missing dependency. I made assure my ImportError Exception contained the specific missing dependency. Is this something that you were thinking? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#298 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AHgZ5YsE4jQuzGb5kQDIvm6IfkH2FZ7Uks5rD0vNgaJpZM4LB5fw> .

Copy link
Contributor

@den-run-aiden-run-ai left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you make TestDependencyAssembly.dll compile as part of project and remove its dependencies before import? Just including a binary without source code is not maintainable.

@fdanny
Copy link
ContributorAuthor

fdanny commentedDec 2, 2016
edited
Loading

@denfromufa Is there a location in the solution you want me to put this in TestDependencyAssembly? Is it okay just to check the solution as a reference and treat this dll as a resource. If there are any changes needed then the source code is included to build

Also why did my test failed on the Travis CI but passed AppVeyor? It has the following error
clr.AddReference(path_to_dll)
System.IO.FileNotFoundException: Unable to find assembly

@den-run-ai
Copy link
Contributor

You can just add a new project to solution. Otherwise just compile at
runtime - have a look at clrmagic.

That dll loading issue is pretty weird, please share the source code and
how you compiled it.

Here is repeatable issue using Mono C# REPL when using reflection, but not
when adding reference (LoadAssembly):

Mono C# Shell, type "help;" for helpEnter statements below.csharp>LoadAssembly("/home/dta/Documents/clrmagic/TestDependencyAssembly.dll")csharp> using System.Reflection;csharp> AssemblyAssembly AssemblyAlgorithmIdAttribute AssemblyCompanyAttributeAssemblyConfigurationAttribute AssemblyContentTypeAssemblyCopyrightAttribute AssemblyCultureAttributeAssemblyDefaultAliasAttribute AssemblyDelaySignAttributeAssemblyDescriptionAttribute AssemblyFileVersionAttributeAssemblyFlagsAttribute AssemblyInformationalVersionAttributeAssemblyKeyFileAttribute AssemblyKeyNameAttribute AssemblyLoadEventArgsAssemblyLoadEventHandler AssemblyMetadataAttribute AssemblyNameAssemblyNameFlags AssemblyNameProxy AssemblyProductAttributeAssemblySignatureKeyAttribute AssemblyTitleAttributeAssemblyTrademarkAttribute AssemblyVersionAttributecsharp> Assembly testdll =Assembly.Load("/home/dta/Documents/clrmagic/TestDependencyAssembly.dll")System.IO.FileNotFoundException: Could not load file or assembly'/home/dta/Documents/clrmagic/TestDependencyAssembly.dll' or one of itsdependenciesFile name: '/home/dta/Documents/clrmagic/TestDependencyAssembly.dll'  at System.AppDomain.Load (System.String assemblyString,System.Security.Policy.Evidence assemblySecurity, Boolean refonly)<0x7f976292e650 + 0x000a2> in <filename unknown>:0  at System.AppDomain.Load (System.String assemblyString) <0x7f976292e610 +0x00015> in <filename unknown>:0  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)  at System.Reflection.Assembly.Load (System.String assemblyString)<0x7f97629a1980 + 0x0001b> in <filename unknown>:0  at <InteractiveExpressionClass>.Host (System.Object& $retval) <0x41b71120+ 0x0001a> in <filename unknown>:0  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object&result, System.Boolean& result_set) <0x41ae4d30 + 0x000dd> in <filenameunknown>:0  at Mono.CSharpShell.Evaluate (System.String input) <0x41ae4c30 + 0x00053>in <filename unknown>:0csharp> Assembly testdll =Assembly.Load("/home/dta/Documents/clrmagic/TestDependencyAssembly")System.IO.FileNotFoundException: Could not load file or assembly'/home/dta/Documents/clrmagic/TestDependencyAssembly' or one of itsdependenciesFile name: '/home/dta/Documents/clrmagic/TestDependencyAssembly'  at System.AppDomain.Load (System.String assemblyString,System.Security.Policy.Evidence assemblySecurity, Boolean refonly)<0x7f976292e650 + 0x000a2> in <filename unknown>:0  at System.AppDomain.Load (System.String assemblyString) <0x7f976292e610 +0x00015> in <filename unknown>:0  at (wrapper remoting-invoke-with-check) System.AppDomain:Load (string)  at System.Reflection.Assembly.Load (System.String assemblyString)<0x7f97629a1980 + 0x0001b> in <filename unknown>:0  at <InteractiveExpressionClass>.Host (System.Object& $retval) <0x41b71690+ 0x0001a> in <filename unknown>:0  at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object&result, System.Boolean& result_set) <0x41ae4d30 + 0x000dd> in <filenameunknown>:0  at Mono.CSharpShell.Evaluate (System.String input) <0x41ae4c30 + 0x00053>in <filename unknown>:0csharp>

@fdanny
Copy link
ContributorAuthor

fdanny commentedDec 6, 2016
edited
Loading

@denfromufa I ran into an issue trying to resolve this. My method will only work if the namespace imported is the same as the assembly name. I have no way of mapping a namespace to an assembly.

It looks like whenclr.AddReference is called anAssemblyLoadEventHandle is initiated when an assembly is loaded and eventually goes into theAssemblyManager::ScanAssembly. It looks like this method parses out the namespaces and loads it intoConcurrentDictionary.

The issue in ScanAssembly is when
types = assembly.GetTypes();

This doesn't work since it doesn't have all the dependencies so we don't get the namespace mapping.

I'm thinking the following maybe

  1. Raise an exceptionclr.AddReference if not all dependencies are present
  2. On a failure onassembly.GetTypes() Read the assembly in Stream and parse the out the information sort of like Mono Cecil.

What do you think???

@den-run-ai
Copy link
Contributor

@fdanny maybe it is ok without namespace in the error message? but i'm surprised that it is hard to track it down.

@vmuriart
Copy link
Contributor

@denfromufa@fdanny is there any help needed for thispull request ?

@den-run-ai
Copy link
Contributor

@fdanny needs help tracking down the namespace name in the Exception traceback

@filmorfilmor added this to the2.4.0 milestoneAug 30, 2018
@filmorfilmor modified the milestones:2.4.0,2.5.0May 8, 2019
lostmsu added a commit to losttech/pythonnet that referenced this pull requestMar 4, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestMar 4, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
@lostmsulostmsu removed this from the2.5.0 milestoneApr 23, 2020
lostmsu added a commit to losttech/pythonnet that referenced this pull requestApr 23, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestApr 27, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestMay 13, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestAug 18, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestAug 18, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestAug 18, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestAug 18, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit to losttech/pythonnet that referenced this pull requestAug 18, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addressespythonnet#261It is an alternative topythonnet#298
lostmsu added a commit that referenced this pull requestAug 19, 2020
…ore info when CLR assemblies are failed to be loaded1. When trying to implicitly load assemblies, and that fails NOT because an assembly is missing, but because loading failed for some reason, emit Python warning.2. When trying to import a module in our import hook, if the module name is an assembly name, and we fail to load it, and Python also fails to find a module with the same name, add the exceptions we got during the attempt to load it into __cause__ of the final ImportErrorBREAKING: clr.AddReference will now throw exceptions besides FileNotFoundException.Additional: a few uses of BorrowedReferenceThis addresses#261It is an alternative to#298
@filmor
Copy link
Member

The alternative PR#1076 was merged a while ago.

@filmorfilmor closed thisFeb 15, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@den-run-aiden-run-aiden-run-ai left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@fdanny@den-run-ai@vmuriart@filmor@lostmsu

[8]ページ先頭

©2009-2025 Movatter.jp