-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing resource strings from external assembly always returns default strings instead of string based on culture info. #2041
Comments
@tarekgh is it known issue? Can you please help me route it? Thanks! |
@mailfcly could you send more info how did you build the assemblies and what framework and version you are targeting? could you please share a small project repro this? |
CC @sdmaclea @mailfcly are you using net core in your project? I just want to confirm. If this is the case, @jeffschwMSFT mentioned, satellite assemblies will not be found with LoadFrom... you need to subscribe to the resolve event to find them. |
build with my code: |
@sdmaclea I assigned this one to you. could you please have a look why the satellite assembly didn't get loaded? |
Sorry, I meant to assign it to @sdmaclea |
@sdmaclea should we move the bug to CoreCLR? I see you have a fix there ... |
I opened dotnet/coreclr#20979 to address this inconvenience. I will post a work-around here then close this issue. |
@mailfcly The current releases require adding a resolve handler. As mentioned above. This is sample code that worked for me based on @jeffschwMSFT's suggestion. namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolveEventHandler);
var assembly = Assembly.LoadFile(@"C:\Users\stmaclea\issues\2041\ConsoleApp1\ConsoleApp1\ClassLibrary2\bin\Debug\netcoreapp2.1\ClassLibrary2.dll");
var a = assembly.GetManifestResourceNames();
foreach(var type in assembly.GetTypes())
{
if(type.FullName.Contains("ClassLibrary2.Class1"))
{
var itemList = Activator.CreateInstance(type) as ClassLibrary1.IClass1;
itemList.OutputText();
}
}
}
static System.Reflection.Assembly AssemblyResolveEventHandler(object sender, ResolveEventArgs args)
{
if (args.Name == "ClassLibrary2.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null")
{
return Assembly.LoadFile(@"C:\Users\stmaclea\issues\2041\ConsoleApp1\ConsoleApp1\ClassLibrary2\bin\Debug\netcoreapp2.1\en\ClassLibrary2.resources.dll");
}
return null;
}
}
} This issue belongs in the coreclr repo. Closing here as dotnet/coreclr#20979 is opened to address the long term fix. |
Issue Title
Accessing resource strings from external assembly always returns default strings instead of string based on culture info.
Code in ClassLibrary2.dll
Code in MainApp.exe
Expected result
output text from Resources.en.resx
Actual result
output text from Resources.resx
The text was updated successfully, but these errors were encountered: