Locked Error- Could not load file or assembly

  • Monday, August 15, 2005 6:29 PM
     
     

    I have two projects in a solution. One is a class library with my FTP, GPG and some other classes that get compiled into a dll call CBI.Utilities.

    The other is my main app which in a few places call the ftp class. I added the reference to the main solution by browing to the project from references under the main solution and now I get this error when I try to instantiate the ftp class.

    "Could not load file or assembly 'CBI.Utilities, Version=1.0.2053.21021, Culture=neutral, PublicKeyToken=78bbe40a91a1660e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

    Should I be making a reference to the DLL or to the projects. Either way I end up with a reference cbi.utilities.

    I have built the CBI project first and then added the reference but that did not help.

    Thanks.

All Replies

  • Monday, August 15, 2005 11:41 PM
     
     

    Just a question, were all the components of the application - Class Library & Client all created using the same version of the .Net Framework.   Was this using VB 2003 or 2005 (Beta)

    Some potential scenarios that could be are that the CBI.Utilities assembly is referencing something that doesn't exist on the machine.    An example of this may be a reference to a DLL that is not installed - this potentially could be an earlier version of the framework or even a different version of the DLL.

    If you load the solution and load up each of the the projects (Class Library and Client) and ensure that all the references used throughout exist as well as change any references that refer to the dll and change them to the project in the solution.     When you rebuild the solution it will rebuild each of the components.

    This means that you should ensure that all the components are in sync and that all references to those components exist when you build your solution.

     

     

     

  • Thursday, August 18, 2005 2:17 PM
     
     

    The only reference used by the utilities project is system.

    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50215\System.dll

    And if I delete \obj directory in the utilities solution and rebuild the project the program runs fine until I pull down the project from sourcesafe again. The utilities project was written in VS 2003 whereas the main project is being written in the beta.

    Should opening a project in vs2005 update the assembly to point to the 2.0 framework.

     

     

     

  • Wednesday, August 24, 2005 12:55 AM
     
     

    You saying that the cbi.utilities is a class library that was written in VS2003 and when you pull the project down from sourcesafe it stops working again.

    Youve given me a reference to a V2.0.50215 of the .net framework which is the version for the beta of VS2005.   So your reference would be to this.  Pulling down the sourcesafe copy make be looking for files that are version 1.1 of even .0 of the framework.  

    when you pull the ode from sourcesafe is the reference to an earlier version of the framework as V2.0.50215 was not around for a VS2003.   So I would still be learning towards a a reference in your class library that is not set correctly to a version that is on your machine - such as an component which may be on an earlier version of the framework.

    Is V1.1 of the framework installed on this machine as well as V2 ?

     

  • Wednesday, August 24, 2005 1:55 PM
     
     
    I have a fresh XP install and Visual studio 2005. In the control panel I have the compact framework 1.0 sp3 Dev Beta 2, compact 2.0 beta 2 and MS .Net Framework 2.0 beta 2 installed

    I would think there would be a menu items or process for upgrading any old references to the new framwork if it saw a reference to an old framework.
  • Wednesday, August 24, 2005 6:45 PM
     
     
    But not all framework 1 items may be supported in framework 2.0

    I would definately try installing the .NET framework 1.1 redistributables to see if that helped.

    http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&displaylang=en

    That way you know that all the original 1.1 framework components are present.   Framework 1.0, 1.1 and 2.0 can all be residing on the same machine at the same time.

  • Friday, November 11, 2005 8:02 PM
     
     
    I have the same problem. My solution contains multiple projects. All but the main project are built as dll's. The main project is a Windows executable.

    I am forever dealing the the problem you describe on one of my projects. I note in properties of the reference to the offending dll from the calling project that the  "Specific Version" property repeatedly gets set to "True".

    No matter how often I set if false when the error occurs I check and it has been set to True again.

    I wonder if you have solved your problem and if this helps. Please let me  know.

    Cheers
  • Monday, November 14, 2005 3:06 PM
     
     
    I eneded up just pulling the code into the main project.
  • Monday, November 14, 2005 10:55 PM
    Moderator
     
     
    Philip,

    JUst for future reference:

    If you add a reference to a component that was built with an older version of the .NET Runtime then you need to have the version installed in order for your app to run.

    The alternative is to rebuild the component using the newer .NET Runtime and this would be the recommended thing to do. After that you should no longer be getting this error.

    Cameron McColl
    The Wee Scot
  • Monday, November 14, 2005 10:59 PM
    Moderator
     
     
    Stephen,

    This sounds like a different issues.

    Hvae you tried dropping the reference altogether to the offending dll and then adding it again?

    Add it as a project reference first and see if that works.
    Then try a DLL reference. Let me know which if any don't work.
    When you add the DLL (file) reference be sure to add the reference from the bin dir of the dll's proect.

    If your still stuck, perhaps you could make a simplified zip file of the sln and include it so I can take a look?
  • Saturday, January 14, 2006 8:03 PM
     
     

    I have the same issue... more so than before...

    I started a solution (14 projects in all) over a year ago with the First 2.0 Beta... since it has been compiled and re-compiled with the new 2.0 Full Production Release of .NET.  If I get the error... I can Re-Build the Solution and that fixes it.... but it is such a pain in the A@@!

    And it is happening more and more lately.  I just reformatted my entire computer and reloaded the VS Studio and 2.0... still nothing... still get the issue!

  • Monday, January 24, 2011 8:41 PM
     
     Proposed

    I ran into similar issue and following resolved it.

    Explanation


    This message indicates that the Script task or Script component cannot locate an assembly that is referenced within the script project.

    Possible Causes

    This message might appear because of one of the following problems:

    • The referenced assembly has not been installed in the global assembly cache (GAC).
    User Action

    Install the assembly in the global assembly cache (GAC)

    At design time, you must place assemblies that are used by the Integration Services Script task or Script component in specific folders before you can successfully add a reference to them in the script project. However at run time, these assemblies are loaded from the global assembly cache. Therefore you must use the gacutil.exe command prompt utility with the /i option to install each referenced assembly in the global assembly cache for use at run time. For more information, see Referencing Other Assemblies in Scripting Solutions.

    • Proposed As Answer by Shital Mehta Thursday, September 22, 2011 10:24 PM
    •  
  • Monday, February 14, 2011 1:31 PM
     
      Has Code

    I've faced similar issue and none of the above solutions worked for me.  I'm pasting the error information below.

    Could not load file or assembly 'DocumentFormat.OpenXml.2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IO.FileLoadException: Could not load file or assembly 'DocumentFormat.OpenXml.2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Assembly Load Trace: The following information can be helpful to determine why the assembly 'DocumentFormat.OpenXml.2' could not be loaded.

    WRN: Assembly binding logging is turned OFF.
    To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
    Note: There is some performance penalty associated with assembly bind failure logging.
    To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
    

    Stack Trace:

    [FileLoadException: Could not load file or assembly 'DocumentFormat.OpenXml.2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
      System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
      System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
      System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
      System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
      System.Reflection.Assembly.Load(String assemblyString) +28
      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46
    
    [ConfigurationErrorsException: Could not load file or assembly 'DocumentFormat.OpenXml.2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
      System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
      System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
      System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
      System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
      System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +94
      System.Web.Compilation.BuildManager.CallPreStartInitMethods() +332
      System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +591
    
    [HttpException (0x80004005): Could not load file or assembly 'DocumentFormat.OpenXml.2' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
      System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8950644
      System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
      System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258
    

    Any suggestions appreciated.

     

     


    Mohan Raju
  • Wednesday, April 06, 2011 4:32 PM
     
     

    Hey guys I have had this problem and here is how I solved it.

    The first time the problem was coming up it was pointing to the asp.net temporary files directory and couldn't find a dll referenced in my application there.

    In the asp.net temporary files directory in the root folder there are folders one for each website you are compiling. So I deleted the one corresponding to the website with problem. And when I rebuilt the application the deleted folder was regenerated and everything was ok. I think it will work  if you delete all folders in the asp.net temporary files directory since everything related to your application is regenerated when you rebuild your application.