none
Strong name validation failed in Win 7 (64) RRS feed

  • Question

  • Hi Guys,

    I am using two dlls one is signed and other one is not signed. These dlls are referenced and they work perfectly on win xp.

    But when I upgraded my System to win 7 they stopped working and I started getting Strong name validation exceptions like

    System.IO.FileLoadException was unhandled
      Message=Could not load file or assembly 
    

    now I want to reproduce the same problem on windows xp 32, how should I proceed.

    I want to turn on Strong name validation on Win XP, how should I do it.

    The command sn -Vl on win xp says

    No verification entries registered.

     

    Thanks


    Raghvendra
    • Moved by Leo Liu - MSFT Friday, November 11, 2011 8:24 AM Moved for better support. (From:Visual C# General)
    Thursday, November 10, 2011 10:13 AM

All replies

  • Hi raghavx,

    I am moving your thread into the Common Language Runtime Forum for dedicated support.
    Have a nice day,
    Leo Liu [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.

    Friday, November 11, 2011 8:24 AM
  • Hi,

    According to your description, the IO.FileLoadException happens when the assemblies loading on a Windows 7 machine. I think it is not caused by Strong name validation. It may caused by many reasons. For example, you are not locate the dlls in correct folder. 

    Moreover,

     

    To disable verification of an assembly, type the following at the command line:

    SN -Vr SomeAssemblyName

     To re-enable verification of the assembly, type the following at the command line:

    SN -Vu SomeAssemblyName

    I think Windows XP or Windows 7 is not the point. SN.exe works both on Windows XP and Windwos 7.

     

     


    Paul Zhou [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.

    Friday, November 11, 2011 8:58 AM
  • Raghvendra,

    Could you please provide the full exception details (including stack trace) as returned by the exception's ToString() method?

    Thanks,

    Nicole

    Monday, November 14, 2011 5:46 PM
  • Hi Nicole,

    Here is the exceptio I got win 7 x64and no exception win xp 32

    System.IO.FileLoadException was unhandled

      Message=Could not load file or assembly 'Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)

      Source=DemoMonoCecil

      FileName=Mono.Cecil, Version=0.6.9.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756

      FusionLog=""

      StackTrace:

           at DemoMonoCecil.ReadWriteAssembly..ctor(String assemblyLocation, Boolean log)

           at DemoMonoCecil.Program.Main(String[] args) in D:\Temp\s101\DemoMonoCecil\DemoMonoCecil\Program.cs:line 18

           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

           at System.Threading.ThreadHelper.ThreadStart()

      InnerException: System.Security.SecurityException

           Message=Strong name validation failed. (Exception from HRESULT: 0x8013141A)

           InnerException:


    Raghvendra
    Tuesday, November 15, 2011 12:41 PM
  • Have you checked that the strong name on the Mono.Cecil assembly is valid using sn.exe -v?  If it's not, could you please provide the code in the DemoMonoCecil.ReadWriteAssembly constructor in which the exception occurs?

    If it passes the validity check on 32-bit XP, could you please check on your Windows 7 system?  (If you have both the 32-bit and 64-bit .NET Frameworks installed, please make sure that you use the copy of sn.exe from the appropriate "bitness" install.)

    Thanks,

    Nicole

    • Proposed as answer by Paul Zhou Thursday, November 17, 2011 4:51 AM
    Tuesday, November 15, 2011 2:19 PM
  • Yes sn -vf Mono.Cecil on win xp 32 it says it is valid. But on Win 7 64 it is not. The code is as follows.
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Mono.Cecil;
    using System.IO;
    
    namespace DemoMonoCecil
    {
        class ReadWriteAssembly
        {
            static TextWriter textWriter = new StreamWriter(Environment.GetEnvironmentVariable("USERPROFILE") + "\\DemoMonoCecil.log", true);
    
            public ReadWriteAssembly(String assemblyLocation, bool log)
            {
                try
                {
                    Console.WriteLine("Starting assembly read and write.");
                    Console.WriteLine("Assembly location to be checked = "+assemblyLocation);
                    if (log)
                    {
                        textWriter.WriteLine("Starting assembly read and write.");
                        textWriter.WriteLine("Assembly location to be checked = " + assemblyLocation);
                    }
                    AssemblyDefinition def = AssemblyFactory.GetAssembly(assemblyLocation);
                    Console.WriteLine("Assembly Definition = " + def);
                    Console.WriteLine("Type Count = " + def.MainModule.Types.Count);
                    if (log)
                    {
                        textWriter.WriteLine("Assembly Definition = " + def);
                        textWriter.WriteLine("Type Count = " + def.MainModule.Types.Count);
                    }
                    foreach(TypeDefinition td in def.MainModule.Types)
                    {
                        if ("<Module>".Equals(td.Name))
                        {
                            Console.WriteLine("[ignore] "+td.Name);
                            if (log)
                                textWriter.WriteLine("[ignore] " + td.Name);
                        }
                        else
                        {
                            Console.WriteLine("Full Name = " + td.FullName);
                            if (log)
                            { 
                                textWriter.WriteLine("Full Name = " + td.FullName); 
                            }
                            foreach (MethodDefinition md in td.Methods)
                            { 
                                Console.WriteLine(md);
                                if (log)
                                {
                                    textWriter.WriteLine(md);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Exception occured while reading assembly = "+assemblyLocation+"\nException = "+ex);
                    if (log)
                    {
                        textWriter.WriteLine("Exception occured while reading assembly = " + assemblyLocation + "\nException = " + ex);
                    
                    }
                }
                if (log)
                {
                    textWriter.Flush();
                    textWriter.Close();
                }
            }
        }
    }
    
    


    Raghvendra
    Thursday, November 17, 2011 6:09 PM
  • Did you build Mono.Cecil yourself or are you using a pre-compiled copy of the assembly?  If the latter, could you please provide directions to the source?

    Thursday, November 17, 2011 6:38 PM
  • Try to use different SN.exe on different OS(I assume that you build the assembly with AnyCPU platform option).

    On 32-bit Windows XP, use x86 Visual Studio Command Prompt. On 64-bit Windows 7, use X64 version:


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Friday, November 18, 2011 4:38 AM
  • Thank you, Paul.

    sn -Vr [my assembly name]

    Solved my problem like a charm!

    It works with Windows 8.1.

    sn.exe is in C:\"Program Files (x86)"\"Microsoft SDKs"\Windows\v8.1A\bin\"NETFX 4.5.1 Tools"\x64\

    The path to an assembly should be given as well - ex) sn.exe -Vr C:\myFolder\myAssemblyName.

    Friday, June 6, 2014 4:55 PM