c++ cli - How does the .NET COM Callable Wrapper generate IIDs? -
viewing generated tlb file created ccw though ole/com object viewer shows iid remains constant unless change design of interface (which correct behaviour), concern if compile same code on machine different iid generated despite interface not changing , hence breaking existing com clients.
- how com interface ids generated com callable wrapper?
- how ccw know if interface has changed , needs generate new iid?
- would safer generate own , declare in source file?
the guid type not specific com interop, .net types have guid. can obtain type.guid property. code in clr generates available sscli20 distribution. can have look-see @ algorithm checking out code in clr/scr/vm/methodtable.cpp, methodtable::getguid() method.
summarizing algorithm:
- if type has [guid] attribute return that
- if type interface type generate stringized version of interface type definition. done getstringizeditfdef() in interoputil.cpp. starts qualified type name , appends string version of each member definition.
- for other types, generate stringized version of class. starts qualified type name, appends class name , appends qualified assembly name.
- the resulting string hashed guid helper function corguidfromnamew().
this enough info answer questions:
how com interface ids generated com callable wrapper?
it uses type.guid generated algorithm above. none of elements in algorithm specific machine executed on don't have fear getting different iids , clsids on different build machines.
how ccw know if interface has changed , needs generate new iid?
it doesn't. purely relies on algorithm producing different guids different interface definitions.
would safer generate own , declare in source file?
not really. there's no documented failure mode algorithm. using own [guid] attribute increases odds you'll forget change when have to. shortcut that's taken , primary source of dll hell. nasty kind, kind makes client crash near-impossible diagnose hardware exceptions. opposed still-hard-but-not-impossible kind of e_nointerface. there 2 disadvantages can think of relying on auto-generated guid: tends cause registry pollution on dev machine when forget unregister assemblies before rebuilding them. , slows down bit when you're troubleshooting com errors because don't readily know guids. admittedly, registry pollution enough reason me.
Comments
Post a Comment