Hi,
I created an assembly (let's call it assembly (B)) that returns a localized
resource for a given key (similar to System.Globaliz ation.ResourceM anager).
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.Culture Info = new CultureInfo(cul ture);
// ------ Sign the satellite assembly -----
FileStream fs = null;
StrongNameKeyPa ir kp = null;
try
{
fs = new FileStream(@"My Key.snk", FileMode.Open, FileAccess.Read ,
FileShare.Read) ;
kp = new StrongNameKeyPa ir(fs);
}
catch (FileNotFoundEx ception)
{
Diag.Trace.Writ e("Strong name key pair file not found.");
throw;
}
catch(Exception ex)
{
Diag.Trace.Writ e("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("MyKe y.snk",
FileMode.Open,F ileAccess.Read, FileShare.Read) ;
byte[] publicKey = new byte[publicKeyStream .Length];
publicKeyStream .Read(publicKey , 0, (int)publicKeyS tream.Length);
// Provide the assembly with a public key.
assName.SetPubl icKey(publicKey );
}
catch(Exception ex)
{
throw;
}
---------------------------------------------
Can anyone help me ?
-----------------------------
Mário Sobral
Inosat
Research & Development
-----------------------------