Ask a questionAsk a question
 

QuestionAssembly.getType is not working

  • Wednesday, October 21, 2009 10:05 PMsangeeta10 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    We have a ddex assembly (foo.dll) which we use to make a connection to db2. When we try to load the assembly using reflection within our package, it works fine. But when we do a assembly.getType to get a class(c1) in that assembly, it fails with an error message "Could not load file or assembly
    foo, Version=9.1.0.0, Culture=neutral,
    PublicKeyToken=7c307b91aa13d208' or one of its dependencies. The system
    can not find the file specified."
    This seems to work with VS2005 without any problems
    This works when we load the foo outside the package and the assembly.getType works just fine. Also one other thing that we noticed is that when we create a windows aplication and change the target framework type of that application to framework 4.0 without doing anything else the assembly.GetType works just fine.
    Can someone please help us with this issue.
    •  

All Replies

  • Wednesday, October 21, 2009 10:10 PMMichael Feingold Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It probably means that the assembly you are loading fails to pull some other assembly when it needs it. To have more details you can run fuslogvw to see the detailed protocol of assembly load/bind process
  • Wednesday, October 21, 2009 10:19 PMsangeeta10 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    We already checked the fusion log. It doesn't seem to indicate any failure

     

    *** Assembly Binder Log Entry  (10/21/2009 @ 3:14:29 PM) ***

    The operation was successful.
    Bind result: hr = 0x0. The operation completed successfully.

    Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.21006\clr.dll
    Running under executable  C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
    --- A detailed error log follows.

    === Pre-bind state information ===
    LOG: User = ur1
    LOG: Where-ref bind. Location = foo.dll
    LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = devenv.exe
    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:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe.Config
    LOG: Using host configuration file:
    LOG: Using machine configuration file from C:\WINDOWS\Microsoft.NET\Framework\v4.0.21006\config\machine.config.
    LOG: Attempting download of new URL file:///foo.dll.
    LOG: Assembly download was successful. Attempting setup of file: foo.dll
    LOG: Entering run-from-source setup phase.
    LOG: Assembly Name is: foo, Version=9.1.0.0, Culture=neutral, PublicKeyToken=null
    LOG: Re-apply policy for where-ref bind.
    LOG: Where-ref bind Codebase does not match what is found in default context. Keep the result in LoadFrom context.
    LOG: Binding succeeds. Returns assembly from foo.dll.
    LOG: Assembly is loaded in LoadFrom load context.
    WRN: The same assembly was loaded into multiple contexts of an application domain:
    WRN: Context: LoadFrom | Domain ID: 1 | Assembly Name: foo, Version=9.1.0.0, Culture=neutral, PublicKeyToken=null
    WRN: Context: Neither | Domain ID: 1 | Assembly Name: foo, Version=9.1.0.0, Culture=neutral, PublicKeyToken=null
    WRN: This might lead to runtime failures.
    WRN: It is recommended to inspect your application on whether this is intentional or not.
    WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.

     

  • Wednesday, October 21, 2009 10:30 PMMichael Feingold Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    This is not necessarily the foo assembly. Do you see any failures in the fusion log? If foo references some other assembly the attempt to load it can be deferred to the moment when the type using it is first requested. Loading your assembly into LoadFrom can cause this sort of problems because it changes the binding behavior. And the fact that foo is loaded twice looks especially suspicios
  • Wednesday, October 21, 2009 11:19 PMsangeeta10 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    We cannot figure out why it gets loaded twice in VS 2010. When we use VS2005, the fusion log appears to be loading only into LoadFrom.

    For all the assemblies that foo references, the fusion log shows a file not found exception.

    *** Assembly Binder Log Entry  (10/21/2009 @ 3:14:11 PM) ***

    The operation was successful.
    Bind result: hr = 0x0. The operation completed successfully.

    Assembly manager loaded from:  C:\WINDOWS\Microsoft.NET\Framework\v4.0.21006\clr.dll
    Running under executable  C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe
    --- A detailed error log follows.

    LOG: IJW explicit bind. File path:fooreferenced.dll
    LOG: IJW assembly bind returned file not found.

     

  • Wednesday, November 04, 2009 5:21 AMSaurabh Jain VSMSFT, OwnerUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Is it possible for you to provide some steps on how to reproduce this scenario? This will help us in narrowing down what's the root cause here.

    --
    Regards,
    Saurabh


    http://blogs.msdn.com/saurabhjain