.NET Development Foundation/Interoperability Classes

From Wikibooks, open books for an open world
Jump to navigation Jump to search


Interoperability, Reflection, and Mailing: Classes, interfaces and tools


Classes, Interfaces, and tools[edit | edit source]

COM interoperability[edit | edit source]

Exam objective: Expose COM components to the .NET Framework and .NET Framework components to COM

(Refer System.Runtime.InteropServices namespace)

Exposing COM Components to the .NET Framework[edit | edit source]

First there is an article in the .NET developers guide that covers the first part of this section, see MSDN

Import a type library as an assembly - MSDN

Add references to type libraries
Same link as above, see second paragraph.
Type Library Importer (Tlbimp.exe) - MSDN
Generate interop assemblies from type libraries - MSDN
Imported Library Conversion - MSDN
Imported Module Conversion - MSDN
Imported Type Conversion - MSDN
Imported Member Conversion - MSDN
Imported Parameter Conversion - MSDN
TypeConverter class - MSDN

Create COM types in managed code - MSDN

Compile an interop project - MSDN

Deploy an interop application - MSDN

Exposing .NET Framework Components to COM[edit | edit source]

The rest of the objectives of that section directly refers to MSDN

Qualify the .NET Framework types for interoperation - MSDN

Apply Interop attributes, such as the ComVisibleAttribute class - MSDN

Package an assembly for COM - MSDN

Deploy an application for COM access - MSDN

Call DLL functions[edit | edit source]

Exam objective: Call unmanaged DLL functions in a .NET Framework application, and control the marshalling of data in a .NET Framework application.

(Refer System.Runtime.InteropServices namespace)

Platform Invoke - MSDN

Create a class to hold DLL functions - MSDN

Create prototypes in managed code - MSDN

DllImportAttribute class - MSND

Call a DLL function - MSDN

Look for "P/Invoke" on the internet.
A good reference is: http://www.pinvoke.net/
Some short hints:
  • For the DllAttribute "CharSet", Logically, CharSet.Auto is the most secure way as this will autodetect the Charset used. The CharSet can be ANSI(Win95/Win98/ME) or Unicode (Win2000/WinXP)
  • GetEntryPoint: There could be one tricky question as the EntryPoint states the method that should be called. In case the name of the method used differs from the method to be called, this flag is necessary.

Call a DLL function in special cases, such as passing structures and implementing callback functions

Same link as above
Passing structures - MSDN
Implementing callback functions - MSDN

Create a new Exception class and map it to an HRESULT - MSDN

Default marshaling behavior - MSDN

Marshal data with Platform Invoke - MSDN

Marshal data with COM Interop - MSDN

MarshalAsAttribute class and Marshal class

MarshalAsAttribute class - MSDN
Marshal class - MSDN

Implement Reflection[edit | edit source]

Exam objective: Implement reflection functionality in a .NET Framework application (refer System.Reflection namespace), and create metadata, Microsoft intermediate language (MSIL), and a PE file by using the System.Reflection.Emit namespace.

Building a custom attribute (annexes)

Assembly class -MSDN

Assembly attributes - MSDN

AssemblyAlgorithmIdAttribute class - MSDN
AssemblyCompanyAttribute class - MSDN
AssemblyConfigurationAttribute class - MSDN
AssemblyCopyrightAttribute class - MSDN
AssemblyCultureAttribute class - MSDN
AssemblyDefaultAliasAttribute class - MSDN
AssemblyDelaySignAttribute class - MSDN
AssemblyDescriptionAttribute class - MSDN
AssemblyFileVersionAttribute class - MSDN
AssemblyFlagsAttribute class - MSDN
AssemblyInformationalVersionAttribute class - MSDN
AssemblyKeyFileAttribute class - MSDN
AssemblyTitleAttribute class - MSDN
AssemblyTrademarkAttribute class - MSDN
AssemblyVersionAttribute class - MSDN

Info classes

ConstructorInfo class - MSDN
MethodInfo class - MSDN
MemberInfo class - MSDN
PropertyInfo class - MSDN
FieldInfo class - MSDN
EventInfo class - MSDN
LocalVariableInfo class - MSDN

Binder class and BindingFlags - MSDN

MethodBase class and MethodBody class

MethodBase class - MSDN
MethodBody class - MSDN

Builder classes

AssemblyBuilder class - MSDN
ConstructorBuilder class - MSDN
EnumBuilder class - MSDN
EventBuilder class - MSDN
FieldBuilder class - MSDN
LocalBuilder class - MSDN
MethodBuilder class - MSDN
ModuleBuilder class - MSDN
ParameterBuilder class - MSDN
PropertyBuilder class - MSDN
TypeBuilder class - MSDN

Send Electronic mail[edit | edit source]

Exam objective: Send electronic mail to a Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application.

(Refer System.Net.Mail namespace)

MailMessage class - MSDN

MailAddress class and MailAddressCollection class

MailAddress class - MSDN
MailAddressCollection class - MSDN

SmtpClient class, SmtpPermission class, and SmtpPermissionAttribute class

SmtpClient class - MSDN
SmtpPermission class - MSDN
SmtpPermissionAttribute class - MSDN

Attachment class, AttachmentBase class, and AttachmentCollection class

Attachment class - MSDN
AttachmentBase class - MSDN
AttachmentCollection class - MSDN

SmtpException class, SmtpFailedReceipientException class, and SmtpFailedReceipientsException class

SmtpException class - MSDN
SmtpFailedReceipientException class - MSDN
Please note that there is a typo in the exam objective page here, they use SmtpFailedReceipientException instead of SmtpFailedRecipientException.
SmtpFailedRecipientsException class - MSDN
Same typo then above

SendCompleteEventHandler delegate - MSDN

LinkedResource class and LinkedResourceCollection class

LinkedResource class - MSDN
LinkedResourceCollection class - MSDN

AlternateView class and AlternateViewCollection class

AlternateView class - MSDN
AlternateViewCollection class - MSDN