Ask a questionAsk a question
 

Answer Assembly.getType is not working

  • Thursday, October 22, 2009 6:07 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.


    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.

    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.

    • Moved byKarel ZikmundMSFTThursday, October 22, 2009 7:55 PMWrong forum (From:.NET Framework 4 Beta 2 – General)
    •  

Answers

All Replies

  • Thursday, October 22, 2009 6:36 PMKarel ZikmundMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello,
    Is this a standalone application or VS plugin? What is 'package'?
    Also, can you please explain exactly when it does not work and when it does? ... I didn't quite get all those combinations:
    1) What does it mean that it works in VS 2005? (Do you mean hitting F5 in VS, or also running from command line when it was built by VS?)
    2) What does it mean that it works when you load foo outside of package? How exactly do you load it? From a simple application? From a native application?
    3) What does it mean that it does not work in VS2010? (Do you mean when you hit F5 in VS, and/or when you run the built app from command line?)

    -Karel

  • Thursday, October 22, 2009 6:56 PMsangeeta10 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi Karel,

    Thanks for responding.

    This is a VS plugin that currently works on VS 2005 and VS 2008 and we are trying to migrate to VS 2010.

    When we try to make a connection to our database in Server Explorer by selecting our provider, the connection dialog does not show up correctly. When we debugged through the code we found that the problem is happening in assembly.getType call which we make to load a class by reflection. We get an error that the class cannot be found although it seems to be looking for the assembly in the correct loaction as you noticed in the fusion log. On the same machine when we try to create a connection using VS2005 it works just fine and the assemblies seem to be loading fine.

    There is one thing that we noticed. When we create a windows application and change the application target framework type to 4.0 and then try to launch the connection dialog from server explorer for our provider, it seems to show up the connection dialog fine which means that the assemblies are loading up fine.

    Also we created a console application and tried to load the same assemblies for which the getType call is failing and that seems to work fine from the console application.

    Thanks,

    Sangeeta

  • Thursday, October 22, 2009 9:00 PMKarel ZikmundMSFTUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hello Sangeeta,
    It looks like something changed for VS plugins. Moving to VS Extension forum.

    Can you try to find out who and how loads this DLL in various loader contexts? That might help answer your question.
    Also can you please try to create a small test-only plugin for VS 2010 which would fail the same way?

    -Karel

  • Wednesday, November 04, 2009 1:52 AMNathan Halstead [MSFT]ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This is a duplicate topic.  See here:  http://social.msdn.microsoft.com/Forums/en-US/vsxprerelease/thread/f2c7436c-c23e-4edf-9b56-27847bf360a6/

    To focus the discussion, we'll have someone follow-up on the thread above, and I'll close this topic as answered.