COM assemblies

Issue #6 new
Javier García Magna created an issue

Hi

I think codecop tries to load and examine all the DLLs in the same folder where the EXE is or something like that?

Problem is we have a few COM (VB6) DLLs that cannot be loaded in the same folder.

*An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll

Additional information: Could not load file or assembly 'BPAdviceSummary.dll' or one of its dependencies. The module was expected to contain an assembly manifest. *

This is the error and stack trace:

Application: Sequel.Menu.Shell.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.BadImageFormatException
Stack:
   at System.Reflection.AssemblyName.nGetFileInformation(System.String)
   at System.Reflection.AssemblyName.GetAssemblyName(System.String)
   at CodeCop.Core.Helpers.ReflectionHelper+<>c__DisplayClass0_0.<GetAppDomainAssemblies>b__1(System.String)
   at System.Collections.Generic.List`1[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]].ForEach(System.Action`1<System.__Canon>)
   at CodeCop.Core.Helpers.ReflectionHelper.GetAppDomainAssemblies(System.String)
   at CodeCop.Core.Helpers.ReflectionHelper.GetTypesImplementing[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]()
   at CodeCop.Core.Handlers.DiscoverInterceptorsCommandHandler.Handle(CodeCop.Core.Contracts.IDiscoverInterceptorsCommand)
   at CodeCop.Core.Messaging.InMemoryMessageBus.Send[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](System.__Canon)
   at CodeCop.Core.Cop.Intercept()
   at Sequel.Menu.UI.Shell.Program.Main(System.String[])

Comments (12)

  1. Ricardo Barbosa

    Hi Javier,

    Yes that's done via autodiscovery of types and that assembly is being caught up in the process.

    Let me quickly fix that.

    Thanks,

    Ricardo

  2. Ricardo Barbosa

    Hi Javier,

    Just pushed v1.2.7 onto nuget.

    Please tell me if this issue still persists.

    Thanks,

    Ricardo

  3. Javier García Magna reporter

    Apologies but...

    An unhandled exception of type 'System.Reflection.ReflectionTypeLoadException' occurred in mscorlib.dll

       at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
       at System.Reflection.RuntimeModule.GetTypes()
       at System.Reflection.Assembly.GetTypes()
       at CodeCop.Core.Helpers.ReflectionHelper.<>c__10`1.<GetTypesImplementing>b__10_3(Assembly x)
       at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
       at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
       at CodeCop.Core.Helpers.ReflectionHelper.GetTypesImplementing[T]()
       at CodeCop.Core.Handlers.DiscoverInterceptorsCommandHandler.Handle(IDiscoverInterceptorsCommand command)
       at CodeCop.Core.Messaging.InMemoryMessageBus.Send[TCommand](TCommand message)
       at CodeCop.Core.Cop.Intercept()
       at Sequel.Menu.UI.Shell.Program.Main(String[] args) in s:\UW\Releases\4.12.0\framework\Source\Net\Sequel\Menu\UI\Shell\Program.cs:line 105
    
  4. Javier García Magna reporter

    By the way in our case we don't do anything at all with the DLLs in the same folder and I believe that auto discovery takes a little while so if it can be turned off (via a parameter in the Intercept method maybe) even better.

    All the relevant DLLs are loaded by reflection in the client side and are not in the same folder as the EXE. In the server side the DLLs are also in a different folder...

  5. Ricardo Barbosa

    That's very relevant info Javier,

    As you don't use assemblies in the same folder as the app , might be better to specify paths via the AssemblyPath property to each assembly you want to intercept.

    That way it will override the autodiscovery.

    What do you think?

    Ricardo

  6. Javier García Magna reporter

    Yes, that sounds good, if all the assemblies have an assembly path then there is no point in trying to find it :)

    Thanks.

  7. Ricardo Barbosa

    Exactly ;)

    Try it that way and please tell me how it went.

    Don't worry as we'll adapt it until its perfect for you guys ok?

    Thanks,

    Ricardo

  8. Javier García Magna reporter

    Umm, are you going to change something? :-)

    The config file already contains that but it doesn't work...

    {
        "Types": [
            {
                "TypeName": "Sequel.UW.Risk.UIP.EditPolicyWorkItem",
                "Methods": [
                    {
                        "MethodSignature": "LockEntity()",
                        "Interceptors": [ "WriteMethodNameToConsoleInterceptor"]
                    }
                ],
                "GenericArgumentTypes": [ ],
                "AssemblyPath": "c:\\Program Files (x86)\\Sequel Underwriting\\bin\\gac\\Sequel.UW.Risk.UIP.dll"
            }
    
        ],
        "GlobalInterceptors": [],
        "Key":""
    }
    
  9. Javier García Magna reporter

    Yes, I changed the config file when I closed the other issue, and then I raised this one.

  10. Javier García Magna reporter

    I can provide you with a dump file if you wish or if you send me the PDBs we will be able to see line numbers... up to you.

  11. Log in to comment