Giter Site home page Giter Site logo

Comments (4)

chucklu avatar chucklu commented on June 3, 2024

We need to use another method to load assembly

 internal static Assembly GetAssemblyByFile(string fileName)
        {
            var assembly = Assembly.ReflectionOnlyLoadFrom(fileName);
            if (assembly == null)
            {
                throw new FileNotFoundException(fileName);
            }

            return assembly;
        }

from dependentchecker.

chucklu avatar chucklu commented on June 3, 2024

2021-09-29 17:37:46.408 +08:00 [ERR] Load assembly [LISA.Batch.CustomInstaller, Version=6.3.0.25091, Culture=neutral, PublicKeyToken=null] failed, System.BadImageFormatException: Could not load file or assembly 'LISA.Batch.CustomInstaller, Version=6.3.0.25091, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
File name: 'LISA.Batch.CustomInstaller, Version=6.3.0.25091, Culture=neutral, PublicKeyToken=null'
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
at DependentChecker.Helper.AssemblyHelper.LoadAssembly(AssemblyName assemblyName) in C:\workspace\GitHub\ChuckLu\chucklu\DependentChecker\DependentChecker\Helper\AssemblyHelper.cs:line 46

=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:/workspace/Software/UK/UK.Batch/LISA.Batch.CustomInstaller.dll
LOG: Appbase = file:///C:/workspace/GitHub/ChuckLu/chucklu/DependentChecker/DependentChecker/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\workspace\GitHub\ChuckLu\chucklu\DependentChecker\DependentChecker\bin\Debug\DependentChecker.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Attempting download of new URL file:///C:/workspace/Software/UK/UK.Batch/LISA.Batch.CustomInstaller.dll.
ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

from dependentchecker.

chucklu avatar chucklu commented on June 3, 2024

If I switch to ReflectionOnlyLoad(this method without from), it will throw another exception fro another file
2021-09-29 18:21:50.120 +08:00 [ERR] System.IO.FileLoadException: Could not load file or assembly 'C:\workspace\Software\UK\UK.Batch\RDC.Controls.Calendar.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
File name: 'C:\workspace\Software\UK\UK.Batch\Accor.RDC.Controls.Calendar.dll'
at System.Reflection.AssemblyName.nInit(RuntimeAssembly& assembly, Boolean forIntrospection, Boolean raiseResolveEvent)
at System.Reflection.RuntimeAssembly.CreateAssemblyName(String assemblyString, Boolean forIntrospection, RuntimeAssembly& assemblyFromResolveEvent)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.ReflectionOnlyLoad(String assemblyString)
at DependentChecker.MainWindow.FindDependent(String dependencyPath) in C:\workspace\GitHub\ChuckLu\chucklu\DependentChecker\DependentChecker\MainWindow.xaml.cs:line 137
at DependentChecker.MainWindow.DependencyChoose_Click(Object sender, RoutedEventArgs e) in C:\workspace\GitHub\ChuckLu\chucklu\DependentChecker\DependentChecker\MainWindow.xaml.cs:line 39

from dependentchecker.

chucklu avatar chucklu commented on June 3, 2024

ReflectionOnlyLoadFrom works fine.

from dependentchecker.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.