3

Resolved

Strong Name sign

description

I need it, so I made some changes ...
 
  1. create the key. (EmitMapper.snk)
  2. add to prj and modify: InternalsVisibleTo in AssemblyInfo.cs as in: http://blog.tylerholmes.com/2008/04/unit-tests-and-internalsvisibleto.html or you have a problem with EmitMapperAssembly.
    [assembly: InternalsVisibleTo("EmitMapperAssembly, PublicKey=0024000 ...."]
  3. add strongname in DynamicAssemblyManager.cs:
        FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory+ "\\EmitMapper.snk", FileMode.Open);
        StrongNameKeyPair kp = new StrongNameKeyPair(fs);
        fs.Close();
     
        assemblyName = new AssemblyName("EmitMapperAssembly");
        assemblyName.KeyPair = kp;
        assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
            assemblyName,
            AssemblyBuilderAccess.RunAndSave
            );
  4. play... I don't know if this modify the benchmark results...

file attachments

comments

minorello wrote Jan 18, 2010 at 11:19 AM

I also note this:
Guid.NewGuid().ToString().Replace("-", "")
you can have the same result with:
Guid.NewGuid().ToString("N")
http://msdn.microsoft.com/en-us/library/97af8hh4.aspx

romankovs wrote Jan 20, 2010 at 10:37 AM

Thanks, minorello. I will add your changes to the main project trunc.

minorello wrote Jan 20, 2010 at 1:47 PM

FileStream fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory+ "\EmitMapper.snk", FileMode.Open);
I discover this is not the best way. I've seen that is better to embed the snk to the proj with something like:
           Assembly assembly = Assembly.GetExecutingAssembly();
            string resourceName = string.Format("{0}.{1}", assembly.GetName().Name, "EmitMapper.snk");
[..]
     using (Stream resourceStream = assembly.GetManifestResourceStream(resourceName))
   {
                 int length = (int)resourceStream.Length;
                key = new byte[length];
                resourceStream.Read(key, 0, length);
            }
and then use the
new StrongNameKeyPair(bytes[]);

chrbruno wrote Jun 10, 2010 at 9:48 AM

Hello,
when you create the dynamic assembly, it should be possible to "inherit" the EmitAssembly key pairs :
[..]
  assemblyName = new AssemblyName("EmitMapperAssembly");
  assemblyName.SetPublicKey(Assembly.GetExecutingAssembly().GetName().GetPublicKey());
[..]

wrote Sep 28, 2010 at 11:15 PM

wrote Sep 29, 2010 at 12:08 AM

pocheptsov wrote Sep 29, 2010 at 12:08 AM

I create patch with strong name attaching, but I also converted solution to 2010 and have problems with running unit tests

wrote Aug 4, 2011 at 12:59 PM

wrote Sep 13, 2011 at 8:30 PM

wrote Feb 21, 2013 at 11:43 PM

wrote May 16, 2013 at 11:21 AM

wrote May 16, 2013 at 11:21 AM

wrote Jun 14, 2013 at 8:23 AM