asp.net - System.Web.Globalization namespace introduced with .NET 4.6.2 conflicts at runtime with System.Globalization -


after installing windows 10 anniversary update on weekend, includes .net framework 4.6.2, code stopped working. i've gone version of 1 week ago make sure it's not related our code.

at runtime, error thrown:

error bc30561: 'globalization' ambiguous, imported namespaces or types 'system.web, system'.

stack trace:

system.web.httpcompileexception (0x80004005): c:\path\to\project\masterpages\sitemaster.master(71): error bc30561: 'globalization' ambiguous, imported namespaces or types 'system.web, system'.    @ system.web.compilation.buildmanager.postprocessfoundbuildresult(buildresult result, boolean keyfromvpp, virtualpath virtualpath)    @ system.web.compilation.buildmanager.getbuildresultfromcacheinternal(string cachekey, boolean keyfromvpp, virtualpath virtualpath, int64 hashcode, boolean ensureisuptodate)    @ system.web.compilation.buildmanager.getvpathbuildresultfromcacheinternal(virtualpath virtualpath, boolean ensureisuptodate)    @ system.web.compilation.buildmanager.getvpathbuildresultinternal(virtualpath virtualpath, boolean nobuild, boolean allowcrossapp, boolean allowbuildinprecompile, boolean throwifnotfound, boolean ensureisuptodate)    @ system.web.compilation.buildmanager.getvpathbuildresultwithnoassert(httpcontext context, virtualpath virtualpath, boolean nobuild, boolean allowcrossapp, boolean allowbuildinprecompile, boolean throwifnotfound, boolean ensureisuptodate)    @ system.web.compilation.buildmanager.getvpathbuildresult(httpcontext context, virtualpath virtualpath, boolean nobuild, boolean allowcrossapp, boolean allowbuildinprecompile, boolean ensureisuptodate)    @ system.web.ui.basetemplateparser.getreferencedtype(virtualpath virtualpath, boolean allownocompile)    @ system.web.ui.pageparser.processmaindirectiveattribute(string devicename, string name, string value, idictionary parsedata)    @ system.web.ui.templateparser.processmaindirective(idictionary maindirective) 

this offending line:

$.setlanguage("<%= globalization.cultureinfo.currentuiculture.twoletterisolanguagename %>"); 

replacing globalization system.globalization fixes problem, visual studio suggests "name can simplified", indicating system not necessary.

when setting breakpoint @ offending line, can same error via immediate window:

globalization.cultureinfo.currentuiculture error bc30560: 'cultureinfo' ambiguous in namespace 'system.globalization'. 

if understand correctly, there both system.globalization , system.web.globalization. according the api diff, new namespace introduced, seems causing issue.

+namespace system.web.globalization { +    public interface istringlocalizerprovider { +        string getlocalizedstring(cultureinfo culture, string name, params object[] arguments); +    } +    public sealed class resourcefilestringlocalizerprovider : istringlocalizerprovider { +        public const string resourcefilename = "dataannotation.localization"; +        public resourcefilestringlocalizerprovider(); +        public string getlocalizedstring(cultureinfo culture, string name, params object[] arguments); +    } +    public static class stringlocalizerproviders { +        public static istringlocalizerprovider dataannotationstringlocalizerprovider { get; set; } +    } +} 

why error appear @ runtime? how can make fail @ compile time?

bug crusher's answer correct. address stijn's comment answer, search project "globalization." , remove every instance of it. wouldn't use find + replace may have unintended side effects.

then make sure each file edited has correct import or using statement on top.

vb- imports system.globalization

c#- using system.globalization;

that's fix vs would've proposed.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -