The AppDomain AssemblyResolve event is querying Microsoft.Practices.EnterpriseLibrary.Common.resources

I wrote my own AssemblyResolve method to handle the assembly in a folder other than the exe file. But as soon as it shows the lack of "Microsoft.Practices.EnterpriseLibrary.Common.resources". Although I have Microsoft.Practices.EnterpriseLibrary.Common.dll, I do not have Microsoft.Practices.EnterpriseLibrary.Common.resources.dll. How to manually download Microsoft.Practices.EnterpriseLibrary.Common.resources?

protected Assembly ConfigResolveEventHandler(object sender, ResolveEventArgs args)
        {
            //This handler is called only when the common language runtime tries to bind to the assembly and fails.

            //Retrieve the list of referenced assemblies in an array of AssemblyName.
            string strTempAssmbPath = "";
            Assembly asm = this.GetType().Assembly;

            var uri = new Uri(Path.GetDirectoryName(asm.CodeBase));


            Assembly objExecutingAssemblies = Assembly.GetExecutingAssembly();
            AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies();

            //Loop through the array of referenced assembly names.
            if (arrReferencedAssmbNames.Any(strAssmbName => strAssmbName.Name == args.Name))
            {
                strTempAssmbPath = Path.Combine(uri.LocalPath, args.Name) + ".dll";
            }
            //Load the assembly from the specified path.                    
            Assembly myAssembly = Assembly.LoadFrom(strTempAssmbPath);

            //Return the loaded assembly.
            return myAssembly;  
        }
+3
source share
2 answers

The issue was discussed on Microsoft Connect .

Suggested Solution: Add the following assembly to AssemblyInfo.cs:

[assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.MainAssembly)]
+3
source

AssemblyResolve. , Windows XP. , NeutralResourcesLanguageAttribute. .NET v3.5, AssemblyResolve .NET v4.0:

. .NET Framework 4, ResolveEventHandler , . . , : .

, e.Name , *.Resources.dll. AppDomain , ".Resources" *.dll. , . .

+2

All Articles