How can I reuse .NET resources across multiple executables?

I have an existing application that I need to take and create a "mini" version. Both are localized apps and we would like to reuse resources in the main app as they are. So here is the basic structure of my applications:

MainApplication.csproj

/Properties/Resources.resx

/MainUserControl.xaml(Uses strings in /Resources.resx properties)

/MainUserControl.xaml.cs


MiniApplication.csproj

link to MainApplication / Properties / Resources.resx

link to MainApplication / MainUserControl.xaml

link to MainApplication / MainUserControl.xaml.cs

MiniApplication.xaml (tries to use MainUserControl from MainApplication link)

So, in general, I added the required resources and user control from the main application as links to the widget. However, when I run the widget, I get the following exception. I am guessing it has different namespace problems, but how can I fix it?

Could not find resources suitable for the specified culture or neutral culture. Make sure \ "MainApplication.Properties.Resources.resources \" has been properly embedded or linked to the "MiniApplication" assembly at compile time, or that all satellite assemblies are required to be downloadable and fully signed.

FYI, I know I can put a custom control in a custom control library, but the problem is that the widget needs to be small. Therefore, we want to include only what we need.

+2


a source to share


2 answers


You are correct that different namespaces are a problem. Unable to provide a resource file for the namespace, it will occupy the namespace of the folder that contains it. If the namespaces are different in your two applications, the namespace will be different.

I see three options available to you



  • Use the same default namespace for both applications.
  • You have an assembly just for your resource file and referenced to it in both apps
  • In the code that loads the resource, generate a namespace based on the namespace of the class that loads it
+2


a source


The assets created by visual studio are not publicly available, they are only visible to classes in the library. to generate resources as public properties you will need to use a custom generator like this: http://www.codeproject.com/kb/dotnet/ResXFileCodeGeneratorEx.aspx



0


a source







All Articles