IDL custom attribute recognized by type library importer, 692–693
IDL definition of IHTMLStyleSheet interface, 988–989
IDL definition of IRunningAppCollection, 975–976
IDL definition of the IWMPEffects interface, 964
IDL definitions of INetMeetingEvents dispinterface and INetMeeting interface, 1007–1008
IDL representation of the AddressLists dispinterface, 982
IDL Representation of Two Modules, 187–188
IEnumVARIANT parameters transformed to IEnumerator types, 153
implementing System.Reflection.Ireflect, 668–672
implementing two COM interfaces, 636, 643–646
Importer.cs., 1070–1083
Incorrect C# Source Code, 546–547
Instantiating a Remote COM Object, 871, 873–874
Interface Hierarchy Exported to COM, 744–746
IntroScreen.cs., 1156–1157
Invoking an Unmanaged Function Pointer, 818, 820–821
IPersist and IPersistStream Interfaces in C#, 985–987, 1000–1001
IPersist and IPersistStream Interfaces in IDL, 985
IRunningAppCollection definition in C#, 976–979
IRunningAppCollection definition in VB .NET, 980–981
IWMPEffects.cs., 1202–1204, 1209–1222
Layer.cs., 1151–1152
Making PInvoke Methods Throw Exceptions Upon Failure using PreserveSig, 803–805
Marking a strongly-type GetEnumerator method with DispIdAttribute, 525–527
Marking an Array Parameter with InAttribute and OutAttribute in C#, 792–794
MarshaledStructInspector.DisplayStruct, 845–847
Metadata Definitions of Documents.Add and Application.Quit, 343–345
Metadata for the ISearch Interface with Added DescriptionAttributes, 361–363
Metadata Generated by the Type Library Importer for the Recordset.ActiveConnection Property, 992–993
metadata in IL Assembler syntax, 967–971
MiscTypes.cs., 1064–1068
.NET and COM representations of two classes implemented, 636
.NET Definition of AddressLists in Visual C++ .NET, 982–984
.NET Definition of UCOMIStream Shown in C# Syntax, 883, 888
.NET definitions of the RECT and TimedLevel Structures, 1021
.NET interfaces with conflicting capitalization of the same indentifier, 503–504
.NET View and COM View of same methods By-Value and By-Reference parameters, 436–438
.NET View and COM View of the same methods, 434–436
.NET View and COM View of the same overloaded methods, 438–439
.NET view of Conformant Arrays, 160
NumerPicture.cs., 1147–1150
Object class interface, 439–440
Obtaining an Error String from an Error Code, 802
Performing Manual SAFEARRAY Marshaling in C#, 273–275
Performing Manual VARIANT Marshaling in C#, 267, 270–272
Picture.cs., 1136–1139
PresetEnumAttribute.cs., 1222–1223
ReadConsoleInput, 865–868
Registrar.cs., 1093–1097
Screen.cs., 1155–1156
Simple Struct, 189–191
SimpleVisualization.vb, 1224–1226
Sound.cs., 1134–1136
StreamMarshaler.cs., 901–903, 905
StringValidator.cs., 380–381
structure definitions, 1020
SupportingType.cs., 1204–1208
System.Reflection.MemberInfo, 490, 492
System.Runtime.Interop-Services.UCOMI-Connection, 676
System.Runtime.Interop-Services.UCOMI-ConnectionPointContainer, 675–676
SetConsoleCtrlHandler Function, 816–817
StringMarshaler Custom Marshaler, 943–947
Traditional ADO, 93–94
translation of IWMPEffects to C#, 965–966
.NET customizations, 1002
customizations, 967
Tricks with COM, 477–482
Two Versions of a C# Client, 345–348
Unmanaged C++ Code, 404–407, 727
Unmanaged Enum and Managed Enum, 193–194
Unmanaged Union Converted to a .NET Value Type, 191–192
Unmanaged Visual C++ Code Using a .NET Class, 385–388
VB6Form.frm, 921–923
Windows Handle Wrapping, 853, 856
WizardVisualization.cs, 1227–1230
LoadAndDisplayAssembly method, 1097
LoadBalancingSupportedAttribute, 585
LoadTypeLibEx class, 1066
LoadTypeLibEx method, 1042–1043
Local Identifier. See LCID
LocaleID parameters, 644
location of property accessors, 990–994
LocationX field, 1158
LocationY field, 1158
lostLifeSound field, 1121
LPArray, UnamangedType enumeration values, 550
LPSTR, 149–150
LPStr value, 834
LPTStr value, 834
LPWSTR, 149–150
LPWStr value, 834
luring attacks, 306
MainForm class, 1100–1101
MainForm class (Interactive Interop Tool), 1100–1101
MakeVisibleAndInfected method, 1162, 1166
managed code, 48
adapter objects, 905–909
connection points, 218–222
connectable objects, 229–235
lazy connection point initialization, 227–229
type library importer transformation, 222–227
debugging COM Interoperability calls to unmanaged code, 315–319
interaction with unmanaged code, 49
C++ extensions, 50–51
COM Interoperability, 51–53, 69–71
JUMP to .NET, 51
PInvoke, 49–50
invoking unmanaged pointers in, 818–821
managed compilers, 15
managed extensions, C++, 42
managed languages, 15
managed resources, assemblies, 326
ManagedForm assembly, 923
ManagedIStream class, 889–895
ManualResetEvent instance, 289
Marshal class, 250, 263, 270, 306, 1067, 1292–1294
methods
AddRef, 1294
AllocCoTaskMem, 1295
AllocHGlobal, 1295
BindToMoniker, 1296
ChangeWrapperHandleStrength, 1296–1297
Copy, 1297–1298
CreateWrapperOfType, 1298–1299
DestroyStructure, 1299
FreeBSTR, 1299–1300
FreeCoTaskMem, 1300
FreeHGlobal, 1300
GenerateGuidForType, 1301
GenerateProgIdForType, 1301
GetActiveObject, 1301
GetComInterfaceFor-Object, 1302
GetComObjectData, 1303
GetComSlotForMethod-Info, 1303
GetEndComSlot, 1303
GetExceptionCode, 1303–1304
GetExceptionPointers, 1304
GetHINSTANCE, 1304
GetHRForException, 1304–1305
GetHRForLastWin32-Error, 1305
GetIDispatchForObject, 1305–1306
GetITypeInfoForType, 1306
GetIUnknownForObject, 1306–1307
GetLastWin32Error, 1307
GetManagedThunkForUnmanagedMethod-Ptr, 1307
GetMethodInfoForComSlot, 1308
GetNativeVariantFor-Object, 1308–1309
GetObjectForIUnknown, 1309
GetObjectForNative-Variant, 272, 1309
GetObjectsForNative-Variants, 1310
GetStartComSlot, 1310–1311
GetThreadFromFiber-Cookie, 1311
GetTypedObjectForI-Unknown, 1311
GetTypeForITypeInfo, 1311–1312
GetTypeInfoName, 1312
GetTypeLibGuid, 1312
GetTypeLibGuidFor-Assembly, 1312
GetTypeLibLcid, 1313
GetTypeLibName, 1313
GetUnmanagedThunk-ForManagedMethod-Ptr, 1313–1314
IsComObject, 1314
IsTypeVisibleFromCom, 1314
NumParamBytes, 1314
OffsetOf, 1314–1315
Prelink, 1315–1316
PrelinkAll, 1316
PtrToStringAnsi, 1316–1317
PtrToStringAuto, 1317–1318
PtrToStringBSTR, 1318
PtrToStringUni, 1319
PtrToStructure, 1319–1321
QueryInterface, 1321–1323
ReadByte, 1323–1325
ReadInt16, 1326
ReadInt32, 1326–1327
ReadInt64, 1327
ReadIntPtr, 1327–1328
ReAllocCoTaskMem, 1328
ReAllocHGlobal, 1328–1329
Release, 1329–1330
ReleaseComObject, 1330
ReleaseThreadCache, 1330
SetComObjectData, 1331
SizeOf, 1331
StringToBSTR, 1331–1332
StringToCoTaskMem-Ansi, 1332
StringToCoTaskMem-Auto, 1332
StringToCoTaskMem-Uni, 1333
StringToHGlobalAnsi, 1333
StringToHGlobalAuto, 1333–1334
StringToHGlobalUni, 1334
StructureToPtr, 1334–1336
ThrowExceptionForHR, 1336–1337
UnsafeAddrOfPinned-ArrayElement, 1337
WriteByte, 1337–1339
WriteInt16, 1340
WriteInt32, 1340–1341
WriteInt64, 1341
WriteIntPtr, 1342
properties
SystemDefaultCharSize, 1336
SystemMaxDBCSChar-Size, 1336
Marshal.ReleaseCom-Object, 299–304
Marshal.ReleaseComObject method, 110
Marshal.SizeOf method, 839
MarshalAsAttribute, 895, 898, 1222, 1342–1344
C# signatures, 899–901
COM interface shortcuts, 651
customizing arrays, 549–550
customizing data types, 541–549, 552–553
customizing structures, 834–839
detecting errors in, 552–553
Inherited property, 546
ArraySubType, 1343
Boolean, 1343
MarshalCookie, 1343
MarshalType, 1343
MarshalTypeRef, 1343
object, 1343
SafeArraySubType, 1343
SafeArrayUserDefined-SubType, 1344
SizeConst, 1344
SizeParamIndex, 1344
strings, 1342
syntax, 334–335
SafeArraySubType parameter, 338–340
UnmanagedType.LPArray class, 337
UnmanagedType.Safe-Array class, 337
UnmanagedType enumeration, 542–545, 550–552
ByValArray, 549
LPArray, 550
UnmanagedType values, 834
MarshalCookie parameter (MarshalAsAttribute), 898, 1343
MarshalDirectiveException (System.Runtime.InteropServices namespace), 1344–1345
marshalers. See custom marshalers; Interop Assembly; Interop Marshaler
MarshalManagedToNative method, 896, 1281
MarshalNativeToManaged method, 896
MarshalType parameter (MarshalAsAttribute), 898, 1343
MarshalTypeRef parameter (MarshalAsAttribute), 898, 1343
Media Player, 1196
custom registration, 572–574
skins, 1196
visualizations, 1196
COM objects, 1196–1197
.NET Visualization API, 1224–1243
Visualization API, 1197–1223
members
converting for .NET object models, 434
.NET events, 446–447
.NET fields, 444–446
.NET methods, 434–441
.NET properties, 441–444
designing for .NET clients, 729
passing error information, 731
passing interface pointers to anything, 729
passing type information, 730–731
explicit, 655–656
IReflect interface, 665–666
private, 653
selecting, 651
static, reflection, 482–488
versioning, 527
Menu property, 507
Message string, 722
MessageBeep API, 810
MessageTypes enumeration, 1068
metadata
assemblies, 26–28
customizing PIAs (Primary Interop Assemblies), 693–694
in IL Assembler syntax, 967–971
ISearch interface, 360–363
signature transformations to expose HRESULTs, 344–348
signatures, 249
VB .NET modules, 356–358
Method value (ComMemberType enumeration), 1261
methods
adding to Interop Assembly, 372–373
AddMessage, 625
AddNotificationType, 285
AddRef, Marshal class, 1294
add_EventName, 592
Advise interface, 216
AllocCoTaskMem, Marshal class, 1295
AllocHGlobal (Marshal class), 1295
AnimatedEnvelopePicture, 1144
AnimatedEnvelopePicture class, 1144–1146
AnimatedPicture, 1140
AnimatedPicture class, 1140–1143
AnnoyingMessage, 206
AskYesNoQuestion, 1068
Assembly.GetExported-Types, 1052
Assembly.Load, 1050
Assembly.LoadFrom, 1050
AssemblyBuilder.Save, 1048
BindToMoniker (Marshal class), 1296
BitConverter.ToString, 946
CallerId, 596
calling COM objects, 101–109
ChangeFontButtonClick, 923
ChangeWrapperHandleStrength (Marshal class), 1296–1297
Character, 1158
Character class, 1158, 1161–1162
CleanUpManagedData (ICustomMarshaler interface), 1282
CleanUpNativeData (ICustomMarshaler interface), 1281
ConformantArray1D, 161
ConsoleMessage, 206
ConvertAssemblyToType-Lib (TypeLibConverter class), 1356
converting, 162
by-value versus by-reference, 164–167
hiding HRESULTs, 162–164
in, [out] parameter, 167–169
[in] versus [out], 167–169
parameter arrays, 169–171
ConvertTypeLibTo-Assembly, 1041–1042
creating assemblies from type libraries, 1042–1044
parameters, 1357
ConvertTypeLibTo-Assembly (TypeLib-Converter class), 1356–1357
Copy (Marshal class), 1297–1298
CreateInstance, 468
CreateObject, creating instances, 99–101
CreateObject (Visual Basic 6), 60
CreateRemoteInstance, 874
CreateSink, 239
CreateSoundBufferFrom-File, 1112
CreateSurfaceFromFile, 1118
CreateTypeInfo, 1068
CreateWrapperOfType (Marshal class), 1298–1299
DeleteSubKey, 860
DestroyStructure (Marshal class), 1299
DetachSink, 239
DisplayPropertyPage, 1220–1221
Dispose, 69, 1121, 1131–1136, 1151–1156, 1167, 1171
DllGetClassObject, 392
Draw, 1147–1149
DrawAt, 1136, 1139–1140, 1143–1146
dxSurface, 1136
E-mailAttackForm class, 1167–1168, 1171
E-mailAttackForm, 1167
EnumConnectionPoints, 216
Envelope, 1162
Envelope class, 1162, 1165–1166
Equals, 743
exportOpenButton_Click, 1100
ExtensibleClassFactory class, 1269
ExtensibleClassFactory.RegisterObjectCreation-Callback, 314
FAILED, 347
FillRect, 271
Finalize, 743
FreeBSTR (Marshal class), 1299–1300
FreeCoTaskMem (Marshal class), 1300
FreeHGlobal (Marshal class), 1300
FromGlobalAccessCache (RuntimeEnvironment class), 1351
Game, 1121
Game.Render, 1171
GCHandle value type
AddrOfPinnedObject, 1275
Alloc, 1275
Free, 1275
GenerateGuidForType (Marshal class), 1301
GenerateProgIdForType (Marshal class), 1301
GetActiveObject (Marshal class), 1301
GetClassID, 654
GetComInterfaceForObject (Marshal class), 1302
GetComObjectData (Marshal class), 1303
GetComSlotForMethodInfo (Marshal class), 1303
GetDisplayNameForAssembly, 1067
GetEndComSlot (Marshal class), 1303
GetExceptionCode (Marshal class), 1303–1304
GetExceptionPointers (Marshal class), 1304
GetExportedTypes, 1097
GetFrequency, 1225
GetHashCode, 743
GetHINSTANCE (Marshal class), 1304
GetHRForException (Marshal class), 1304–1305
GetHRForLastWin32Error (Marshal class), 1305
GetIDispatchForObject (Marshal class), 1305–1306
GetIDsOfNames, 662
GetITypeInfoForType (Marshal class), 1306
GetIUnknownForObject (Marshal class), 1306–1307
GetLastWin32Error (Marshal class), 1307
GetManagedCategoryGuid, 1057, 1349
GetManagedThunkFor-UnmanagedMethodPtr (Marshal class), 1307
GetMethodInfoForComSlot (Marshal class), 1308
GetNativeDataSize (ICustomMarshaler interface), 1282
GetNativeVariantForObject (Marshal class), 1308–1309
GetObjectAttribute
calling, 260
.NET signature, 260
GetObjectForIUnknown (Marshal class), 1309
GetObjectForNativeVariant (Marshal class), 272, 1309–1310
GetPrimaryInteropAssembly (TypeLibConverter class), 1357
GetRecordInfoFromType-Info, 271
GetRegistrableTypesIn-Assembly, 1057, 1350
GetRuntimeDirectory (RuntimeEnvironment class), 1351
GetSite, 729
GetSite .NET signature, 729
GetStartComSlot (Marshal class), 1310–1311
GetSystemVersion (RuntimeEnvironment class), 1352
GetThreadFromFiberCookie (Marshal class), 1311
GetType, 511–512
GetTypeCode, 118
GetTypedObjectFor-IUnknown (Marshal class), 1311
GetTypeForITypeInfo (Marshal class), 1311–1312
GetTypeInfo, 663
GetTypeInfoName (Marshal class), 1312
GetTypeLibGuidFor-Assembly (Marshal class), 1312
GetTypeLibLcid (Marshal class), 1067, 1313
GetTypeLibName (Marshal class), 1067, 1313
GetUnderlyingObject (ICustomAdapter interface), 909
GetUnmanagedThunkForManagedMethodPtr (Marshal class), 1313–1314
GoFullScreen, 1222
GroundLayer class, 1153
HasPropertyPage, 1232
hasTransparentColor, 1136
IConnectionPointContainer interface, 216
ICustomMarshaler interface, 896–897, 1281–1282
CleanUpManagedData, 897
CleanUpNativeData, 897
GetInstance, 897–898
GetInstance method, 897–898
GetNativeDataSize, 897
MarshalManagedTo-Native, 896
MarshalNativeTo-Managed, 896
IDispatch.Invoke, 608
IDisposable.Dispose, 493, 1135
IFormEvents, 623
InitializeComponent, 239
InputLanguageChanging, 622
Install, 1099
InterfaceName_MemberName, 663
InvokeVerb, 645–646
IsComObject (Marshal class), 1314
ISmartTagRecognizer.get_Name, 654
ISmartTagRecognizer.Recognize, 635
IsPhoneNumber, 381
IsTypeVisibleFromCom (Marshal class), 1314
ITypeInfo.Invoke, 582
ITypeLibExporterNotify-Sink interface, 1289
ITypeLibExporterNotifySink.ReportEvent, 1052
ITypeLibImporterNotify-Sink interface, 1044, 1051–1055, 1289
IUnknown (COM interface), 54
IUnknown.AddRef, 109
IUnknown.Release, 109
IWMPEffects interface, 1199–1201
Layer, 1150
Layer class, 1150–1152
LCIDs, LCIDConversionAttribute, 582–583
LoadAndDisplayAssembly, 1097
LoadTypeLibEx, 1042–1043
MakeVisibleAndInfected, 1162, 1166
Marshal class
AddRef, 1294
AllocCoTaskMem, 1295
AllocHGlobal, 1295
BindToMoniker, 1296
ChangeWrapperHandleStrength, 1296–1297
Copy, 1297–1298
CreateWrapperOfType, 1298–1299
DestroyStructure, 1299
FreeBSTR, 1299–1300
FreeCoTaskMem, 1300
FreeHGlobal, 1300
GenerateGuidForType, 1301
GenerateProgIdForType, 1301
GetActiveObject, 1301
GetComInterfaceFor-Object, 1302
GetComObjectData, 1303
GetComSlotForMethod-Info, 1303
GetEndComSlot, 1303
GetExceptionCode, 1303–1304
GetExceptionPointers, 1304
GetHINSTANCE, 1304
GetHRForException, 1304–1305
GetHRForLastWin32-Error, 1305
GetIDispatchForObject, 1305–1306
GetITypeInfoForType, 1306
GetIUnknownForObject, 1306–1307
GetLastWin32Error, 1307
GetManagedThunkForUnmanagedMethod-Ptr, 1307
GetMethodInfoForComSlot, 1308
GetNativeVariantFor-Object, 1308–1309
GetObjectForIUnknown, 1309
GetObjectForNative-Variant, 1309
GetObjectsForNative-Variants, 1310
GetStartComSlot, 1310–1311
GetThreadFromFiber-Cookie, 1311
GetTypedObjectFor-IUnknown, 1311
GetTypeForITypeInfo, 1311–1312
GetTypeInfoName, 1312
GetTypeLibGuid, 1312
GetTypeLibGuidFor-Assembly, 1312
GetTypeLibLcid, 1313
GetTypeLibName, 1313
GetUnmanagedThunk-ForManagedMethod-Ptr, 1313–1314
IsComObject, 1314
IsTypeVisibleFromCom, 1314
NumParamBytes, 1314
OffsetOf, 1314–1315
Prelink, 1315–1316
PrelinkAll, 1316
PtrToStringAnsi, 1316–1317
PtrToStringAuto, 1317–1318
PtrToStringBSTR, 1318
PtrToStringUni, 1319
PtrToStructure, 1319–1321
QueryInterface, 1321–1323
ReadByte, 1323–1325
ReadInt16, 1326
ReadInt32, 1326–1327
ReadInt64, 1327
ReadIntPtr, 1327–1328
ReAllocCoTaskMem, 1328
ReAllocHGlobal, 1328–1329
Release, 1329–1330
ReleaseComObject, 1330
ReleaseThreadCache, 1330
SetComObjectData, 1331
SizeOf, 1331
StringToBSTR, 1331–1332
StringToCoTaskMem-Ansi, 1332
StringToCoTaskMem-Auto, 1332
StringToCoTaskMem-Uni, 1333
StringToHGlobalAnsi, 1333
StringToHGlobalAuto, 1333–1334
StringToHGlobalUni, 1334
StructureToPtr, 1334–1336
ThrowExceptionForHR, 1336–1337
UnsafeAddrOfPinned-ArrayElement, 1337
WriteByte, 1337–1339
WriteInt16, 1340
WriteInt32, 1340–1341
WriteInt64, 1341
WriteIntPtr, 1342
Marshal.ReleaseComObject, 110
Marshal.SizeOf, 839
MarshalManagedToNative (ICustomMarshaler interface), 1281
MarshalNativeToManaged (ICustomMarshaler interface), 1281
MediaInfo, 1220
Microsoft.VisualBasic.CreateObject, 646
Microsoft.VisualBasic.Interaction.Beep, 810
MoveNext, 524
NumberPicture, 1147
NumberPicture class, 1147, 1149–1150
NumParamBytes (Marshal class), 1314
OffsetOf (Marshal class), 1314–1315
OnChangeUICues, 622
OnClosing, 622
OnEnterFullScreen, 1222
OnValidating, 622
optional parameters, 583–584
Picture, 1136
Picture class, 1136, 1138–1139
Play, 1134–1136
Prelink (Marshal class), 1315–1316
PrelinkAll (Marshal class), 1316
PtrToStringAnsi (Marshal class), 1316–1317
PtrToStringAuto (Marshal class), 1317–1318
PtrToStringBSTR (Marshal class), 1318
PtrToStringUni (Marshal class), 1319
PtrToStructure (Marshal class), 1319–1321
QueryInterface
(Marshal class), 1321–1323
IUnknown implementation, 658–659
Read, by-reference null value types, 264–265
ReadByte (Marshal class), 1323–1325
ReadInt16 (Marshal class), 1326
ReadInt32 (Marshal class), 1326–1327
ReadInt64 (Marshal class), 1327
ReadIntPtr (Marshal class), 1327–1328
ReAllocCoTaskMem (Marshal class), 1328
ReAllocHGlobal (Marshal class), 1328–1329
Recognize, 644–645
RegEnumKey, 856
RegisterAssembly, 1350, 1056–1057
RegisterFunction, 644
RegisterObjectCreation-Callback, Extensible-ClassFactory class, 1269
RegisterTypeForCom-Clients, 1058, 1350
RegistrationHelper class, 1060
C#, 1059
C++, 1059
Visual Basic .NET, 1059
RegistrationServices
GetManagedCategory-Guid, 1349
GetProgIdForType, 1350
GetRegistrableTypesIn-Assembly, 1350
RegisterAssembly, 1350
RegisterTypeForCom-Clients, 1350
RegistrationServices class, 1056–1058
TypeRepresentsCom-Type, 1350
TypeRequires-Registration, 1351
UnregisterAssembly, 1351
Release (Marshal class), 501, 1329–1330
ReleaseComObject (Marshal class), 110, 1330
ReleaseThreadCache (Marshal class), 1330
Remove, 596
remove_EventName, 592
Render, 1121, 1133, 1151–1158, 1162, 1217–1218, 1233
RenderFullScreen, 1222
Reset, 1151–1152, 1158, 1162, 1166
ResizeAndDrawAt, 1136, 1140, 1143–1146
ResizeAndDrawSurface, 1112
ResolveRef, 1053–1054
creating assemblies from type libraries, 1045–1046
implementation, 1045
ITypeLibExporterNotifySink interface, 1289
ITypeLibImporterNotifySink interface, 1289
TypeLibConverter class, 1045
Ring, 596
RuntimeEnvironment class
FromGlobalAccess-Cache, 1351
GetRuntimeDirectory, 1351
GetSystemVersion, 1352
Screen, 1155
SetComObjectData (Marshal class), 1331
setGUID, 728
Shutdown, 227
signatures, 652
size, 1136
SizeOf (Marshal class), 1331
SomeMethod, 479
Sound, 1134
Sound class, 1134–1136
StringToBSTR (Marshal class), 1331–1332
StringToCoTaskMemAnsi (Marshal class), 1332
StringToCoTaskMemAuto (Marshal class), 1332
StringToCoTaskMemUni (Marshal class), 1333
StringToHGlobalAnsi (Marshal class), 1333
StringToHGlobalAuto (Marshal class), 1333–1334
StringToHGlobalUni (Marshal class), 1334
StructureToPtr (Marshal class), 1334–1336
System, 1135
System.AppDomain.Unload, 1049
System.Enum.Format, 646
System.Guid.NewGuid, 60
System.IO.Stream class, 883–889
System.Object class, 743
System.Runtime.Interop-Services.ItypeLib-ExporterNameProvider interface, 1054
System.Runtime.Interop-Services.Marshal, 845
System.Type.GetType, 68
System.Windows.Forms.Control.Invoke, 1100
System.Windows.Forms.Design.PictureBox-Designer.Initialize, 508
System.Windows.Forms.MessageBox.Show, 50
TAPI class, 227–229
ThrowExceptionForHR (Marshal class), 1336–1337
ToString, 743
IFormattable interface implementation, 761–764
type library transformation, 439–440
type library transformations, 434
by-reference parameters, 436–438
by-value parameters, 436–438
GetEnumerator method, 440
HRESULTs, 434–436
overloaded, 438–439
parameter arrays, 440–441
ToString method, 439–440
Type.GetTypeFromCLSID, 309
Type.GetTypeFromProgID, 309
TypeLibConverter class
C#, 1040
C++, 1041
ConvertAssemblyTo-TypeLib, 1050, 1356
ConvertTypeLibTo-Assembly, 1356–1357
GetPrimaryInterop-Assembly, 1357
Visual Basic .NET, 1041
TypeRepresentsComType, 1057, 1350
TypeRequiresRegistration, 1058, 1351
Unadvise interface, 216
UnicodeEncoding.GetBytes, 946
Uninstall, 1100
UnregisterAssembly, 1056, 1351
UnregisterFunction, 644
UnsafeAddrOfPinnedArrayElement (Marshal class), 1337
usage guidelines, 511–513
Util.CreateSoundBuffer-FromFile, 1135
windowsForm_Activated, 625
windowsForm_ChangeUICues, 625
windowsForm_DragDrop, 625
WriteByte (Marshal class), 1337–1339
WriteInt16 (Marshal class), 1340
WriteInt32 (Marshal class), 1340–1341
WriteInt64 (Marshal class), 1341
WriteIntPtr (Marshal class), 1342
methods Screen class, 1155–1156
MFC (Microsoft Foundation Classes), 277
Microsoft C Runtime Library, 15
Microsoft Direct Animation type library, 731
Microsoft DirectX. See DirectX
Microsoft Foundation Classes. See MFC
Microsoft Intermediate Language. See IL
Microsoft Telephony API. See TAPI
Microsoft Word, Spell Checking application example, 127–137
Microsoft.VisualBasic assembly, 38, 356–358
Microsoft.VisualBasic namespace, 643
Microsoft.VisualBasic.CompilerServices.StandardModuleAttribute, 356
Microsoft.VisualBasic.CreateObject method, 646
Microsoft.VisualBasic.Interaction.Beep method, 810
Microsoft.VisualBasic.Left function, 788
Microsoft.Win32 namespace, 1131
Microsoft.Win32.Registry class, 644
MIDL.EXE, 55
MiscTypes.cs (Interactive Interop Tool), 1064–1068
mixed-mode
debugging, 315–319
programming (Visual C++ managed extensions), 50–51
MKTYPLIB.EXE, 55
modules, converting COM, 187–188
Monitor class, 275
monitoring performance, 320–321
MoveNext method, 524
Moves enumeration, E-mail Attack, 1120
moveSound field, 1121
MSCOREE.DLL, 391, 460, 468, 492–493
MSCOREE.TLB, 460
mscorlib
IL Assembler types, 332–333
registering REGDB_E_CLASSNOTREG failure, 403
mscorlib assembly, 23, 34–35, 38, 71, 463, 522
exceptions to HRESULT transformations, 1416–1417, 1423, 1429
HRESULT to exception transformations, 1400, 1406–1407, 1413
Interop API, 52
mscorlib.tlb type library, 623
MSHTML.TLB, 234
MSIL. See IL
MSXML, running TLBIMP on, 142
MTA (multi-threaded), 733
MTA value, System.Threading.ApartmentState enumeration, 280
MTAs (Multi-Threaded Apartments), 276–278, 282–289
Multi-Threaded Apartments. See MTAs
MultiPurposeObject coclass, 705
MultiPurposeObject interface, 705
MultiUse setting (instancing), 633
MULTI_QI structure, 873
MustInherit class, 506
MustRunInClientContext-Attribute, 585
Mutex class, 275
MyCustomMarshalers assembly, 365
Name property, 645
named_guids directive, 387
names
COM interfaces, 500
components, COM compared to .NET Framework, 59–62
designing COM objects for .NET clients, 734–735
DLL filenames, 690
enums, 707–709
GUIDs, 60–61
libraries, 427–428
parameters, 503–504
PIAs (Primary Interop Assemblies), 686–687
PInvoke functions, 796
properties, 504–505
structures, 707–709
type libraries, 141–143
V-table binding, 505
/names (TLBEXP.EXE), 1383
/namespace (TLBIMP.EXE), 1379
/namespace option
namespaces, 643
assemblies, 23
DirectX, 1111, 1118, 1135, 1138, 1143, 1146, 1183, 1193–1194
Microsoft.VisualBasic, 643
Microsoft.Win32, 1131
names, 502–503
output assembly, 690–693
Sams.SmartTags, 643
SmartTagLib, 643
System, 35, 52, 620, 643, 887, 894, 1016, 1066–1068, 1079, 1096, 1118, 1131, 1138, 1146, 1149, 1152, 1156, 1171, 1215
C# keywords, 35
C++ keywords, 42–43
IntPtr type, 270
Visual Basic .NET keywords, 39
System.Collections, 596, 743–744, 746–747
System.Diagnostics, 321
System.Drawing, 1215
System.EnterpriseServices, 52, 584–586, 1059, 1099
System.Globalization, 620
System.Reflection, 26, 59,,270, 1066, 1096, 1215
System.Runtime.InteropServices, 52, 218, 250, 297, 391, 596–598, 643, 772, 837, 861, 887, 909, 998, 1016, 1056, 1066–1067, 1118, 1138, 1215, 1250, 1252
ArrayWithOffset value type, 1252–1254
AssemblyRegistration-Flags enumeration, 1254
AutomationProxy-Attribute, 1254
BINDPTR value type, 1255
BIND_OPTS value type, 1255
CALLCONV enumeration, 1255
CallingConvention enumeration, 1255–1256
CharSet enumeration, 1256
ClassInterfaceAttribute, 1256–1257
ClassInterfaceType enumeration, 1257
CoClassAttribute, 1258
ComAliasNameAttribute, 1258
ComConversionLoss-Attribute, 1258
ComEventInterface-Attribute, 1258–1259
COMException exception, 1259–1260
ComImportAttribute, 1260
ComInterfaceType enumeration, 1260
ComMemberType enumeration, 1261
ComRegisterFunction-Attribute, 1261
ComSourceInterfaces-Attribute, 1261
ComUnregisterFunctionAttribute, 1262
ComVisibleAttribute, 1262–1263
CONNECTDATA value type, 1263
CurrencyWrapper class, 1263–1264
custom attributes, 1250
DESCKIND enumeration, 1264
DESCUNION value type, 1264
DispatchWrapper class, 1264–1265
DispIdAttribute, 1265–1266
DISPPARAMS value type, 1266
DllImportAttribute, 1266–1267
ELEMDESC value type, 1267
ErrorWrapper class, 1267–1268
EXCEPINFO value type, 1268
ExporterEventKind enumeration, 1268–1269
ExtensibleClassFactory class, 1269–1271
ExternalException exception, 1271
FieldOffsetAttribute, 1271–1272
FILETIME value type, 1272
FUNCDESC value type, 1272
FUNCFLAGS enumeration, 1272
FUNCKIND enumeration, 1273
GCHandle value type, 1273–1277
GCHandleType enumeration, 1277
GuidAttribute, 1278
HandleRef value type, 1278–1280
ICustomAdapter interface, 1280–1281
ICustomFactory interface, 1281
ICustomMarshaler interface, 1281–1282
IDispatchImplAttribute, 1282
IDispatchImplType enumeration, 1283
IDLDESC value type, 1283
IDLFLAG enumeration, 1283
IMPLTYPEFLAGS enumeration, 1283
ImportedFromTypeLib-Attribute, 1284
ImporterEventKind enumeration, 1284
InAttribute, 1284–1285
InterfaceTypeAttribute, 1285
InvalidComObjectException exception, 1286
InvalidOleVariantTypeExceptionexception, 1286–1287
INVOKEKIND enumeration, 1287
IRegistrationServices interface, 1287
ITypeLibConverter interface, 1287–1288
ITypeLibExporterNameProvider interface, 1288
ITypeLibExporterNotifySink interface, 1289
ITypeLibImporterNotifySink interface, 1289
LayoutKind enumeration, 1290
LCIDConversion-Attribute, 1290–1291
LIBFLAGS enumeration, 1291
Marshal class, 1292–1342
MarshalAsAttribute, 1342–1344
MarshalDirective-Exception, 1344–1345
ObjectCreationDelegate delegate, 1345
OptionalAttribute, 1345–1346
OutAttribute, 1346–1347
PARAMDESC value type, 1347
PARAMFLAG enumeration, 1347
PreserveSigAttribute, 1347–1348
PrimaryInterop-AssemblyAttribute, 1348
ProgIdAttribute, 1349
RegistrationServices class, 1349–1351
RuntimeEnvironment class, 1351–1352
SafeArrayRank-MismatchException, 1352
SafeArrayType-MismatchException, 1352–1353
SEHException, 1353
STATSTG value type, 1353
StructLayoutAttribute, 1354
SYSKIND enumeration, 1354
tool APIs, 1252
TYPEATTR value type, 1355
TYPEDESC value type, 1355
TYPEFLAGS enumeration, 1355
TYPEKIND enumeration, 1355
TYPELIBATTR value type, 1356
TypeLibConverter class, 1356–1357
TypeLibExporterFlags enumeration, 1357
TypeLibFuncAttribute, 1358
TypeLibFuncFlags enumeration, 1358
TypeLibImporterFlags enumeration, 1358
TypeLibTypeAttribute, 1359
TypeLibTypeFlags enumeration, 1359
TypeLibVarAttribute, 1359
TypeLibVarFlags enumeration, 1359
UCOMIBindCtx interface, 1360
UCOMIConnection-Point interface, 1360
UCOMIConnection-PointContainer interface, 1360
UCOMIEnum-ConnectionPoints interface, 1360
UCOMIEnum-Connections interface, 1361
UCOMIEnumMoniker interface, 1361
UCOMIEnumString interface, 1361
UCOMIEnumVARIANT interface, 1361–1362
UCOMIMoniker interface, 1362–1363
UCOMIPersistFile interface, 1363
UCOMIRunningObjectTable interface, 1363
UCOMIStream interface, 1364
UCOMITypeComp interface, 1364–1365
UCOMITypeInfo interface, 1365
UCOMITypeLib interface, 1366
UnknownWrapper class, 1366–1367
UnmanagedType enumeration, 1367–1368
VARDESC value type, 1368
VarEnum enumeration, 1369–1370
VARFLAGS enumeration, 1370
wrappers, 115
System.Runtime.InteropServices, 1135
System.Runtime.InteropServices.CustomMarshalers, 1370
EnumerableToDispatchMarshaler class, 1370
EnumeratorToEnumVariantMarshaler class, 1371
ExpandoToDispatchExMarshaler class, 1371–1372
TypeToTypeInfo-Marshaler class, 1372
System.Runtime.InteropServices.Expando, 1372–1373
System.Text, 946
System.Text.RegularExpressions, 381
System.Windows.Forms, 52, 620, 1171, 1215
NAs (Neutral Apartments), 276, 277
nested arrays, data types, 518–519
nested types, ILASM.EXE, 334
.NET Framework
compared to COM, 55–57
component locations, 62–64
component names, 59–62
error handling, 66–68
object lifetimes, 68–69
programming model, 57–58
type compatibility, 64
type information, 58–59
type safety, 66
versioning, 64–66
C# StringValidator class, 380–381
C++ StringValidator class, 385–388
DirectX, 1106
JScript StringValidator class, 388–390
locations, 62–64
Visual Basic 6 StringValidator class, 382–384
converting COM members for object models, 434
.NET events, 446–447
.NET fields, 444–446
.NET methods, 434–441
.NET properties, 441–444
defined, 14
designing COM components for, 716–717
array parameters, 717–720
error reporting, 720–728
VARIANT parameters, 720
designing COM members for, 729
passing error information, 731
passing interface pointers to anything, 729
passing type information, 730–731
designing COM objects for
IProvideClassInfo, 734
naming guidelines, 734–735
performance, 735–738
resource management, 731–733
features, 16
deployment, 19–20
platform neutrality, 21–22
security, 20–21
version resiliency, 16–19
DLL Hell, 16–17
interfaces, 740
class interfaces, 741–743
COM, 678–679
converting to COM interfaces, 447–449
disabling type library marshaling, 580–582
HRESULTs, 758
IComparer implementation, 764–766
IDispatchEx, 678–679
IDisposable, 732
IEnumVARIANT, 678
IErrorInfo, 731
IHashCodeProvider implementation, 764–766
inheritance, 743–747
InterfaceTypeAttribute, 578
IReflect, 665–672
ITypeInfo, 678
names, 503–504
System.IConvertible, 652
Visual Basic 6, 397–399, 759–764
Visual C++, 747–759
monitoring performance, 320–321
naming guidelines, 499
names to avoid, 500–502
namespaces, 502–503
Pascal casing, 503–506
SDK
referencing ActiveX controls, 122–123
referencing COM components, 81–84
running Office XP smart tags example, 650
threading, 275
callbacks from COM objects to .NET objects, 282–289
COM apartment incompatibility, 291–292
COM apartment states, 277–282
COM apartment types, 276–277
COM ThreadingModel registry value, 276–277
concurrency, 275
usage guidelines, 506
constructors, 513–514
data types, 516–519
enumerations, 514–516
interfaces versus classes, 506–508
interfaces versus custom attributes, 508–510
overloaded methods, 511–513
properties versus fields, 510–511
.NET Visualization API, 1224
ColorfulVisualization, 1231–1235
Dancing Cat Visualization, 1235–1243
SimpleVisualization, 1224–1226
WizardVisualization, 1227–1230
NetMeeting Coclass interface, C# definitions, 1007–1009, 1016–1018
Neutral Apartments. See NAs
neutral components, 277
Neutral string value, 276
new operator, creating instances, 99
NewWrapper type, 298
/nologo (AXIMP.EXE), 1393
/nologo (REGASM.EXE), 1389
/nologo (REGSVCS.EXE), 1396
/nologo (TLBEXP.EXE), 1384
/nologo (TLBIMP.EXE), 1381
non-contiguous property accessors, 992
non-public interfaces (COM interfaces), 967
non-reflexive IUnknown, implementations, 292–293
Non-Static Extern Members feature (C#), 1029–1031
AssemblyRegistrationFlags enumeration, 1254
CharSet enumeration, 1256
ClassInterfaceType enumeration, 1257
/noreconfig (REGSVCS.EXE), 1395
Normal value (GCHandleType enumeration), 1277
notifySink parameter (ConvertTypeLibToAssembly method), 1051, 1357
NOTIF_CONVERTWARNING value, 1044–1045, 1052
ExporterEventKind enumeration, 1269
ImporterEventKind enumeration, 1284
NOTIF_TYPECONVERTED events, 1052
NOTIF_TYPECONVERTED value, 1045, 1052
ExporterEventKind enumeration, 1269
ImporterEventKind enumeration, 1284
no_namespace directive, 387
NumberPicture class, 1133, 1146
methods, 1147–1150
private fields, 1147
NumberPicture method, 1147
numBonuses field, 1121
NumBonuses property, 1121, 1132
numLives field, 1121
NumParamBytes method (Marshal class), 1314
Object class, interface, 439–440
Object Definition Language. See ODL
object parameters, MarshalAsAttribute, 1343
ObjectCreationDelegate delegate (System.Runtime.InteropServices namespace), 1345
ObjectPoolingAttribute, 585
objects
adapter
alternative to, 910–913
CCWs, 904–905
custom marshalers, 901–909
RCWs, 904–906
Application, 646
COM, 53
activating with CoCreateInstanceEx, 871–874
calling methods, 101–109
calling properties, 101–109
IProvideClassInfo interface, 734
Marshal.ReleaseCom-Object, 299–304
passing, 115–118
releasing, 109–110
visualizations, 572, 1196–1197
COM+, 309–311
exposing .NET objects as, 584–586
installing in Component Services explorer, 309
DCOM, 309–311
creating remote objects, 309–310
.NET remoting, 310
Type.GetTypeFromCLSID method, 309
Type.GetTypeFromProgID method, 309
designing for .NET clients
IProvideClassInfo, 734
managing resources, 731–733
naming guidelines, 734–735
performance, 735–738
threading, 733
IUnknown.AddRef (COM), 68
lifetimes, COM compared to .NET Framework, 68–69
.NET Framework
calling members, 400–403
creating, 399–400
exposing as COM objects, 584–586
performance, 320–321
ODL (Object Definition Language), 54
Office XP, smart tags, 634–636, 643–646
explicit interface members, 655–656
HRESULTs, 656
inheritance, 654–655
parameterized properties, 653–654
running example using .NET Framework, 650
running example using Visual Studio .NET, 646–650
Office.dll, 301
OffsetOf method (Marshal class), 1314–1315
OLE Automation, 516–518
IDispatch implementations, 665
LoadTypeLibEx method, 1042
SAFEARRAY parameters, 517
VARIANTs, 517
OLE/COM Object Viewer. See OLEVIEW.EXE
OLE32.DLL, PInvoke signatures, 1461, 1470
OLEVIEW.EXE, 55–56, 291, 427, 535–536, 688
OLE_COLOR parameter, 194, 341–342
OnCallerId event, 596
OnChangeUICues method, 622
OnClosing method, 622
OnEnterFullScreen method, 1222
OnEventName method, 609, 622–623
OnRing event, 596
OnValidating method, 622
operators, creating new instances, 99
optional parameters, 104, 583–584
COM, 104–105
.NET Framework, 105–109
OptionalAttribute (System.Runtime.InteropServices namespace), 583–584, 1345–1346
Options property, 1099
ordering property accessors, language limitations of COM interfaces, 990–994
/out (AXIMP.EXE), 1392
/out (TLBEXP.EXE), 1384
/out (TLBIMP.EXE), 1378
OutAttribute (System.Runtime.InteropServices namespace), 786, 1346–1347
customizing data flow, 553–554
export behaviors, 438
marking array parameters, 792–794
outgoing interface. See source interface (COM callbacks)
outproc servers, 63
output
C# code demonstration, 28
assembly content modifications, 328
creating PIAs (Primary Interop Assemblies), 690
discovering custom attributes with reflection, 32–33
method conversions, 167–169
namespaces, 690–693
OutputDirectory property, 1079
overloaded methods, 438–439, 511–513
OwnerWindow class, 1221
Pack parameter, StructLayoutAttribute, 830
padding field, 1147
page flipping, 1118
PARAMDESC value type (System.Runtime.InteropServices namespace), 1347
parameter arrays, method conversions, 169–171
parameters. See also arrays
arrays, 717
SAFEARRAYs, 717–719
single-dimensional, 719–720
type library transformations, 440–441
zero-bounded, 719
ArraySubType, 337
asmNamespace, 1046
assembly, 1060
ILASM.EXE, 334
method conversions, 164–167
.NET method transformations, 436–438
method conversions, 164–167
.NET method transformations, 436–438
Component, 508
ConvertTypeLibToAssembly method, 1357
flags, 1051
ILASM.EXE, 334
in, [out]
method conversions, 167–169
installFlags, 1060
IntPtr, 340–341
[in], 167–169
IReflect interface, 671
isVisible, 504
keyPair, 1046
language limitations of COM interfaces, 994–995, 998
LocaleID, 644
ArraySubType, 1343
Boolean, 1343
MarshalCookie, 1343
MarshalType, 1343
MarshalTypeRef, 1343
object, 1343
SafeArraySubType, 1343
SafeArrayUserDefined-SubType, 1344
SizeConst, 1344
SizeParamIndex, 1344
strings, 1342
names, 503–504
notifySink, 1051
COM, 104–105
.NET Framework, 105–109
[out], 167–169
PInvoke, DllImportAttribute, 1266–1267
PInvoke signatures
arrays, 792–794
CallingConvention, 799–800
Declare statement, 796–799
default marshaling, 782
DllImportAttribute, 796–807
strings, 782–791
ppAttributeEntries (struct type), 259
properties, 653–654
publicKey, 1046
RecognizerSite, 645
Render method, 1218
SafeArraySubType, 338–340
SmartTagID, 645
strTypeLibName, 1050
StructLayoutAttribute, 830
System.Type, GUID property, 568–570
throwOnMissingSubKey, 569
tlb, 1060
Type, ComSourceInterfaces-Attribute, 600
VARIANT, 720
VerbID, 645
PARAMFLAG enumeration (System.Runtime.InteropServices namespace), 1347
/parname (REGSVCS.EXE), 1395–1396
partial binding, 91
Pascal casing (naming guidelines), 503–506
passing
error information, 731
interface pointers, 729
objects, COM, 115–118
structures, 821–829
type information, 730–731
pauseScreen field, 1121
performance
designing COM objects for .NET clients, 735–738
monitoring, 320–321
permissions
reflection, 304
serialization, 304
unmanaged code, 304
event handlers, 597
exposing .NET events to COM with CLR, 602–605
exposing .NET events to COM without CLR, 594–597
PIAs (Primary Interop Assemblies), 86–90, 684
creating, 686
customizing metadata, 693–694
names, 686–687
naming output assembly, 690–693
type library references, 687–689
deployment, 694–696
IDL type libraries, 697–698
ActiveX controls, 712
constants, 709–710
constructs, 710
defining classes, 702–707
naming enums, 707–709
referencing external types, 698–702
registering type libraries, 711
opening, 695
reasons for creating, 684–685
registration, 694–696
Picture class, 1133–1134
methods, 1136–1139
properties, 1136
Picture method, 1136
pictures, E-mail Attack, 1111
Pinned value, GCHandleType enumeration, 1277
PInvoke, 49–50
Pinvoke (Platform Invocation Services), 49, 772
choosing DLL locations dynamically, 863–865
choosing DLL names dynamically, 863–865
delegates as function pointers, 811
CopyFileEx, 812–815
SetConsoleCtrlHandler function, 815–817
DLL entry points, 772
functions
case-sensitivity, 774
KERNEL32.DLL, 774–777
names, 796
invoking unmanaged function pointers in managed code, 818–821
parameters, DllImportAttribute, 1266–1267
responding to console input, 865–868
signatures, 1432–1433
arrays, 792–794
calling conventions, 799–800
changing exact spelling, 799
converting data types, 778–781
Declare statement, 795–796
default marshaling for parameters, 782
diagnostics, 778
error handling, 800–807
premature garbage collecting, 852–853, 856, 859–862
SHELL32.DLL, 1470–1471
unsafe C# code, 849–852
Visual Basic .NET, 773–775
Win32 APIs, 772
pixelsOffscreen field, 1150
Platform Invocation Services. See PInvoke
platforms, 21–22
Player field, 1120
PlayerPicture field, 1121
PlaySound API, 810
pointer to string. See LPSTR
pointer to wide-character string. See LPWSTR
pointers, 810–811
customizing structures, 829
FieldOffsetAttribute, 832–833
formatted classes, 839–844
MarshalAsAttribute, 834–839
StructLayoutAttribute, 829–832
structure inspection, 844–847
data types, 518
delegates as, 811–812
CopyFileEx, 812–815
SetConsoleCtrlHandler, 815–817
invoking unmanaged
pointers in managed code, 818–821
passing structures, 821–829
PowerPoint, garbage collection, 301–304
PowerPoint.dll, 301
PowerPoint.Eapplication interface, 366
ppAttributeEntries parameter (struct type), 259
Prelink method (Marshal class), 1315–1316
PrelinkAll method (Marshal class), 1316
PreserveSig parameter, 803–807, 1267
PreserveSigAttribute (System.Runtime.InteropServices namespace), 436, 579, 1347–1348
PresetCount property, 1221
PresetEnumAttribute, 1220–1223
/primary (TLBIMP.EXE), 1379
Primary Interop Assembly. See PIAs
PrimaryInteropAssembly-Attribute (System.Runtime.InteropServices namespace), 1348
private fields
Character class, 1158
Game class, 1121
NumberPicture class, 1147
private members, 653
Private setting (instancing), 633
PrivateComponent-Attribute, 585
problems, COM interface implementations
explicit interface members, 655–656
HRESULTs, 656
inheritance, 654–655
parameterized properties, 653–654
ProgId property, 644–645
ProgIdAttribute (System.Runtime.InteropServices namespace), 566, 1349
ProgIDs, 63–65
programming models, COM compared to .NET Framework, 57–58
Progress property, 1068
ProgressMaximum property, 1068
Project menu commands, Add Reference, 25
projects, binary-compatible components. See binary-compatible components
properties
AllowMultiple, 30
AnimatedPicture class, 1140
ApartmentState, 280–281
C#, 280–281
starting new threads, 282
Visual Basic .NET, 281
AssemblyQualifiedName, 61
calling COM objects, 101–109
Capabilities, 1220
COM interface language limitations, 990
location and ordering of property accessors, 990–994
optional parameters and default values, 994–995, 998
Control, 621
converting, 171–173
CurrentAudioTitle, 1220
CurrentChannelCount, 1220
CurrentSampleRate, 1220
Desc, 644–645
EntryPoint, DllImportAttribute, 36, 40, 43
EnvelopeUnderneath, 1162
exception objects, CLR, 722
Game class, 1121
GCHandle value type
IsAllocated, 1275
Target, 1276
Graphics, 622
HashCode, 502
HResult, 520
Instancing, 633
InternetExplorer.Document, 234
IsVisible, 504
ITreeNode.isVisible, 504
Marshal class
SystemDefaultCharSize, 1336
SystemMaxDBCSChar-Size, 1336
Menu, 507
Name, 645
names, 504–505
Options, 1099
OutputDirectory, 1079
parameterized, 653–654
Picture class, 1136
PresetCount, 1221
ProgId, 644–645
Progress, 1068
ProgressMaximum, 1068
Rectangle, 622
SmartTagCaption, 645
SmartTagCount, 644–645
SmartTagDownloadURL, 645
SmartTagName, 645
System.Windows.Forms.Form.Menu, 507
SystemConfigurationFile (RuntimeEnvironment class), 1351
SystemDefaultCharSize (Marshal class), 1336
SystemMaxDBCSCharSize (Marshal class), 1336
TextBoxFont, 923
Type, 502
type library transformations, 441–444
usage guidelines, versus fields, 510–511
VerbCaptionFromID, 645
VerbCount, 645
VerbID, 645
VerbNameFromID, 646
PropGet value, ComMemberType enumeration, 1261
PropSet value, ComMemberType enumeration, 1261
pros and cons, manually defining COM definitions, 958–959
pseudo-custom attributes, 33
DllImportAttribute, 776–777
choosing DLL locations dynamically, 863, 865
choosing DLL names dynamically, 863, 865
System.Runtime.InteropServices namespace
ComImportAttribute, 1260
DllImportAttribute, 1266–1267
FieldOffsetAttribute, 1271–1272
InAttribute, 1284–1285
MarshalAsAttribute, 1342–1344
OptionalAttribute, 1345–1346
OutAttribute, 1346–1347
PreserveSigAttribute, 1347–1348
StructLayoutAttribute, 1354
PtrToStringAnsi method (Marshal class), 1316–1317
PtrToStringAuto method (Marshal class), 1317–1318
PtrToStringBSTR method (Marshal class), 1318
PtrToStringUni method (Marshal class), 1319
PtrToStructure method (Marshal class), 1319–1321
public fields
Envelope class, 1162
Game class, 1120
Util class, 1112
public key, assemblies, 61
public properties, Game class, 1121
/publickey (AXIMP.EXE), 1392
/publickey (TLBIMP.EXE), 1379
publicKey parameter (ConvertTypeLibToAssembly method), 1046, 1357
PublicNotCreatable setting (instancing), 633
QueryAccessibilityHelp event, 623
failures, 290–291
incompatibile apartments, 291–292
non-reflexive IUnknown implementations, 292–293
type library errors, 294
Visual Basic 6 projects without binary compatability, 294–295
method (Marshal class), 658–659, 1321–132,3
QueryPerformanceCounter function, 774
QueryPerformance-Frequency function, 774–777
/quiet (REGSVCS.EXE), 1396
RandomNumber field, 1112
raw_interfaces_only directive, 387
RCW (Runtime-Callable Wrapper), 69–71
class, 182–186
custom marshaling, 880–882
exposing IStream and Stream, 923–932
types, 295–304
Read method, 264–265
ReadByte method (Marshal class), 1323–1325
ReadConsoleInput API, 865–868
ReadInt16 method (Marshal class), 1326
ReadInt32 method (Marshal class), 1326–1327
ReadInt64 method (Marshal class), 1327
ReadIntPtr method (Marshal class), 1327–1328
ReAllocCoTaskMem method (Marshal class), 1328
ReAllocHGlobal method (Marshal class), 1328–1329
Recognize method, 644–645
RecognizerSite parameter, 645
/reconfig (REGSVCS.EXE), 1396
ReconfigureExistingApplication value, 1061
Recordset.ActiveConnection property, 992–993
RECT parameter, 1218
RECT structure, 1021
Rectangle property, 622
/reference option (TLBIMP.EXE), 1045, 1380
referencing
ActiveX controls
with .NET Framework SDK, 122–123
in Visual Studio .NET, 121–122
assemblies, 25
COM components
SDK, 81–84
in Visual Studio .NET, 78–84
reflection, 26
C# code, 26–28
custom attributes, 31–33
Reflection Emit, 26
static members, 482–488
reflection permission, 304
REGASM.EXE, 296, 385, 535, 694–696, 1040, 1056, 1062–1063, 1385–1386
/?, 1390
/codebase option, 393–394
/codebase, 1386
generating type libraries, 395
/help, 1390
/nologo, 1389
/registered, 1387
registration, 568
Interop Assemblies, 297
/silent, 1389
syntax, 1385
/tlb, 1387–1389
/tlb option, 1057
/tlb switch, 571
/u option, 569
/unregister, 1389
/verbose, 1390
RegCloseKey API, 856
REGDB_E_CLASSNOTREG failure, 403
RegDeleteKey API, 860
REGEDIT.EXE, 55
REGEDT32.EXE, 55
RegEnumKey API, 856
RegEnumKey method, 856
/regfile (REGASM.EXE), 573, 1386–1387
Register class, 1093–1097
Register for COM Interop option, 390, 395, 649
C#, 534
Visual Basic .NET, 534
Visual Studio .NET, 535
Register tab (Interactive Interop Tool), 1092–1097
Register value, 1061
RegisterAssembly method (RegistrationServices class), 1056–1057, 1350
/registered (REGASM.EXE), 1387
RegisterFunction method, 644
RegisterObjectCreation-Callback method, 1269
RegisterTypeForComClients method (RegistrationServices class), 1058, 1350
Registrar class, 1096
registration, 460
assemblies, 390–392, 532–535, 1056
HRESULTs, 393
RegistrationServices class, 391, 1056–1058
TypeLoadException, 392
VB6.EXE, 392
WSCRIPT.EXE, 392
ClrCreateManagedInstance API, 468–471
customizing, 566
adding arbitrary registration code, 567–569
custom registration functions, 570–574
ProgIdAttribute, 566
System.Guid.ToString, 570
unregistration functions, 569–570
hosting CLR, 460–468
Interop Assemlies, 297
mscorlib, 403
PIAs, 694–696
REGASM.EXE, 568
type libraries, 711
Registration Utility. REGASM.EXE, 385
RegistrationHelper class, 1059, 1252
InstallationFlags enumeration, 1060–1061
methods, 1060
C#, 1059
C++, 1059
Visual Basic .NET, 1059
RegistrationServices class (System.Runtime.InteropServices namespace), 391, 1097, 1349
methods, 1056–1058
GetManagedCategory-Guid, 1349
GetProgIdForType, 1350
GetRegistrableTypesInAssembly, 1350
RegisterAssembly, 1350
RegisterTypeForCom-Clients, 1350
TypeRepresentsCom-Type, 1350
TypeRequires-Registration, 1351
UnregisterAssembly, 1351
Registry
adding additional entries, 567–569
assemblies, 80
HKEY_CLASSES_ROOTCLSID{CLSID}InProcServer32 key, 276–277
registering assemblies in. See registration
Visualization API, 1197–1198
RegistryKey class, 853, 856, 859–860
RegistryKey instance, 856
RegistryKey.DeleteSubKey, 569
RegistryKeyEnumerator class, 853, 856
REGKIND enumeration, 1068
RegOpenKey API, 856
REGSVCS.EXE, 1040, 1060, 1252, 1394
/?, 1396
/appname, 1394–1395
/c, 1395
/componly, 1395
/exapp, 1395
/extlb, 1395
/fc, 1395
/help, 1396
/nologo, 1396
/noreconfig, 1395
/parname, 1395–1396
/quiet, 1396
/reconfig, 1396
syntax, 1394
/tlb, 1396
/u, 1396
Release method (Marshal class), 501, 1329–1330
ReleaseComObject method (Marshal class), 110, 300, 1330
ReleaseThreadCache method (Marshal class), 1330
releasing COM objects, 109–110
remote DCOM objects, creating, 309–310
remote servers, 63
remoting (.NET), 310
Remove method, 596
remove_EventName method, 592
Render method, 1121, 1133, 1151–1156, 1158, 1162, 1199–1200, 1217–1218, 1233
RenderComplete method, 1112, 1118
RenderFullScreen method, 1200, 1222
ReportEvent method (ITypeLibExporterNotify-Sink interface), 1044–1045, 1289
ReportEvent method (ITypeLibImporterNotifySink interface), 1289
reporting errors, 720–721
HRESULTs
failure, 721
success, 721–722
setting information, 722–728
ReportWarningsToConsole value, 1061
Reset method, 1151–1152, 1158, 1162, 1166
ResizeAndDrawAt method, 1136, 1140, 1143–1144, 1146
ResizeAndDrawSurface method, 1112
ResolveRef method (ITypeLibExporterNotifySink interface), 1053–1054, 1289
creating assemblies from type libraries, 1045–1046
implementation, 1045
ITypeLibImporterNotify-Sink interface, 1289
TypeLibConverter class, 1045
resources
management, 731–733
unmanaged, 326
RestrictedAttribute, 508–509
Ring event, 592–593
Ring method, 596
RingEventHandler class, 596
role-based security, 21
running object tables, 1301
runtime environment, 15
Runtime-Callable Wrapper. See RCW
RuntimeEnvironment class, 1351–1352
methods
FromGlobalAccess-Cache, 1351
GetRuntimeDirectory, 1351
GetSystemVersion, 1352
properties, 1351
safe mode, 19
SAFEARRAY parameters, 517
SafeArrayAsSystemArray flag, 1043
SafeArrayGetVartype API, 946
SafeArrayRankMismatch-Exception (System.Runtime.InteropServices namespace), 1352
SAFEARRAYs, 154–156, 348–351, 717–719
adding size to C-style arrays, 349–351
custom marshaling .NET string, 943–947
UnmanagedType enumeration values, 550–552
variants containing structures, 273–275
SafeArraySubType parameter, 338–340, 1343
SafeArrayTypeMismatch-Exception (System.Runtime.InteropServices namespace), 1352–1353
SafeArrayUserDefinedSubType parameters, 1344
Sams.SmartTags namespace, 643
saving
assemblies, 1048–1050
dynamic type libraries, 1055
SCODE data type, 150–151
score field, 1121
ScorePicture field, 1121
screen (Console), clearing, 868–870
Screen method, 1155
SDK (Software Developer Kit), 15, 33–34, 78
COM utilities, 55–56
compared to Interactive Interop Tool, 1062–1063
referencing ActiveX controls, 122–123
referencing COM components, 81–84
running Office XP smart tags example, 650
tools, 960–962
SecureMethodAttribute, 585
security, 20
code-access, 21
link demands, 306
role-based, 21
security identifier. See SID
SecurityPermission-Attribute, 305
SecurityRoleAttribute, 585
SEHException (System.Runtime.InteropServices namespace), 1353
Sequential value, 1290
serialization permission, 304
servers
inproc, 63
outproc, 63
serviced components, installation, 1059–1061
services, Web, 14
set accessors, 442
SetCodeBase value, 1254
SetComObjectData method (Marshal class), 1331
SetConsoleCtrlHandler function, 815–817
SetCurrentPreset method, 1201
SetErrorInfo interface, 728
SetGUID method, 728
SetLastError parameter, 800–801, 1267
SetPosition method, 1147–1149
SetVolumeLabel function, 783–784
shared names, 23–24
SHELL32.DLL, 1470–1471
shutdown functions, 492–493
Shutdown method, 227
SID (security identifier), 847–848
side-by-side components, 18–19
sideEdge field, 1147
signatures (.NET), 729
C#, 899–901
GetObjectAttribute method, 260
GetSite, 729
Interop Assembly, 344
metadata, 249
methods, 652
premature Garbage Collection, 852–853, 856, 859–862
unsafe C# code, 849–852
variable-length, 849
signatures (PInvoke), 1432–1433
arrays, 792–794
calling conventions, 799–800
changing exact spelling, 799
converting data types, 778–781
Declare statement, 795–796
default marshaling for parameters, 782
diagnostics, 778
error handling, 800
error codes, 800–802
exceptions on failure, 803–807
SHELL32.DLL, 1470–1471
strings, 782
customizing behavior, 796–799
System.IntPtr, 789–791
System.String, 783–784, 787–788
System.Text.StringBuilder, 783–786
SignCode.exe, 24
signing
assemblies, 24
SignCode.exe, 24
/silent (AXIMP.EXE), 1393
/silent (REGASM.EXE), 1389
/silent (TLBEXP.EXE), 1384
/silent (TLBIMP.EXE), 1381
Simple Object Access Protocol. See SOAP
Single string value, 276
single-dimensional arrays, 719–720
Single-Threaded Apartments. See STAs
SingleUse setting (instancing), 633
sink helper class (NetMeeting coclass interface), 1016
size, adding to C-style arrays, 349–351
size method, 1136
Size parameter, 830
SizeConst parameters, 1344
SizeOf method (Marshal class), 1331
SizeParamIndex parameters, 1344
skins (Media Player), 1196
smart tag
explicit interface members, 655–656
HRESULTs, 656
inheritance, 654–655
parameterized properties, 653–654
smart tagsrunning example
.NET Framework SDK, 650
Visual Studio .NET, 649–650
SmartTagCaption property, 645
SmartTagCount property, 644–645
SmartTagDownloadURL property, 645
SmartTagID parameter, 645
SmartTagLib namespace, 643
SmartTagName property, 645
SN.EXE (Strong Name Utility), 380
SOAP (Simple Object Access Protocol), 14
software, 14
Software Development Kit. See SDK
SomeFormattedClass table entry, 433
SomeMethod method, 479
Sound class, 1133–1136
Sound method, 1134
sounds, 810
/source (AXIMP.EXE), 1393
source files, 1109–1111
source interfaces (COM callbacks), 215–216
defining classes in IDL files, 703–704
DownloadBegin, 239
DWebBrowserEvents, 226
DWebBrowserEvents2, 226
IChatRoomDisplay, 216
IConnectionPointContainer, 216
Source string, 722
SourceInterfaceName_Event interface, 222
SourceInterfaceName_EventProvider interface, 222
SourceInterfaceName_MethodNameEvent class, 236
SourceInterfaceName_MethodNameEvent-Handler delegate, 235
SourceInterfaceName_MethodNameEvent-Handler interface, 222
SourceInterfaceName_SinkHelper interface, 222
Spell Checking application, 127–130, 133–137
SQL Distributed Management Objects. See SQLDMO
SQLDMO (SQL Distributed Management Objects), 293
STA value, 280, late binding, 404
StackTrace, 723
STAs (Single-Threaded Apartments), 276–277, 282–289
state field, 1121
statements
Declare
changing string behavior, 797–799
customizing, 795
function names, 796
PInvoke, 773–775
#import, 502
Imports (Visual basic .NET), 38
using (C#), 35
STAThreadAttribute, 1100
static entry points, 772
callbacks, 810–821
choosing DLL locations dynamically, 863–865
choosing DLL names dynamically, 863–865
customizing structures, 829
FieldOffsetAttribute, 832–833
formatted classes, 839–844
MarshalAsAttribute, 834–839
StructLayoutAttribute, 829–832
structure inspection, 844–847
DUMPBIN.EXE, 772
passing structures, 821–829
Platform Invocation Services. See PInvoke
variable-length structures, 847–849
static members, reflection, 482–488
STATSTG value type (System.Runtime.InteropServices namespace), 1353
status codes, HRESULTS, 67–68
StdCall value, 1255
STDOLE2.TLB, 194
Stream class, 889–895
/strictref (TLBIMP.EXE), 1380
strings, 782
BSTR, 149–150
customizing behavior, 796–799
help, 382
HelpLink, 723
LPSTR, 149–150
LPWSTR, 149–150
MarshalAsAttribute, 1342
marshaling to SAFEARRAYs, 943–947
Message, 722
Source, 722
System.IntPtr, 789–791
System.String, 783–784, 787–788
System.Text.StringBuilder, 783–786
StringToBSTR method (Marshal class), 1331–1332
StringToCoTaskMemAnsi method (Marshal class), 1332
StringToCoTaskMemAuto method (Marshal class), 1332
StringToCoTaskMemUni method (Marshal class), 1333
StringToHGlobalAnsi method (Marshal class), 1333
StringToHGlobalAuto method (Marshal class), 1333–1334
StringToHGlobalUni method (Marshal class), 1334
StringValidator assembly, 381, 392
StringValidator class, 381
C#, 380–381
JScript, 388–390
Visual Basic 6, 382–384
Strong Name Utility. See SN.EXE
strong names, assemblies, 23–24
strTypeLibName parameter, 1050
struct (IntPtr type), manipulating, 258–262
StructLayoutAttribute (System.Runtime.InteropServices namespace), 270, 433, 1354
customizing structure layout, 554–556
customizing structures, 829–832
formatted classes, 839–844
LayoutKind enumeration, 554, 829–830
parameters, 830
structs, IWMPEffects interface, 1204–1208
COAUTHINFO, 873
COM, converting, 189–191
customizing, 829
FieldOffsetAttribute, 832–833
formatted classes, 839–844
MarshalAsAttribute, 834–839
StructLayoutAttribute, 829–832
structure inspection, 844–847
layout, customizing, 554–556
MULTI_QI, 873
names, 707–709
passing, 821–829
variable-length, 847–849
StructureToPtr method (Marshal class), 1019–1022, 1334–1336
success HRESULTs, 342–343, 580, 721–722
metadata changes, 344–348
SuppressUnmanagedCodeSecurityAttribute, 308, 778
SynchronizationAttribute, 276, 586
syntax, ILASM.EXE, 328–329, 331
ApplicationEvents_SinkHelper class constructor, 332
changing data types, 340–342
custom attributes, 351–358
data types, 332–333
exposing HRESULTs, 342–348
input files, 331
MarshalAsAttribute, 334–340
nested types, 334
passing parameters, 334
SAFEARRAYs, 348–351
/sysarray (TLBIMP.EXE), 1380
SYSKIND enumeration (System.Runtime.InteropServices namespace), 1354–1355
System namespace, 35
System method, 1135
System Monitor, 320–321
System namespace, 52, 620, 643, 887, 894, 1016, 1066–1068, 1079, 1096, 1118, 1131, 1138, 1146, 1149, 1152, 1156, 1171, 1215
C# keywords, 35
C++ keywords, 42–43
IntPtr type, 270
Visual Basic .NET keywords, 39
System.Activator class, 99
System.AppDomain.Unload method, 1049
System.Collections namespace, 596, 743–747
System.Collections.ArrayList instance, 463
System.Collections.Ienumerable interface, 740
System.Collections.SortedList instance, 461
System.Collections.Stack class, 403
System._ComObject, 71, 104, 229–232, 295–298, 422, 696, 734–735
System._ComObject instance, 232
System.ComponentModel class, 620
System.Console class, 868
System.Diagnostics namespace, 321
System.Drawing assembly, 28, 34, 365
System.Drawing namespace, 1215
System.Drawing.dll type library, 396
System.Drawing.Font class, 910–912
System.EnterpriseServices namespace, 52, 584–586, 1059, 1099
System.EnterpriseServices.ServicedComponent class, 283, 507
System.Enum.Format method, 646
System.EventArgs class, 608
System.FlagsAttribute custom attribute, 1022
System.Globalization namespace, 620
System.Guid.NewGuid method, 60
System.Guid.ToString, 570
System.IConvertible interface, 652
System.IDisposable class, 69
System.IntPtr, 789–791
System.IntPtr data type, 248–250
System.IO.Stream class, 883–889
System.MarshalByRef-Object class, 295, 507
System.MTAThread-Attribute, 278
System.Object class, 295, 741–743
System.Reflection namespace, 26, 59, 270, 1066, 1096, 1215
System.Reflection.AssemblyDescription-Attribute, 1067
System.Runtime.CompilerServices.MethodImplAttribute, 276
System.Runtime.InteropServices namespace, 52, 218, 250, 297, 391, 596–598, 643, 772, 837, 861, 887, 909, 998, 1016, 1056, 1066–1067, 1118, 1138, 1215, 1250–1252
APIs, versus unsafe C# code, 250–254
obtaining value type addresses, 254–255
obtaining value type sizes, 255–258
classes, 620
CurrencyWrapper, 1263–1264
DispatchWrapper, 1264–1265
ErrorWrapper, 1267–1268
ExtensibleClassFactory, 1269–1271
Marshal, 1292–1342
RegistrationServices, 1349–1351
RuntimeEnvironment, 1351–1352
TypeLibConverter, 1356–1357
UnknownWrapper, 1366–1367
custom attributes, 1250
AutomationProxy-Attribute, 1254
ClassInterfaceAttribute, 1256–1257
CoClassAttribute, 1258
ComAliasName-Attribute, 1258
ComConversionLoss-Attribute, 1258
ComEventInterface-Attribute, 1258–1259
ComRegisterFunction-Attribute, 1261
ComSourceInterfaces-Attribute, 1261
ComUnregister-FunctionAttribute, 1262
ComVisibleAttribute, 1262–1263
DispIdAttribute, 1265–1266
GuidAttribute, 1278
IDispatchImplAttribute, 1282
ImportedFromTypeLib-Attribute, 1284
InterfaceTypeAttribute, 1285
LCIDConversion-Attribute, 1290–1291
PrimaryInterop-AssemblyAttribute, 1348
ProgIdAttribute, 1349
TypeLibFuncAttribute, 1358
TypeLibTypeAttribute, 1359
TypeLibVarAttribute, 1359
custom marshaling interfaces, 1252
delegates, 1345
enumerations
AssemblyRegistration-Flags, 1254
CALLCONV, 1255
CallingConvention, 1255–1256
CharSet, 1256
ClassInterfaceType, 1257
ComInterfaceType, 1260
ComMemberType, 1261
DESCKIND, 1264
ExporterEventKind, 1268–1269
FUNCFLAGS, 1272
FUNCKIND, 1273
GCHandleType, 1277
IDispatchImplType, 1283
IDLFLAG, 1283
IMPLTYPEFLAGS, 1283
ImporterEventKind, 1284
INVOKEKIND, 1287
LayoutKind, 1290
LIBFLAGS, 1291
PARAMFLAG, 1347
SYSKIND, 1354
TYPEFLAGS, 1355
TYPEKIND, 1355
TypeLibExporterFlags, 1357
TypeLibFuncFlags, 1358
TypeLibImporterFlags, 1358
TypeLibTypeFlags, 1359
TypeLibVarFlags, 1359
UnmanagedType, 1367–1368
VarEnum, 1369–1370
VARFLAGS, 1370
exceptions
COMException, 1259–1260
ExternalException, 1271
InvalidComObject-Exception, 1286
InvalidOleVariantType-Exception, 1286–1287
MarshalDirective-Exception, 1344–1345
SafeArrayRank-MismatchException, 1352
SafeArrayType-MismatchException, 1352–1353
SEHException, 1353
interfaces
ICustomAdapter, 1280–1281
ICustomFactory, 1281
ICustomMarshaler, 1281–1282
IRegistrationServices, 1287
ITypeLibConverter, 1287–1288
ITypeLibExporterNameProvider, 1288
ITypeLibExporterNotifySink, 1289
ITypeLibImporterNotifySink, 1289
UCOMIBindCtx, 1360
UCOMIConnection-Point, 1360
UCOMIConnection-PointContainer, 1360
UCOMIEnum-ConnectionPoints, 1360
UCOMIEnum-Connections, 1361
UCOMIEnumMoniker, 1361
UCOMIEnumString, 1361
UCOMIEnumVARIANT, 1361–1362
UCOMIMoniker, 1362–1363
UCOMIPersistFile, 1363
UCOMIRunningObjectTable, 1363
UCOMIStream, 1364
UCOMITypeComp, 1364–1365
UCOMITypeInfo, 1365
UCOMITypeLib, 1366
pseudo-custom attributes
ComImportAttribute, 1260
DllImportAttribute, 1266–1267
FieldOffsetAttribute, 1271–1272
InAttribute, 1284–1285
MarshalAsAttribute, 1342–1344
OptionalAttribute, 1345–1346
OutAttribute, 1346–1347
PreserveSigAttribute, 1347–1348
StructLayoutAttribute, 1354
tool APIs, 1252
value types
ArrayWithOffset, 1252–1254
BINDPTR, 1255
BIND_OPTS, 1255
CONNECTDATA, 1263
DESCUNION, 1264
DISPPARAMS, 1266
ELEMDESC, 1267
EXCEPINFO, 1268
FILETIME, 1272
FUNCDESC, 1272
GCHandle, 1273–1277
HandleRef, 1278–1280
IDLDESC, 1283
PARAMDESC, 1347
STATSTG, 1353
TYPEATTR, 1355
TYPEDESC, 1355
TYPELIBATTR, 1356
VARDESC, 1368
wrappers, 115
System.Runtime.InteropServices.CustomMarshalers namespace classes
EnumerableToDispatch-Marshaler, 1370
EnumeratorToEnumVariantMarshaler, 1371
ExpandoToDispatchEx-Marshaler, 1371–1372
TypeToTypeInfoMarshaler, 1372
System.Runtime.InteropServices.Expando namespace, 1372–1373
System.Runtime.InteropServices.ITypeLibExporterNameProvider interface, 1054–1055
C# method, 1054
C++ method, 1054
Visual Basic .NET method, 1054
System.Runtime.InteropServices.Marshal class, 307, 501, 845
System.Security.SuppressUnmanagedCodeSecurityAttribute, 308, 778
System.STAThread-Attribute, 278
in ASP.NET, 279–280
in C#, 279
System.String, 783–784, 787–788
System.Text namespace, 946
System.Text.RegularExpressions namespace, 381
System.Text.RegularExpressions.Regex class, 396
System.Text.StringBuilder, 783–786
System.Threading namespace, 275, 288
System.Threading.ApartmentState enumeration, 280
System.Threading.ManualResetEvent class, 286
System.tlb type library, 623
System.Type parameter, 568–570
System.Type.GetType method, 68
System.Web assembly, 510
System.Web.Services.WebService class, 507
System.Web.UI.Page class, 507
System.Windows.Forms assembly, 50, 427, 1221
System.Windows.Forms namespace, 52, 620, 1171, 1215
System.Windows.Forms.Control.Invoke method, 1100
System.Windows.Forms.Design.PictureBox-Designer.Initialize method, 508
System.Windows.Forms.dll type library, 396
System.Windows.Forms.Form class, 479, 507, 1221
System.Windows.Forms.Form.Menu property, 507
System.Windows.Forms.MainMenu class, 507
System.Windows.Forms.MessageBox.Show method, 50
System.Windows.Forms.tlb type library, 623
System.Xml assembly, 34
System.Xml.dll type library, 396
System32 directory, 25
SystemConfigurationFile property (RuntimeEnvironment class), 1351
SystemDefaultCharSize property (Marshal class), 1336
SystemDefinedImpl value, 1283
SystemMaxDBCSCharSize property (Marshal class), 1336
tables, running object, 1301
TagTypes enum, 643–644
TAPI (Microsoft Telephony API), 227
methods, 227–229
Target property (GCHandle value type), 1276
testing components from COM, 535–536
TextBoxFont property, 923
ThisCall value, 1255
ApartmentState property, 280
C#, 280–281
starting new threads, 282
Visual Basic .NET, 281
Both model, 733
COM, 275
apartment states, 277–282
apartment types, 276–277
callbacks to .NET objects, 282–289
HKEY_CLASSES_ROOTCLSID{CLSID}InProc-Server32 key string values, 276–277
incompatible apartments, 291–292
MTA (multi-threaded), 733
.NET Framework, 275
callbacks from COM objects to .NET objects, 282–289
COM apartment incompatibility, 291–292
COM apartment states, 277–282
COM apartment types, 276–277
COM ThreadingModel registry value, 276–277
concurrency, 275
threadsafe, 275
ThreadingModel registry value, 276–277
threadsafe, 275
ThrowExceptionForHR method (Marshal class), 1336–1337
throwOnMissingSubKey parameter, 569
TimedLevel structure, 1021
Title property, 1216–1217, 1233
titleScreen field, 1121
/tlb (REGASM.EXE), 1387–1389, 1057
/tlb (REGSVCS.EXE), 1396
tlb parameter, 1060
tlb switch (REGASM.EXE), 571
TLBEXP.EXE, 426, 535, 1040, 1062, 1382
/?, 1384
converting assemblies, 426
exported type library, 428
helpstrings, 427
LCID, 427
library names, 428
type library identification, 426–427
version numbers, 427
converting classes, 449–451
converting COM members, 434
.NET events, 446–447
.NET methods, 434–441
.NET properties, 441–444
converting enumerations, 453–454, 457
converting .NET data types, 429, 432–433
converting .NET interfaces to COM interfaces, 447–449
converting value types, 452–453
generating type libraries, 395–396
/help, 1384
/names, 1383
/nologo, 1384
/out, 1384
/silent, 1384
syntax, 1382
/verbose, 1384
TLBIMP.EXE, 1040, 1062–1063, 1376–1377
/?, 1381
/asmversion, 1377
creating PIAs, 686
customizing metadata, 693–694
names, 686–687
naming output assembly, 690–693
reasons for, 684–685
type library references, 687–689
/delaysign, 1377
/help, 1381
/keycontainer, 1377–1378
/keyfile, 1378
/namespace, 1379
/nologo, 1381
/out, 1378
/primary, 1379
/publickey, 1379
referencing COM components with SDK, 81–84
registering PIAs, 694–696
running on MSXML.DLL, 142
/silent, 1381
/strictref, 1380
syntax, 1376
/sysarray, 1380
troubleshooting, 167
/unsafe, 1380–1381
/verbose, 1381
writing IDL type libraries, 697–698
constants, 709–710
constructs, 710
defining classes, 702–707
naming enums, 707–709
referencing external types, 698–702
registering type libraries, 711
topEdge field, 1147
ToString method, 743
IFormattable interface implementation, 761–764
type library transformations, 439–440
TransactionAttribute, 586
transformations, 86
ActiveX controls, 196–198
classes, 179
coclasses, 180–182
RCW, 182–186
data types, 143–144
combining types, 145–151
complex types, 152–162
DISPIDs, 173–174
DISPID NEWENUM -4, 175–176
DISPID Value 0, 174–175
enumerations, 193–194
HRESULTs, 1400, 1406–1407, 1413, 1416–1417, 1423, 1429
interfaces, 177–179
methods, 162
by-value versus by-reference, 164–167
hiding HRESULTs, 162–164
[in, out] parameter, 167–169
[in] versus [out], 167–169
parameter arrays, 169–171
modules, 187–188
properties, 171–173
structures, 189–191
type libraries, 141–143
typedefs, 194–196
unions, 191–192
transformations (data types). See also type libraries
custom marshaling, 895–896
adapter objects, 901–903, 905–909
arrays, 943–947
by value, 914–923
deterministic release of resources, 947–952
ICustomMarshaler interface, 896–898
limitations, 952–953
MarshalAsAttribute, 895, 898–901
marshaling between .NET and COM fonts, 914–923
marshaling between System.IO.Stream and IStream, 923–943
marshaling by value versus reference, 910–913
.NET class implementations, 909
without custom marshaling, 882–883, 883–895
TreeView control, 624
troubleshooting. See also errors
InvalidCastException, 289–290
casting to RCW types, 295–299
QueryInterface failure, 290–295
TLBIMP.EXE, 167
tryAgainScreen. field, 1121
type libraries, 262, 426. See also transformations (data types)
converting, 141–143
assemblies, 426–428
classes, 449–451
COM members for .NET object models, 434–447
.NET interfaces to COM interfaces, 447–449
value types, 452–453
creating assemblies from, 1040
dynamic assemblies, 1042–1046
GetPrimaryInteropAssembly method, 1047–1048
saving, 1048–1050
TypeLibConverter class, 1040–1042
creating from assemblies, 1050
dynamic libraries, 1050–1055
saving dynamic libraries, 1055
disabling marshaling, 580–582
dynamic
creating, 1050–1055
saving, 1055
errors, 294
exported, 428
exporter, 394–397
COM-Callable Wrappers. See CCWs
generating type libraries, 395–396
helpstring, 382
importer transformations to create IntPtr types. See IntPtr types
importer transformations to expose connection points, 222–227, 235–240
importing in separate application domains, 1049–1050
LCID (Local Identifier), 529
loading, 1043
MarshalAsAttribute C# signature exportation, 900–901
marshaling, 291
Microsoft Direction Animation, 731
mscorlib.tlb, 623
names, 141–143
OLEVIEW.EXE, 535
references
creating PIAs (Primary Interop Assemblies), 687–689
OLEVIEW.EXE, 688
referencing in Visual Studio .NET, 79–81
searching for, 662
System.Collections class interface transformations, 743–747
System.Drawing.dll, 396
System.tlb, 623
System.Windows.Forms.dll, 396
System.Windows.Forms.tlb, 623
System.Xml.dll, 396
TLBEXP.EXE, 426
VBA, 64
versioning, 529
Windows Registry, 65
writing IDL, 697–698
ActiveX controls, 712
constants, 709–710
constructs, 710
defining classes, 702–707
naming enums, 707–709
referencing external types, 698–702
registering type libraries, 711
type library importer. See Interop Assembly
Type Library to Assembly Converter. See TLBIMP.EXE
Type parameter, 600
Type property, 502
type safety, .NET Framework, 66
type systems, 64
Type.GetTypeFromCLSID method, 309
Type.GetTypeFromProgID method, 309
TYPEATTR value type (System.Runtime.InteropServices namespace), 1355
typedefs, 194–196
TYPEDESC value type (System.Runtime.InteropServices namespace), 1355
TYPEKIND enumeration (System.Runtime.InteropServices namespace), 1355
TYPELIBATTR value type (System.Runtime.InteropServices namespace), 1356
TypeLibConverter class, 85, 1052, 1356
creating assemblies from type libraries, 1040
C# methods, 1040
C++, 1041
dynamic assemblies, 1042–1046
GetPrimaryInterop-Assembly method, 1047–1048
ITypeLibConverter interface, 1042
Visual Basic .NET methods, 1041
creating type libraries from assemblies, 1050–1055
generating type libraries, 395
methods
ConvertAssemblyTo-TypeLib, 1356
ConvertTypeLibTo-Assembly, 1356–1357
GetPrimaryInterop-Assembly, 1357
ResolveRef method, 1045
TypeLibExporterFlags enumeration (System.Runtime.InteropServices namespace), 1357, 1051
TypeLibFuncAttribute (System.Runtime.InteropServices namespace), 1358
TypeLibFuncFlags enumeration (System.Runtime.InteropServices namespace), 1358
TypeLibImporterFlags enumeration (System.Runtime.InteropServices namespace), 1043–1044, 1358
TypeLibTypeAttribute (System.Runtime.InteropServices namespace), 1359
TypeLibTypeFlags enumeration (System.Runtime.InteropServices namespace), 1359
TypeLibVarAttribute (System.Runtime.InteropServices namespace), 1359
TypeLibVarFlags enumeration (System.Runtime.InteropServices namespace), 1359
TypeLoadException, 313, 392, 403
TypeRepresentsComType method (Registration-Services class), 1057, 1350
TypeRequiresRegistration method (RegistrationServices class), 1058, 1351
types. See also data types
IntPtr, 789–791
RCW. See RCW types
System.Runtime.Interop-Services namespace. See System.Runtime.Interop-Services namespace
TypeToTypeInfoMarshaler class, 1372
/u (REGSVCS.EXE), 1396
/u option (REGASM.EXE), 569
U1 value, 834
U2 value, 834
UCOMIBindCtx interface, 1360
UCOMIConnectionPoint interface, 1360
UCOMIConnectionPoint-Container interface, 1360
UCOMIEnumConnection-Points interface, 1360
UCOMIEnumConnections interface, 1361
UCOMIEnumMoniker interface, 1361
UCOMIEnumString interface, 1361
UCOMIEnumVARIANT interface, 1361–1362
UCOMIMoniker interface, 1362–1363
UCOMIPersistFile interface, 1363
UCOMIRunningObjectTable interface, 1363
UCOMIStream interface, 1364
UCOMITypeComp interface, 1364–1365
UCOMITypeInfo interface, 1365
UCOMITypeLib interface, 1366
Unadvise interface, 216
Unicode setting, 797–798
Unicode value, 1256
UnicodeEncoding class, 946
UnicodeEncoding.GetBytes method, 946
Uninstall method, 1100
UninstallAssembly method, 1061, 1099
unions, 191–192
Unknown value, 280
UnknownWrapper class (System.Runtime.InteropServices namespace), 1366–1367
UnknownWrapper wrapper, 115
adapter objects, 905–909
debugging COM Interoperability calls from managed code, 315–319
errors, 404–407
goals for interaction, 48–49
interaction with managed code, 49
C++ extensions, 50–51
COM Interoperability, 51–53, 69–71
JUMP to .NET, 51
PInvoke, 49–50
permission, 304
reflection, 482–488
StringValidator class
C++, 385–388
JScript, 388–390
UnmanagedType enumeration (System.Runtime.InteropServices namespace), 337–338, 1367–1368
MarshalAsAttribute, 542–545
ByValArray, 549
LPArray, 550
SAFEARRAY element types, 550–552
UnmanagedType.LPArray class, 337
UnmanagedType.SafeArray class, 337
UnmanageType values, 834
/unregister (REGASM.EXE), 1389
UnregisterAssembly method (RegistrationServices class), 1056, 1351
UnregisterFunction method, 644
unregistration functions, 569–570
/unsafe (TLBIMP.EXE), 1380–1381
unsafe code (C#), 849–852
UnsafeAddrOfPinned-ArrayElement method (Marshal class), 1337
UnsafeInterfaces flag, 1043
usage guidelines, 506
constructors, 513–514
data types, 516
nested arrays, 518–519
OLE Automation, 516–518
pointers, 518
user-defined value types, 519
enumerations, 514–516
interfaces versus classes, 506–508
interfaces versus custom attributes, 508–510
overloaded methods, 511–513
properties versus fields, 510–511
useBonusSound field, 1121
user experience, 14
user input, 865–868
user-defined data types, 519
user-defined exceptions, 521–523
using construct (C#), 1218–1220
using statement (C#), 35
public fields, 1112
Util.CreateSoundBuffer-FromFile method, 1135
V-table binding, 505
Validating event, 612, 622–623
value types
IntPtr. See IntPtr types
type library transformations, 452–453
unsafe C#
obtaining addresses, 254–255
obtaining sizes, 255–258
VARDESC value type (System.Runtime.InteropServices namespace), 1368
VarEnum enumeration (System.Runtime.InteropServices namespace), 337–338, 1369–1370
VARFLAGS enumeration (System.Runtime.InteropServices namespace), 1370
variable-length signatures, 849
variable-length structures, 847–849
variants
data type, 146–147
instances, 117–118
OLE Automation, 517
parameters, 720
varying arrays, 158–159
VB .NET
definitions
addImport and addRule parameters, 994
DispHTMLStyleSheet interface and the HTMLStyleSheet coclass interface, 1004–1006
IHTMLStyleSheet interface, 991
IRunningAppCollection, 980–981
IWMPEffects Interface, 974
modules, 356–358
VB6.EXE, registering assemblies, 392
VBA (Visual Basic for Applications), 64
VerbCaptionFromID property, 645
VerbCount property, 645
VerbID parameter, 645
VerbID property, 645
VerbNameFromID property, 646
/verbose (AXIMP.EXE), 1393
/verbose (REGASM.EXE), 1390
/verbose (TLBEXP.EXE), 1384
/verbose (TLBIMP.EXE), 1381
Verbs enum, 643
version numbers, assemblies, 427
assemblies, 527–529
clients
COM, 528–529
.NET, 527–529
CLSIDs, 530–531
IIDs, 531–532
LIBIDs, 529
members, 527
.NET Framework, 16
CLR, 19
DLL Hell, 17–18
policies, 19
resiliency, 16
side-by-side components, 18–19
ProgIDs, 65
visibility (COM), 477–482, 562–565
Visual Basic .NET, 38
ApartmentState property, 281
callback functionality using delegates, 206–208
callback functionality using events, 212–214
coclass IDL representation of .NET classes, 450–452
code to handle COM callbacks on another thread, 287–289
code with COM callbacks on separate threads, 283–286
COM View and .NET View
of an event, 446
of methods with parameter arrays, 441
of properties, 442
of the same methods, 147
ComClassAttribute, 560–562
compatibility, 38
ComVisibleAttribute, 562–565
custom attributes, 40–42
definition of IProvideClassInfo, 673–674
explicit interface implementation, 656
Hello, World, 39–40
IObjectSafety, 677
ItypeLibImporterNotifySink interface methods, 1044, 1052
keywords corresponding to System namespace, 39
.NET View and COM View
of the same overloaded methods, 438
PInvoke, 773–775
Register for COM Interop option, 534
RegistrationHelper class methods, 1059
RegistrationServices class methods, 1056
strings, 787–788
syntax for imported C-style array fields, 262–264
TypeLibConverter class, 1041, 1050
Visual Basic 6
class interfaces, 397–399
coclass IDL representation of .NET classes, 452
COM, 57
COM View and .NET View
of an event, 447
of fields exported as properties, 445
of properties, 442
compiling projects without binary compatability, 294–295
errors, returned error codes/messages, 403–404
forms, custom marshaling, 921–923
IPhoneEvents interface, 597
.NET interfaces, 759–764
.NET View and COM View
of the same methods, 435–437
of the same overloaded methods, 439
optional parameters, 105
setting error information, 723–724
StringValidator class, 382–384
Visual Basic for Applications, 64
Visual Basic Runtime, 15
Visual C++, 42
custom attributes, 43–45
Hello, World, 43
keywords corresponding to System namespace, 42–43
.NET definition of AddressLists dispinterface, 982–984
.NET interfaces, 747–759
setting error information, 725–728
Visual Studio .NET
COM interface shortcuts, 650
custom attributes, 652
members, 653
selecting Implement Interface,, 651–652
selecting members, 651
syntax changes, 652–653
mixed-mode debugging, 315–319
referencing ActiveX controls, 121–122
referencing COM components, 78, 83–84
Register for COM Interop option, 535
running Office XP smart tags example, 646–650
BookExamples.WindowsMediaPlayer assembly, 1201
IWMPEffects interface, 1199, 1202–1204
enumerations, 1204–1208
Render method, 1199–1201
structs, 1204–1208
Vizualization class, 1208–1223
registry keys, 1197–1198
Visualization Wizard, 1198
Visualization class, 1208–1223, 1229
Visualization Wizard, 1198
visualizations (Media Player), 572, 1196
COM objects, 1196–1197
.NET Visualization API, 1224
ColorfulVisualization, 1231–1235
Dancing Cat Visualization, 1235–1243
SimpleVisualization, 1224–1226
WizardVisualization, 1227–1230
BookExamples.WindowsMediaPlayer assembly, 1201
IWMPEffects interface, 1199–1223
registry keys, 1197–1198
Visualization Wizard, 1198
waveform array, 1199
Weak value (GCHandleType enumeration), 1277
WeakTrackResurrection value (GCHandleType enumeration), 1277
Web services, 14
Web sites, DirectX, 1106
WebBrowser control, 236
events, 241–245
referencing ActiveX controls, 123, 126
Width property, 1136, 1139–1140, 1143
Win32
APIs
CopyFileEx, 810–815
data types, converting into .NET types to define PInvoke signatures, 778–781
error handling, 800–807
MessageBeep, 810
PlaySound, 810
ReadConsoleInput, 865–868
RegCloseKey, 856
RegDeleteKey, 860
RegEnumKey, 856
RegOpenKey, 856
functions
customizing string behaviors, 796–799
GetConsoleScreen-BufferInfo, 821–829
GetLastError, 800
GetWindowsDirectory, 784–788
SetVolumeLabel, 783–784
PInvoke, 772
Winapi value, CallingConvention enumeration, 1256
WINCV.EXE tool (Windows Forms Class Viewer tool), 960–962
WindowResize event, 226
Windows Explorer, GAC, 24
Windows Forms
controls, 471–477
exposing events to COM, 611
COM event sink, 623–625
.NET event source, 611–614, 620–623
FontMarshaler custom marshaler, 918–923
Interactive Interop Tool, 1100–1101
Windows Forms Class Viewer tool. See WINCV.EXE tool
Windows Media Player. See Media Player
Windows Registry
COM components, 62
compared to GAC, 64
ProgIDs, 63
type library versions, 65
windowsForm_Activated method, 625
windowsForm_ChangeUICues method, 625
windowsForm_DragDrop method, 625
WINMM.DLL, 810
WithEvents keyword, 603
automatic event handler hookup, 604
callback functionality using events in Visual Basic .NET, 213–214
wizards
ATL COM (C++), 725
ATL Simple Object (C++), 726
Visualization, 1198
Word, Spelling Checking application, 127–130, 133–137
wrappers
DispatchWrapper, 115
ErrorWrapper, 115
RCW, 69–71
System.Runtime.InteropServices namespace, 115
UnknownWrapper, 115
WriteByte method (Marshal class), 1337–1339
WriteInt16 method (Marshal class), 1340
WriteInt32 method (Marshal class), 1340–1341
WriteInt64 method (Marshal class), 1341
WriteIntPtr method (Marshal class), 1342
writing
custom attributes, 29–30
IDispatch implementations, 665–672
WSCRIPT.EXE, registering assemblies, 392
XCOPY deployment, 20
zero-bounded arrays, 719