none
How do I get the StrongName of a loaded assembly? RRS feed

  • Question

  • Hello All,

    I want to experiment with the use of this overload of CreateDomain:

    public static AppDomain CreateDomain(
        string friendlyName,
        Evidence securityInfo,
        AppDomainSetup info,
        PermissionSet grantSet,
        params StrongName[] fullTrustAssemblies
    )

    I want to create a new AppDomain, but I want to provide the fullTrustAssemblies parameter, initializing the array with the StrongNames of some of the assemblies that are already loaded in the executing domain.

    How do I get or create the StrongName for an assembly that is already loaded?

    The GetName() function of an assembly returns an AssemblyName (NOT a StrongName). The StrongName constructor takes a StrongNamePublicKeyBlob, and I can't find a way to get that from an loaded assembly.

    Any ideas?

    Thanks,
    John.
    Thursday, March 24, 2011 8:30 AM

Answers

  • Have you tried this ?

    Assembly.GetName()
     -> AssemblyName object
      -> AssemblyName.KeyPair
       -> StrongNameKeyPair object
        -> StrongNameKeyPair.PublicKey


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    • Marked as answer by eryang Tuesday, March 29, 2011 9:22 AM
    Thursday, March 24, 2011 11:13 AM

All replies

  • create the StrongName for an assembly that is already loaded - it's impossible.

     

    There is no managed way to check the signature of an assembly and checking the public key leaves you vulnerable to spoofing. You will have to use p/Invoke and call theStrongNameSignatureVerificationEx function to check the signature

    [DllImport("mscoree.dll", CharSet=CharSet.Unicode)]
    static extern bool StrongNameSignatureVerificationEx(string wszFilePath, bool fForceVerification, ref bool  pfWasVerified);

    Don't forget to mark the correct answer
    Thursday, March 24, 2011 10:53 AM
  • Have you tried this ?

    Assembly.GetName()
     -> AssemblyName object
      -> AssemblyName.KeyPair
       -> StrongNameKeyPair object
        -> StrongNameKeyPair.PublicKey


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    • Marked as answer by eryang Tuesday, March 29, 2011 9:22 AM
    Thursday, March 24, 2011 11:13 AM
  •  

    We temporarily mark a reply since the thread idle for a long time, please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.


    Eric Yang [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.

    Tuesday, March 29, 2011 9:23 AM