locked
The located assembly's manifest definition does not match the assembly reference - when referencing signed assemblies RRS feed

  • Question

  • I have a SQL CLR project that is signed in order to be deployed to the database with UNSAFE permissions. Another project has a reference to that SQL CLR project for some miscellaneous functions. When I run my application, I get a TargetInvocationException anytime a function in the SQL CLR assembly is called with the following exception text:

    Could not load file or assembly 'MyAssembly, Version=12.2.1.3, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

    The signed assembly is NOT deployed to the GAC.

    How do I fix this error? 

     

    Thanks!

    Thursday, September 22, 2011 2:27 PM

Answers

  • You are the only person that can answer those questions. You have to track down why there is incorrect file in this directory:
        LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MySolution converted to 2010\MyApplication\bin\MyAssembly.dll
        LOG: Entering download cache setup phase.
        LOG: Assembly Name is: MyAssembly, Version=12.3.2.148, Culture=neutral, PublicKeyToken=7a45b8ac095ea0f9
        WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN

    Review your application and VS project - find out who updates the DLL. Try 'clean' and 'undeploy' your project. In the worst case use ProcMon to track down who is touching that particular file.

    -Karel

    • Proposed as answer by Min Zhu Wednesday, September 28, 2011 1:44 AM
    • Marked as answer by Min Zhu Monday, October 3, 2011 1:22 AM
    Friday, September 23, 2011 3:42 PM

All replies

  • Do Fusion logs give you more details about the error? (See MSDN page for fuslogvw.exe)

    Did you check the reference and your assembly manifest definition? Do they match?

    -Karel

    Thursday, September 22, 2011 3:50 PM
  • Karel,

     

    The fusion log did not display anything. However, I opened up my main application dll using ILDASM, and in the manifest definition, the public key token for the SQL CLR assembly is different from the one Visual Studio mentions in the exception. How do I sync the public key tokens? I tried deleting and re-adding the reference.

     

    Thanks!

    Thursday, September 22, 2011 4:03 PM
  • Empty fusion log is weird. I did not ever try to run CLR in SQL, but I would expect it does the same logging as in desktop runs. Try to check your settings and try if a HelloWorld app running outside of SQL will create entries in Fusion logs.

    What is the public key in your manifest? Check your build log and make sure that the right version of your file is referenced. Also check if SQL does use the latest version of your assembly (some stale old version might be picked up by accident).

    Another option I would try is to reference your DLL from a command line: Open VS environment cmd window and type csc.exe SomeSource.cs /r:YourLibrary.dll
    make sure that SomeSources uses at least one type from YourLibrary.dll. Then check what does the reference to YourLibrary.dll looks like in SomeSource.exe (ildasm - manifest).

    -Karel

    Friday, September 23, 2011 3:22 AM
  • Actually the fusion log wasn't empty. I didn't have it setup correct. According to the log the main assembly tries to load two referenced assemblies with the same version number, but with a DIFFERENT PublicKeyToken. The second attempt fails, and that is the public key token that visual studio looks for. Here is the fusion log entry for the failed load attempt: Why would my main assembly try to load two different referenced assemblies? How do I fix it?

     

    Thanks!

    *** Assembly Binder Log Entry  (9/22/2011 @ 2:14:36 PM) ***
    
    The operation failed.
    Bind result: hr = 0x80131040. No description available.
    
    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
    Running under executable  C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\WebDev.WebServer20.exe
    --- A detailed error log follows. 
    
    === Pre-bind state information ===
    LOG: DisplayName = MyAssembly, Version=12.3.2.148, Culture=neutral, PublicKeyToken=5ad1afbaab228075
     (Fully-specified)
    LOG: Appbase = file:///C:/inetpub/wwwroot/MySolution converted to 2010/MyApplication/
    LOG: Initial PrivatePath = C:\inetpub\wwwroot\MySolution converted to 2010\MyApplication\bin
    LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\8365e84e
    LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\8365e84e
    LOG: AppName = d8cf427a
    Calling assembly : (Unknown).
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\inetpub\wwwroot\MySolution converted to 2010\MyApplication\web.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v2.0.50727\config\machine.config.
    LOG: Post-policy reference: MyAssembly, Version=12.3.2.148, Culture=neutral, PublicKeyToken=5ad1afbaab228075
    LOG: GAC Lookup was unsuccessful.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/8365e84e/d8cf427a/MyAssembly.DLL.
    LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/Temporary ASP.NET Files/root/8365e84e/d8cf427a/MyAssembly/MyAssembly.DLL.
    LOG: Attempting download of new URL file:///C:/inetpub/wwwroot/MySolution converted to 2010/MyApplication/bin/MyAssembly.DLL.
    LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MySolution converted to 2010\MyApplication\bin\MyAssembly.dll
    LOG: Entering download cache setup phase.
    LOG: Assembly Name is: MyAssembly, Version=12.3.2.148, Culture=neutral, PublicKeyToken=7a45b8ac095ea0f9
    WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN
    ERR: The assembly reference did not match the assembly definition found.
    ERR: Setup failed with hr = 0x80131040.
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
    
    


    Friday, September 23, 2011 12:39 PM
  • You are the only person that can answer those questions. You have to track down why there is incorrect file in this directory:
        LOG: Assembly download was successful. Attempting setup of file: C:\inetpub\wwwroot\MySolution converted to 2010\MyApplication\bin\MyAssembly.dll
        LOG: Entering download cache setup phase.
        LOG: Assembly Name is: MyAssembly, Version=12.3.2.148, Culture=neutral, PublicKeyToken=7a45b8ac095ea0f9
        WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN

    Review your application and VS project - find out who updates the DLL. Try 'clean' and 'undeploy' your project. In the worst case use ProcMon to track down who is touching that particular file.

    -Karel

    • Proposed as answer by Min Zhu Wednesday, September 28, 2011 1:44 AM
    • Marked as answer by Min Zhu Monday, October 3, 2011 1:22 AM
    Friday, September 23, 2011 3:42 PM
  • Hi Andy,

    We have not heard from you in a couple of days.

    Please post back at your convenience if we can assist further.

    Enjoy your day!


    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, September 28, 2011 1:44 AM