G
Grant Johnson
Hi,
I am trying to create an assembly to store compiled regular expressions.
I need to give this assembly a strong name. However, I can't seem to
get my use of the CustomAttributeBuilder class right.
Here's what I'm doing:
// The regular expression
infos = new RegexCompilationInfo[1];
infos[0] = new RegexCompilationInfo(@"[\x80-\x9f]",
RegexOptions.Compiled | RegexOptions.CultureInvariant |
RegexOptions.IgnoreCase, "C1Regex", IdsNamespace, true);
// Build the assembly
AssemblyName an = new AssemblyName();
an.Name = IdsNamespace;
Type t;
object[] args;
ConstructorInfo ci;
CustomAttributeBuilder[] ab = new CustomAttributeBuilder[1];
t = typeof(AssemblyKeyFileAttribute);
ci = t.GetConstructor(new Type[] { typeof(string) });
args = new object[1] { @"C:\MyKeys.keys" };
CustomAttributeBuilder cab = new CustomAttributeBuilder(ci, args);
ab[0] = cab;
Regex.CompileToAssembly(infos, an, ab);
This code compiles and runs, but sn.exe reports the produced assembly
does _not_ have a strong name. Can anyone see what I'm doing wrong?
Thanks in advance,
Grant
I am trying to create an assembly to store compiled regular expressions.
I need to give this assembly a strong name. However, I can't seem to
get my use of the CustomAttributeBuilder class right.
Here's what I'm doing:
// The regular expression
infos = new RegexCompilationInfo[1];
infos[0] = new RegexCompilationInfo(@"[\x80-\x9f]",
RegexOptions.Compiled | RegexOptions.CultureInvariant |
RegexOptions.IgnoreCase, "C1Regex", IdsNamespace, true);
// Build the assembly
AssemblyName an = new AssemblyName();
an.Name = IdsNamespace;
Type t;
object[] args;
ConstructorInfo ci;
CustomAttributeBuilder[] ab = new CustomAttributeBuilder[1];
t = typeof(AssemblyKeyFileAttribute);
ci = t.GetConstructor(new Type[] { typeof(string) });
args = new object[1] { @"C:\MyKeys.keys" };
CustomAttributeBuilder cab = new CustomAttributeBuilder(ci, args);
ab[0] = cab;
Regex.CompileToAssembly(infos, an, ab);
This code compiles and runs, but sn.exe reports the produced assembly
does _not_ have a strong name. Can anyone see what I'm doing wrong?
Thanks in advance,
Grant