Two writing unsafe code
a) fixed keyword
The code embodies the fixed usage: fixed (type* ptr= expression) {...} , type is an unmanaged type or void type like int*, expression is an arbitrary expression that can be returned as a type* pointer, and the fixed variable can only be in {...} Used in the.
The above code runs after the foo.x=42. Can only understand this point.
Three COM Interop
The interaction of COM components with the. NET runtime is done through COM interop. This involves a lot of knowledge of COM components, previously only used in the operation of Word Microsoft.Office.Interop.Word, here is only about to understand.
A) The COM component of the instance is Airlineinfo COM, and the public method is:
. NET can only use components that contain metadata (metadata), but not inside COM, presumably with implementations of some registration and similar interfaces. Therefore, the corresponding metadata is generated for the COM before it is manipulated. This work is done by the metadata layer, which handles information related to the data type and then generates the RCW based on these types of information (runtime callable Wrapper Runtime callable wrapper). The RCW is responsible for the activation, Marshal, and lifecycle management of COM objects.
b) Use Tlbimp.exe to generate a. dll file based on a COM file with the suffix. tlb, and then use the class and metadata in the DLL as you would with a normal class.
c) Using the method mentioned in B (early bound) will be strong type checking, auto-completion and other characteristics, but sometimes not at compile time to know the COM object's metadata, then you need to use late binding method.
?
You can call a method using Type.gettypefromprogid reflection as long as you know the name of a method in a COM component.
Learning materials: Inside C # by Tom Archer
"Inside C #" notes (15) under unmanaged code