473,729 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Satellite assemblies and strong names

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
-----------------------------


Nov 16 '05 #1
2 2895
JMW
Do early signing as opposed to late signing of the assembly. The framework is going to verify the signature at load time. Try including this line in your assemblyinfo.cs class.

[assembly: AssemblyKeyFile (@"my.snk")]

Change the path of course! And take out your signing code.

jason.

"Mário Sobral" wrote:
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
-----------------------------


Nov 16 '05 #2
Hi !

Thanks for the suggestion, but my problem is that the satellite assembly is
being generated dinamically with System.Reflecti on.Emit. That's why it
should be signed dinamically also.

There is a method that reads the resources associated to a certain calling
assembly from a database, then generate the satellite assembly for that
calling assembly:

----------------------------------------------------------------------------
-------
AssemblyName assName = new AssemblyName();

assName.Name = assemblyName + ".resources ";

assName.Culture Info = new CultureInfo(cul ture);

assName.Version = new System.Version( 1,0,0,0);

AssemblyBuilder assBuilder =
Thread.GetDomai n().DefineDynam icAssembly(assN ame,
AssemblyBuilder Access.RunAndSa ve,outputPath);

[Code to sign the satellite assebly here (?)]
ModuleBuilder modBuilder = assBuilder.Defi neDynamicModule (assName.Name +
".dll", assName.Name + ".dll", true);
IResourceWriter resourceWriter = modBuilder.Defi neResource(asse mblyName +
"." + culture + ".resources ",

assemblyName + "." + culture + ".resources ",

ResourceAttribu tes.Public);

resStream.Seek( 0,System.IO.See kOrigin.Begin);

// We need ResourceSet object for its GetObject function, to get images and
other binary objects.

System.Resource s.ResourceReade r reader = new
System.Resource s.ResourceReade r(resStream);

ResourceSet rs = new ResourceSet(rea der);

IDictionaryEnum erator resourcesEnumer ator = reader.GetEnume rator();

while(resources Enumerator.Move Next())

{

if(resourcesEnu merator.Value.G etType().ToStri ng().ToLower() ==
"system.string" )

{

resourceWriter. AddResource(res ourcesEnumerato r.Key.ToString( ),resourcesEnum e
rator.Value.ToS tring());

}

else

{

resourceWriter. AddResource(res ourcesEnumerato r.Key.ToString( ),rs.GetObject( r
esourcesEnumera tor.Key.ToStrin g()));

}

}

reader.Close();

rs.Close();
Diag.Trace.Writ e("Saving assembly to: " + assemblyPath + "\\" + assemblyName
+ ".resources.dll ");

assBuilder.Save (assemblyName + ".resources.dll ");


-----------------------------
Mário Sobral
Inosat
Research & Development
-----------------------------


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
276
by: Ice | last post by:
All - I read out on MSDN that "If your main assembly uses strong naming, satellite assemblies must be signed with the same private key as the main assembly." Well if you allow the regeneration of resources at client sites, this forces you to have to ship your strong name also. Anyone know any workarounds for this.
3
7570
by: Nils Erik Asmundvaag | last post by:
Hello I hope someone is able to help me with this frustrating problem. I have a C# web project in Visual Studio .NET 2003. I want to support Swedish and Norwegian texts and have put the texts in resource files (.resx). I build the project from the IDE without errors. A main assembly (containing the Swedish texts) are created, and a resource assembly
0
1212
by: Mário Sobral | last post by:
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...
1
6933
by: Afaq | last post by:
Hi, After adding large number of empty resource files (which will be updated later), we are not able to compile the project. the following is the output of the build process. It fails while compiling the Max.UI.Win project with the following error Satellite assemblies could not be built because the main project output is missing.
0
1579
by: thbst16 | last post by:
After a number of weeks of fruitless research and experimentation, I decided to turn to the group with this issue and see if anyone had any experiences or insights that might help me out. Here's what I'm facing: · Deploying Windows Form client using Zero Touch deployment. · I use a variant of Rocky Lhotka's NetRun utility to bootstrap the application. This utility is client resident and sets permissions to "Full Trust" prior to invoking...
5
10057
by: Rudolf Ball | last post by:
Dear NG, i want to load a plugin (WinForm) in my Applikation. That works fine. Now I want to globalize that plugin. So I have to load the Satellite Assembly, as well. But how can I load this (and when?). Thank you very much Rudi
5
2061
by: Chua Wen Ching | last post by:
Hi all, Basically right now, i am interested to learn how to break strong names in ..net assemblies. I had researched a lot and found a blog that mention how to hack strong name assemblies. http://blogs.msdn.com/shawnfa/archive/2004/08/20/218049.aspx " In order to enable post-build modifications, you need to either:
3
1681
by: Adam Calderon | last post by:
In ASP.NET 2.0 you have the choice of using the built in App_GlobalResoruces or App_LocalResources style of using resources or you can use your own resources utilizing satellite assemblies. In the SDK under "Resources in ASP.NET Applications" the documentation demonstrates how to use your own satellite assemblies and instructs you to build a folder structure under the bin folder. Following all of the correct procedures (taking an resx file...
0
1497
by: Faris Ahmed | last post by:
Dear ASP newsgroup, I have the following environment: 1) VS2005 ASP.NET 2.0 WebApplication called MyApp. 2) MyApp contains Strings.resx, Strings.en.resx and Strings.de.resx in 'App_GlobalResources' folder. 3) MyApp contains standard AssemblyVersion and AssemblyInformationalVersion
1
1509
by: scpedicini | last post by:
Let's say that I've built an assembly, called myapi.dll whose default resource messages are english. Then let's say I create a german satellite assembly for the assembly called myapi.de.resources.dll. However, let's say that I have a german client who is using both myapi.dll and myapi.de.resources.dll; however, they would like to override a single resource string from myapi.de.resources.dll. Is it possible for them to create a "satellite...
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9200
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.