Hi,
I created an assembly (let's call it assembly (B)) that returns a localized
resource for a given key (similar to System.Globalization.ResourceManager).
I checks if the caller assembly (let's call it assembly (A)) has a satellite
assembly (let's call it assembly (sA)) with localized resources.
If it exists, it gets the resource with the given key and returns it,
otherwise it reads information from a support database and dinamically
compiles a new satellite assembly and places it in the calling assembly's
respective folder, and then returns the requested resource.
It is all working fine, but once I started signing the assemblies (A) and
(B) with strong names, I got a dreadful error:
"The located assembly's manifest definition with name '(A).resources' does
not match the assembly reference."
Naturally, I assume I need to sign (sA) with strong name too, so I tried to
do it when I create the satellite assembly, but so far I have been
unsuccessful. Below are my efforts to provide (sA) with a strong name
dinamically:
----------- 1st Try -----------------------------
AssemblyName assName = new AssemblyName();
assName.Name = assemblyName + ".resources";
assName.CultureInfo = new CultureInfo(culture);
// ------ Sign the satellite assembly -----
FileStream fs = null;
StrongNameKeyPair kp = null;
try
{
fs = new FileStream(@"MyKey.snk", FileMode.Open, FileAccess.Read,
FileShare.Read);
kp = new StrongNameKeyPair(fs);
}
catch (FileNotFoundException)
{
Diag.Trace.Write("Strong name key pair file not found.");
throw;
}
catch(Exception ex)
{
Diag.Trace.Write("Error obtaining strong name key pair from file." +
fs.Name);
throw;
}
finally
{
if (fs != null)
{
fs.Close();
}
}
assName.KeyPair = kp;
----------- 2nd Try -----------------------------
try
{
FileStream publicKeyStream = File.Open("MyKey.snk",
FileMode.Open,FileAccess.Read, FileShare.Read);
byte[] publicKey = new byte[publicKeyStream.Length];
publicKeyStream.Read(publicKey, 0, (int)publicKeyStream.Length);
// Provide the assembly with a public key.
assName.SetPublicKey(publicKey);
}
catch(Exception ex)
{
throw;
}
---------------------------------------------
Can anyone help me ?
-----------------------------
Mário Sobral
Inosat
Research & Development
-----------------------------