Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / March 2006

Tip: Looking for answers? Try searching our database.

Any workaround for .NET 1.1 runtime calling CoInitializeSecurity before starting my app, on localized OSs

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gauravl@gmail.com - 10 Mar 2006 06:01 GMT
I've been chasing this frustrating problem for a while, and have
finally got some handle on whats going on.

We've got a C# service that needs to call CoInitializeSecurity with
appropriate settings (so that we can call into Virtual Server's COM API
successfully).  This works fine on on English Win2K3.  On
Japanese/Chinese Win2k3, the call fails 3-4 times (0x80010119,
RPC_E_TOO_LATE) and then works fine.

Pinvoke suggests that CoInitializeSecurity is a bad idea from managed
code, since the CLR may call it before.
http://www.pinvoke.net/default.aspx/ole32/CoInitializeSecurity.html

I've used WinDbg to get the stack of the thread thats calling
CoInitializeSecurity (listed below).  It has something to do with
Satellite Assemblies, which explains why its happening on localized
OS's only.

1. I'm trying to understand what is going on, and why this starts to
work after 3-4 times.  That might help me come up with a solution

2. Does anyone know of a solution for this problem ?
(The best i have right now is to write an unmanaged service to host the
managed app, but i'm a little wary of such a big change).

Thanks,

Gaurav

0:000> kb
ChildEBP RetAddr  Args to Child
0012e794 7744f372 00000000 ffffffff 00000000 ole32!CoInitializeSecurity
0012e7c4 775476e8 001606c0 00000000 00000000
ole32!InitializeSecurity+0x3b
0012e7e0 7744f1be 001606c0 00000000 7c983b20
ole32!ChannelProcessInitialize+0x16a
0012e814 7744f102 001757cc 00000000 775495ce
ole32!CComApartment::InitRemoting+0xaa
0012e820 775495ce 001757cc 001606c0 0012e83c
ole32!CComApartment::StartServer+0x13
0012e830 7744d21c 00150860 0012e84c 7920ea47
ole32!InitChannelIfNecessary+0x1e
0012e83c 7920ea47 791bb890 001757cc 0012e8b8
ole32!CoGetObjectContext+0x11
0012e84c 7920f542 001757cc 00150b58 001757c0
mscorwks!GetCurrentObjCtx+0x39
0012e8b8 7920f5d6 00170e98 001758c8 0016c290
mscorwks!CtxEntry::Init+0x83
0012e8d8 7920397b 0016c290 00000000 00170e98
mscorwks!CtxEntryCache::FindCtxEntry+0x92
0012e8fc 792039f1 00170e98 00000000 00150860
mscorwks!IUnkEntry::Init+0x66
0012e914 79203879 00170e98 00170e98 00150860
mscorwks!ComPlusWrapper::Init+0x37
0012e940 792036d2 00170e98 00170e98 00150860
mscorwks!ComPlusWrapperCache::CreateComPlusWrapper+0x56
0012e980 7920364f 00000000 00000000 00000000
mscorwks!COMInterfaceMarshaler::CreateObjectRef+0x16
0012e990 79201b25 00000000 00170e98 00150860
mscorwks!COMInterfaceMarshaler::FindOrCreateObjectRef+0x43
0012ee38 7932dd3a 00000000 00000000 00000000
mscorwks!GetObjectRefFromComIP+0x1c5
*** WARNING: Unable to verify checksum for
c:\windows\assembly\nativeimages1_v1.1.4322\mscorlib\1.0.5000.0__b77a5c561934e089_b6d2f0fd\mscorlib.dll
*** ERROR: Module load completed but symbols could not be loaded for
c:\windows\assembly\nativeimages1_v1.1.4322\mscorlib\1.0.5000.0__b77a5c561934e089_b6d2f0fd\mscorlib.dll
0012ee7c 799edb43 01bd2180 00bf411c 0012ef08
mscorwks!ConfigNative::GetHelper+0x42
WARNING: Stack unwind information not available. Following frames may
be wrong.
0012eeb4 79a68268 00000001 00bf3930 01bd2180 mscorlib_79990000+0x5db43
0012ef2c 79a680ed 0012ef88 00bf24d4 00bf3644 mscorlib_79990000+0xd8268
0012ef44 799acb2e 00bf0ec0 00bf2860 00bf24d4 mscorlib_79990000+0xd80ed

0:000> !clrstack
succeeded
Loaded Son of Strike data table version 5 from
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\mscorwks.dll"
Thread 0
ESP       EIP
0012e9d8  7744dfd5 [FRAME: GCFrame]
0012ee74  7744dfd5 [FRAME: ECallMethodFrame] [DEFAULT] Class
System.IConfigHelper System.ConfigServer.GetHelper()
0012ee84  799edb43 [DEFAULT] [hasThis] Class System.ConfigNode
System.ConfigTreeParser.Parse(String,String,Boolean)
0012eec4  79a68268 [DEFAULT] [hasThis] Class
System.Collections.Hashtable
System.Resources.ResourceManager.GetSatelliteAssembliesFromConfig()
0012ef34  79a680ed [DEFAULT] [hasThis] Boolean
System.Resources.ResourceManager.TryLookingForSatellite(Class
System.Globalization.CultureInfo)
0012ef4c  799acb2e [DEFAULT] [hasThis] Class
System.Resources.ResourceSet
System.Resources.ResourceManager.InternalGetResourceSet(Class
System.Globalization.CultureInfo,Boolean,Boolean)
0012ef98  799ac848 [DEFAULT] [hasThis] String
System.Resources.ResourceManager.GetString(String,Class
System.Globalization.CultureInfo)
0012efcc  799b32fb [DEFAULT] String
System.Environment.GetResourceString(String)
0012effc  79a95953 [DEFAULT] [hasThis] Void
System.Security.Policy.PolicyLevel.FromXml(Class
System.Security.SecurityElement)
0012f040  79a90e52 [DEFAULT] [hasThis] Void
System.Security.Policy.PolicyLevel.Load(Boolean)
0012f074  79a909ab [DEFAULT] [hasThis] Void
System.Security.Policy.PolicyLevel.IndividualCheckLoaded(Boolean)
0012f0a4  79a908d2 [DEFAULT] [hasThis] Void
System.Security.Policy.PolicyLevel.CheckLoaded(Boolean)
0012f0e0  799a2f07 [DEFAULT] [hasThis] Class
System.Security.Policy.PolicyStatement
System.Security.Policy.PolicyLevel.Resolve(Class
System.Security.Policy.Evidence,I4,SZArray Char)
c0000005 Exception in
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\sos.clrstack debugger
extension.
     PC: 6028d1b4  VA: 00c12000  R/W: 0  Parameter: 0001003f
gauravl@gmail.com - 11 Mar 2006 00:06 GMT
On further investigation, i've found that this is happening because of
the presence of the .config file.  Blowing away the config file 'fixes'
the problem.  The stack further confirms this, since its trying to do
something with the config

mscorwks!ConfigNative::GetHelper+0x42

0012ee74  7744dfd5 Class System.IConfigHelper
System.ConfigServer.GetHelper()

It still doesnt explain why this happens only on chinese/japanese.
Nor does it explain why this works after a few tries.  Does the
app.config get cached somewhere?
gauravl@gmail.com - 11 Mar 2006 00:52 GMT
Sill more investigation revealed that 2 files (security.config.cch,
enterprisesec.config.cch) are changed in
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\CONFIG"

The new lines added are for 'unrestricted' permission settings for each
of the assemblies in my application.  They are part of a cache, which
explains why it takes 3-4 times for the problem to appear (it probably
takes time for the clr to reread its configuration)

Blowing the .cch files away brings the problem back, ie causes the CLR
to call CoInitializeSecurity when starting the app.

I suspect that the machine.config settings on my english machine are
less restrictive than those on my japanese machine.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.