C # Reading resource .resx file outside throws assembly MissingManifestResourceException

I am working on a project that consists of an Asp.Net web application and a Windows application. These two can use the collaborative project that I created to contain resource files. I wanted to put resource files outside the assembly, so when I want to change them, they can be edited without compiling the whole solution. I am looking for a method and find it as follows:

ASP.NET Resourcemanager for reading local .resx

It worked fine in a web application, but after a while I saw that the Windows service application could not read these resources, and I got

System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture (or the neutral culture) on disk. baseName: abc locationInfo: <null> fileName: abc.resx at System.Resources.FileBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture, Boolean wrapUnmanagedMemStream) at System.Resources.ResourceManager.GetObject(String name, CultureInfo culture) at yyyy.yyyyyy.yyyyyyy.GetGlobalResourceObject(String classKey, String resourceKey, Boolean getCommon) at xxx.xxx.xxx.Entities.xxxxxxxx.get_LocalizedName() at yyyyy.Adapters.ArchiverDtoAdapter.CreateArchiverInjectionsDto(InjectionProcedure procedure, INamingService namingService) at yyyyy.Adapters.ArchiverDtoAdapter.ConvertInjectionProcedureDto(InjectionProcedure procedure, INamingService namingService) at yyyy.Factories.ArchiverDtoFactory.<>c__DisplayClass1.<CreateInjectionProcedureSendRequestDto>b__0(IUnitOfWork unitOfWork) at Core.Data.NHibernate.Factory.UnitOfWorkFactoryBase.Create(Action`1 action, IUnitOfWork unitOfWork) at Core.Data.NHibernate.Factory.UnitOfWorkFactory.Create(Action`1 action) 

I do not understand the problem, because, I am working correctly, and the other is not. Another strange behavior is that when I start the service on my machine with debugging to find out what is happening, it works.

Update: This is the code I'm using as a link.

 public class ResxResourceManager : ResourceManager { public ResxResourceManager(string baseName, string resourceDir) { ObjectFactory.ResolveDependencies(this); Type[] paramTypes = new Type[] { typeof(string), typeof(string), typeof(Type) }; object[] paramValues = new object[] { baseName, resourceDir, typeof(ResXResourceSet) }; Type baseType = GetType().BaseType; ConstructorInfo ci = baseType.GetConstructor( BindingFlags.Instance | BindingFlags.NonPublic, null, paramTypes, null); ci.Invoke(this, paramValues); } protected override string GetResourceFileName(CultureInfo culture) { string resourceFileName = base.GetResourceFileName(culture); return resourceFileName.Replace(".resources", ".resx"); } } 
+6
source share
1 answer

Please take a look at this. Hope this helps.

http://support.microsoft.com/kb/839861

0
source

Source: https://habr.com/ru/post/971754/


All Articles