public AssemblyAlgorithmIdAttributeTest () { //create a dynamic assembly with the required attribute //and check for the validity dynAsmName.Name = "TestAssembly"; dynAssembly = Thread.GetDomain ().DefineDynamicAssembly ( dynAsmName,AssemblyBuilderAccess.Run ); // Set the required Attribute of the assembly. Type attribute = typeof (AssemblyAlgorithmIdAttribute); ConstructorInfo ctrInfo = attribute.GetConstructor ( new Type [] { typeof (AssemblyHashAlgorithm) } ); CustomAttributeBuilder attrBuilder = new CustomAttributeBuilder ( ctrInfo, new object [1] { AssemblyHashAlgorithm.MD5 } ); dynAssembly.SetCustomAttribute (attrBuilder); object [] attributes = dynAssembly.GetCustomAttributes (true); attr = attributes [0] as AssemblyAlgorithmIdAttribute; }