c# - Windows Forms Threads are losing their culture -
we have .net 3.5 multi-threaded windows forms application. is launching 4-5 background workers/ async calls retrieve data. 1 in 10 times, 1 of threads throws following error. error null exception instead same exact call stack. have tracked issue down thread somehow losing cultureinfo. else ran this?
system.threading.synchronizationlockexception: object synchronization method called unsynchronized block of code. @ system.globalization.culturetablerecord.getculturetablerecord(string name, boolean useuseroverride) @ system.globalization.culturetablerecord.getculturetablerecord(int32 cultureid, boolean useuseroverride) @ system.globalization.cultureinfo..ctor(int32 culture, boolean useuseroverride) @ system.globalization.cultureinfo.getculturebylcidorname(int32 preferlcid, string fallbacktostring) @ system.globalization.cultureinfo.inituserdefaultuiculture() @ system.globalization.cultureinfo.get_userdefaultuiculture() @ system.threading.thread.get_currentuiculture() @ system.resources.resourcemanager.getstring(string name, cultureinfo culture) @ system.environment.resourcehelper.getresourcestringcode(object userdatain) @ system.environment.getresourcefromdefault(string key) @ system.diagnostics.stacktrace.tostring(traceformat traceformat) @ system.environment.getstacktrace(exception e, boolean needfileinfo) @ system.io.streamwriter.init(stream stream, encoding encoding, int32 buffersize) @ system.io.streamwriter..ctor(stream stream, encoding encoding, int32 buffersize) @ system.web.services.protocols.soaphttpclientprotocol.getwriterformessage(soapclientmessage message, int32 buffersize) @ system.web.services.protocols.soaphttpclientprotocol.serialize(soapclientmessage message) @ system.web.services.protocols.soaphttpclientprotocol.invoke(string methodname, object[] parameters)
try playing default culture entire domain using cultureinfo.defaultthreadcurrentculture
and/or cultureinfo.defaultthreadcurrentuiculture
, see if helps. in all, you'll able ensure whether it's related thread's culture
upd: specific exception may thrown when using sync methods lock
, monitor
, etc on value types, calls sync methods will box value, creating new 1 every time. doubt such serios bug in framework.
can check synchronization code?
upd2: ok, let's try debug.
first off, turn on break on every exception thrown
next, enable .net framework debugging locate error
after that, there high chance workaround/solution problem
Comments
Post a Comment