C


C++. See also Visual C++ 2005; Visual C++ 6; Visual C++ .NET

advantages over C#, 6–7

class for CLS example, 427–432

CLR memory type safety tests and, 7

constants in C# versus, 38

destructors, 200

memory management, 13

templates compared to C# generics, 272

CalculateDocumentSize() method, 886–887

CalculateLineWidths() method, 886

calculating permissions required for an assembly, 481, 483–484

calendar_DayRender() event handler, 930–931

calendar_SelectionChanged() event handler, 930

call contexts (.NET Remoting), 1062–1064

callback functions, 171. See also delegates

camel casing, 76–77

CapsEditor example

appearance, 880–881

CalculateDocumentSize() method, 886–887

CalculateLineWidths() method, 886

coordinate transforms, 889–890

CreateFonts() helper method, 883–884

extending for print functionality, 893–899

File menu, 880

Form1 class fields, 882

functionality, 880

initialization, 883

Invalidate() method, 884–886

LineIndexToPageCoordinates() method, 890

LineIndexToWorldCoordinates() method, 889

LoadFile() method, 884

main menu, 883–884

OnPaint() method, 887–888

PageCoordinatesToLineIndex() method, 890, 893

responding to user input, 890–893

TextLineInformation class and, 882–883

using statements, 881–882

WorldCoordinatesToLineIndex() method, 889

WorldYCoordinateToLineIndex() method, 889

case of names

camel casing, 76–77

IL case sensitivity, 12

Pascal casing, 76, 77

Visual Basic .NET not case-sensitive, 77

caspol.exe (Code Access Security Policy tool)

applying full trust, 492, 502

changing code group permissions, 494–495

creating and applying permissions sets, 495–497

creating code group using strong name, 498

creating custom code groups, 493–494

deleting code groups, 494

Execution Checking setting, 468

getting code group labels, 491

labels for code groups, 469

listing code groups and descriptions, 466–467

listing code groups compactly, 468

listing options for, 466

Policy change prompt option, 469

resetting security policy, 493

specifying trust level for code groups, 468

turning security on and off, 493

verifying the trust level, 503

viewing code access permissions for assemblies, 474–476

viewing code groups at enterprise level, 477–478

viewing code groups at user level, 476–477

viewing code groups for assemblies, 469–471, 503–504

viewing permission sets, 497

casting. See also user-defined casts

array list elements, 251

compilation and, 165–166

converting array element to struct member variable, 144

converting nullable types, 144

converting primitive types, 143–144

dangers of, 143

data loss from, 143–144, 166–167

limitations of, 144

between numeric and string types, 144–145

between pointer types, 208–209

pointers to integer types, 208–209

QueryInterface() method and, with COM, 1154–1155

catch blocks

defined, 330

error trapping process and, 330

exceptions not handled and, 338

MortimerColdCall example, 342–343

multiple blocks, 331, 332–336

omitting, 331

for releasing database resources, 586, 587–588

in SimpleExceptions class, 335–336

syntax, 331

throwing an exception and, 331

throwing exceptions from, 339

CCOMDemo class, 1161, 1162–1163, 1167

CCW (COM callable wrapper), 1172

certificates. See digital certificates

channels (.NET Remoting)

created on both server and client side, 1021

defined, 1012, 1020

delayed loading of client channels, 1046

getting configuration information for, 1022–1023

HTTP channel, 1021

interfaces for, 1022

IPC channel, 1021

listening to multiple channel by server, 1021–1022

marshal-by-value classes and, 1031

pluggability of, 1024–1025

predefined, 1041–1042

server-side creation, 1021

setting properties for, 1023–1024

ShowChannelProperties() method, 1023

TCP channel, 1021

ChannelServices class, 1012, 1025–1026

char type, 42, 43–44

CheckBox control (Windows Forms), 764

checked operator, 137, 162

CheckedListBox control (Windows Forms), 765

chktrust.exe utility, 501

class hierarchies

for data-binding objects, 817–818

DataGridView control, 813–816

for exceptions, 329–330

for streams, 1206

for WebRequest and WebResponse classes, 1257–1258

for Windows Forms, 757–758

class id (CLSID) for COM objects, 1155

class keyword, 32

Class View window (Visual Studio 2005), 396–397

classes. See also class hierarchies; derived classes;

specific classes and members

abstract, 117

accessing fields outside the object, 37–38

ADO.NET, 581–582

ASP.NET pages as, 22

constructors not required for, 95

context attribute classes, 1015–1016

context property classes, 1016

data members, 85

declaring instances, 84

default initialization of variables in, 34

defined, 84

for file system operations, 1188

for fonts and font families, 877

formatter classes (.NET Remoting), 1025

function members, 85–99

generic collection classes, 276–277

generic, custom, 293–296

generic .NET base classes, 277–278

marking members unsafe, 205

members, defined, 85

namespaces for, 21, 58–59

.NET base classes, 19–20

.NET Remoting and, 1031–1032

non-compliant with CLS, 426

not-remotable, 1032

partial, 104–106

Pascal casing for, 76

for performance monitoring, 1309

pointers to members, 212–214

pointers to, not allowed, 208, 212

readonly fields, 99–101

as reference types, 40, 84

registry classes, 1229–1232

for regular expressions, 223

for resources, 527–528, 533–534

sealed, 117–118

static, 106

stored in the heap, 84

structs versus, 84, 102

System.DirectoryServices namespace, 725

System.Xml.XPath namespace, 679

in Visual Studio 2005 Class View window, 396–397

in Visual Studio 2005 Object Browser window, 397–398

for Windows Services, 1275

XML-related, 660–661

ClearAllFields() method

FileProperties application, 1194

FilePropertiesAndMovement application, 1201

ClickOnce deployment technology, 568–569

advanced options, 570–576

application cache, 569

Custom Actions Editor, 573–575

dialog box types available, 572–573

File System Editor, 570

File Types Editor, 571

Launch Conditions Editor, 575–576

mage.exe command-line tool, 568

mageUI.exe gui tool, 568

overview, 553, 567

properties for actions, 575

publishing an application, 568

Registry Editor, 570–571

security settings, 569–570

settings, 568–569

User Interface Editor, 571–573

Windows Installer compared to, 567–568

XML-based manifest files, 567

client applications

ASP.NET client-side code, 905–906

COM client creation, 1179–1181

COM client with a sink object, 1182–1183

creating Web service clients, 991–992

for DatabaseResourceReader class, 549

event-booking client, 993–997

fat-client, 22, 24

hardware requirements for deployment, 553

.NET Remoting simple client, 1019–1020

using a COM component from a .NET client, 1159–1171

using a .NET component from a COM client, 1171–1183

using UDTs from client-side code, 642–643

WCF, 1144

ClientActivated_Client.config file (.NET Remoting), 1044

ClientActivated_Server.config file (.NET Remoting), 1043–1044

clipping region, 848–850

closing

database connections with ADO.NET, 583, 585–588

forms, 782

streams, 1209, 1215

CLR (Common Language Runtime)

application domains, 634

C++ and memory safety tests, 7

CLR Object Remoting, 1011

code access permissions provided by, 471–472

compilation steps for, 4

defined, 4

demanding permissions and, 478

enabling .NET code to run with SQL Server, 634

garbage collector, 13–14

heap maintained by, 13

Identity Permissions, 472–473

managed code advantages, 4–7

passing arguments to Main(),63

stored procedures with SQL Server, 646–647

Virtual Execution System, 465

CLS (Common Language Specification)

C# class for example, 434–436

C++/CLI class for example, 427–432

CLSCompliant attribute, 437

CTS and, 425–426

defined, 12

language independence using, 427–436

language interoperability and, 425, 426

marking assemblies as CLS-compliant, 437

non-compliant classes and methods, 426

overview, 12–13

requirements, 436–438

rules for compliance, 438

Visual Basic class for example, 432–434

writing non-CLS-compliant code, 12

CLSCompliant attribute, 437

CLSID (class id) for COM objects, 1155

code access security. See also code groups;

permissions for code access

caspol.exe (Code Access Security Policy tool), 466–471

code groups, 464, 465–471

as code-based security, 14

distributing code using certificates, 499–504

distributing code using strong names, 497–499

importance of, 464

overview, 464

permissions, 464, 471–476

policy levels, 476–478

Virtual Execution System and, 465

Code Access Security Policy tool. See caspol.exe

code bloat, generics and, 274

code groups. See also permissions for code access

applying full trust, 492, 502

caspol.exe (Code Access Security Policy tool), 466–471

changing permissions for, 494–495

creating custom, 493–494

deleting, 494

evidence, 464

getting labels for, 491

labels for, 469

levels, 470

listing compactly, 468

listing with descriptions, 466–467

managing, 492

membership conditions, 465–466

overview, 464

specifying trust level, 468

viewing code groups at enterprise level, 477–478

viewing code groups at user level, 476–477

viewing for assemblies, 469–471

Zone condition, 465, 504–506

code-behind feature (ASP.NET)

event-booking application code-behind file, 929–930

overview, 22

PCSWebApp1 example code-behind file, 909

ColdCallFileFormatException, 341, 346–347

ColdCallFileReader class

declaring variables, 343

described, 341

Dispose() method, 344, 345–346

NPeopleToRing property, 345

Open() method, 343–344

ProcessNextPerson() method, 344–345

using, 342

collections

Active Directory object collections, 731–732

arrays as, 247–248

Current property of elements, 247

defined, 246

enumerators, 246–247, 248

foreach loops for iterating through, 54, 246

generic, displaying with DataGridView control, 811–813

ICollection interface for, 247

IEnumerable interface for, 246–247

Reset() method for returning to start, 247

Vector struct example, 248–250

colon (:)

for disabling Group object with regular expressions (?:), 243

as namespace alias qualifier (::), 60–61

preceding format specifiers, 230

in ternary operator (?:), 136–137

Color struct, 863

colors in graphics applications

GDI+ struct for representing, 863

graphics display modes and, 865

named colors, 864–865

palettes, 865–866

RGB values, 863–864, 865

safety palette, 866

COM

ActiveX controls in Windows Forms, 1168–1171

apartment models, 1156–1157, 1166

attributes and, 17

casting and QueryInterface() method, 1154–1155

class id (CLSID) for objects, 1155

connection points, 1166–1168, 1181–1182

creating a client with a sink object, 1182–1183

creating a COM callable wrapper (CCW), 1172

creating a component, 1159–1163

creating a runtime callable wrapper (RCW), 1163–1166

creating a simple client, 1179–1181

custom interfaces, 1153

data types, 1155

debugging issues, 9

delegate for, 1181

dispatch interfaces, 1153–1154

dual interfaces, 1154

Enterprise Services history and, 1066

error handling, 1158

event handling, 1158, 1166–1168, 1181–1182

freeing memory, 1153

_ICompletedEvents client interface, 1166–1167

IDispatch interface, 1163, 1164

IMath interface, 1162, 1174, 1177–1178

instantiating components, 1165

interfaces, .NET interfaces versus, 8, 126

interfaces overview, 1153–1155

interop attributes, 1175–1178

interoperability with .NET (overview), 7

IUnknown interface, 1163, 1164

IWelcome interface, 1160–1161, 1162, 1174, 1177–1178

language interoperability and, 8–9, 425

marshaling, 1159

memory management, 13

metadata, 1152

method binding, 1155

MSXML based on, 662

multi-threaded apartment (MTA), 1157, 1166

namespace for objects, 1151

.NET and, 1152–1159

performance losses with, 8

primary interop assemblies, 1166

prog id for objects, 1155

registration, 1155, 1178–1179

releasing components, 1165

running Windows Forms controls in Internet Explorer, 1183

similar concepts in .NET, 1152

single-threaded apartment (STA), 1156–1157, 1166

threading, 1156–1157, 1166

tlbexp utility, 1173

tlbimp utility, 1163

type library for, 1173–1175

using a COM component from a .NET client, 1159–1171

using a .NET component from a COM client, 1171–1183

using objects in ASP.NET, 1171

COM callable wrapper (CCW), 1172

COM+

contexts, .NET contexts compared to, 1014

Enterprise Services history and, 1066

interoperability with .NET (overview), 7

simple Enterprise Services application, 1070–1073

combined characters. See Unicode characters

ComboBox control (Windows Forms), 765, 767

comma (,) in derived class or struct declarations, 113

comments

multi-line, 31, 67–68

single-line, 31, 67

within source files, 67–68

XML documentation, 68–70

Common Language Runtime. See CLR

Common Language Specification. See CLS

Common Type System. See CTS

comparison operators

assignment versus comparison, 48, 134–135

comparing reference types for equality, 147

comparing value types for equality, 147

overloading, 148, 155–157

table listing, 134

compiling. See also building

casts combined during, 165–166

class library example, 64–65

constructors and, 95, 119–120

csc.exe command-line compiler for, 31

custom attributes and, 306–307

destructors and, 199, 200

hiding methods and errors in, 116

inlining by compiler, 94–95

JIT (Just-In-Time) compilation, 5

modules, 421

MSIL code to native code, 439

multiple Main() methods and, 61–62

operators and, 149–150

optimization in Visual Studio 2005, 399–400

/out option for output file specification, 64

performance improvement with IL, 5

pointer arithmetic and, 210

preprocessor directives for, 70–73

PrintingCapsEdit project, 898

/reference or /r switch for reference types, 64

rules for identifiers and, 73–75

steps in .NET, 4

/target or /t switch for file type, 63–64

TypeView assembly, 319

usage conventions and, 75

from Visual Studio 2005, 372, 399–403

XML comments, 68–70

Component class, 755

Component Services explorer, 1075–1077

Computer Management MMC snap-in, 1101–1102

concatenation, operator overloads for, 224

conditional statements, 47. See also if statements ;switch...case statements

configuration files (.NET Remoting)

client code using, 1045

client configuration file for event handling, 1061

client configuration for client-activated objects, 1044

client configuration for well-known objects, 1043

debugging, 1046–1047

delayed loading of client channels, 1046

example online, 1039–1040

formatter providers, 1047–1048

lifetime services, 1047

main elements and attributes, 1040–1041

.NET Framework Configuration tool for, 1048–1050

.NET platform files versus, 1039

overview, 1039–1041

predefined channels, 1041–1042

RemotingConfiguration.Configure() method and, 1046

server code using, 1044–1045

server configuration file for event handling, 1059

server configuration for client-activated objects, 1043–1044

server configuration for well-known objects, 1042–1043

Configure() method (RemotingConfiguration class), 1044, 1045, 1046

configuring assemblies

application configuration files, 450, 453–456

categories, 450

<codeBase> configuration, 460–461

configuration files used instead of registry, 449

directories, 460–462

machine configuration files, 450

overview, 450–451

<probing> configuration, 461–462

publisher policy files, 450, 456–458

remoting settings, 450

runtime settings, 450

runtime version, 459–460

security settings, 450

startup settings, 450

versioning, 451–460

Connect() method (RemotingServices class), 1028, 1029, 1030

connection points (COM), 1166–1168, 1181–1182

Connection Properties dialog box (Visual Studio), 822–824

consistency of Enterprise Services transactions, 1078

console applications

creating in Visual Studio 2005, 377–383

defined, 21

for Enterprise Services client, 1077

first C# program, 30–33

.NET Remoting client, 1019–1020

.NET Remoting server, 1018–1019

role-based security example, 508–509

TestQuoteServer, 1279

threading with ThreadPool class, 365–368

uses for, 21

console I/O

displaying formatted output, 65–67

format strings, 66–67

method for reading, 65

methods for writing, 65

placeholder characters for output, 67

Console.ReadLine() method, 65

Console.Write() method, 65

Console.WriteLine() method

displaying formatted output, 65–67

formatting expressions, 229–230, 231

const keyword, 38, 85

constants

advantages of using, 38–39

associating with classes, 85

in C++ versus C#, 38

characteristics, 38

as data members of classes, 85

declaring, 38, 85

defined, 38

Pascal casing for, 76

readonly fields versus, 99

constraints, database

naming conventions, 630

setting update and delete constraints, 611–612

constructors

calling from other constructors, 98–99

compiler generation of, 95, 119–120

defined, 86

of derived classes, 118–124

FileStream class, 1208–1209

initializers, 99

instance and static in same class, 97

no-parameter, adding in a hierarchy, 120–122

not required for classes, 95

overloading, 95

with parameters, adding in a hierarchy, 122–124

public or protected, 96

QuoteServer class, 1277

static, 96–98

StreamReader class, 1214

StreamWriter class, 1216

for structs, 104

syntax, 95

Thread class, 352

of Windows Form classes, 755–756

consuming Web services, 990–993

ContextDataRow class, 834

ContextMenuAttribute, 834, 835, 837

ContextMenuStrip class (Windows Forms), 779

contexts (.NET Remoting)

activation, 1015

attributes, 1015–1016

call contexts, 1062–1064

COM+ contexts compared to, 1014

communication between, 1016

context-bound objects, 1015

Enterprise Services and, 1067–1068

interceptors, 1015

overview, 1014–1015

properties, 1015, 1016

continue statement, 55

Control class

appearance properties, 760

as base class for controls, 759

Form class inheritance from, 780

miscellaneous functionality, 762

overview, 759

size and location properties, 759–760

user interaction and, 760–761

Windows functionality, 761–762

control palette (ASP.NET), 913–914

ControlBindingsCollection class, 817, 819

ConvertAll() method (List<T> generic class), 282–283

converting. See also generics

ADO.NET relational data to XML, 694–696

ADO.NET single table data to XML, 689–694

array lists to arrays, 253

enumerations from strings, 57

explicit type conversions, 142–145

implicit type conversions, 141–142

need for type conversions, 141

nullable types and, 142

between numeric and string types, 144–145

types with List<T> generic class, 282–283

UDTs to and from strings, 640–641

between value and reference types, 145–146

to Visual Studio 2005 projects from previous versions, 374–376

XML to ADO.NET data, 696–699

CookieContainer class, 1004–1005

Coordinate struct

changing User-Defined Type template for, 637

constructors to initialize variables, 639

converting from a string, 641

converting to a string, 640–641

deploying, 642

get accessor, 640

INullable interface, 637

IsNull property, 640

Null property, 640

Orientation enumeration for, 639

serialization formats, 637–638

[SqlUserDefinedType] attribute, 637, 638

using from client-side code, 642–643

coordinates

converting relative to client area, 861–862

device coordinates, 863

page coordinates, 863

Point and PointF structs for, 851–852

Rectangle and RectangleF structs for, 853–854

Region struct for, 854–855

Size and SizeF structs for, 852–853

System.Drawing structs for, 850

transforms in CapsEditor example, 889–890

world coordinates, 863

Copy() method (File class), 1197

Copy Web tool, deployment using, 552, 555

copying files, 1197–1201

CopyTo() method (FileInfo class), 1197

Course class, 1111–1112

course order application (Message Queuing)

assemblies, 1111

class library, 1111–1113

Course class, 1111–1112

CourseOrder class, 1113

CourseOrderSender application, 1114

Customer class, 1112–1113

Invoke() method, 1117

LableIdMapping class, 1117–1118

message receiver, 1116–1119

message sender, 1114

OnOrderSelectionChanged() method, 1118–1119

OnSubmitCourseOrder() method, 1114

PeekMessages() method, 1116–1117

ReceivedById() method, 1119

sending priority and recoverable messages, 1115

CourseOrder class, 1113

Create() method

MessageQueue class, 1103, 1121

XmlReader class, 665

CreateFonts() helper method, 883–884

CreateGraphics() method (Form class), 845

CreateInstance() method (Activator class), 1027, 1028, 1029

CreateSubKey() method (RegistryKey class), 1230

cross-language support. See CLS (Common Language Specification); language interoperability with .NET

Crystal Reports Web server controls (ASP.NET), 914

.cs file extension, 30

csc.exe command-line compiler

compiling programs using, 31

creating modules using, 421

CTS (Common Type System)

CLS and, 425–426

hierarchy of types, 11–12

language interoperability and, 425

overview, 10–12

culturalization. See globalization; localization

CultureAndRegionInfoBuilder class, 549–550

CultureInfo class, 515, 518

curly braces ({ })

with if statements, 47, 48

joining statements in blocks, 31

Currency struct, 159–162

CurrencyManager class, 819, 820–822

Current property of collection elements, 247

Custom Actions Editor (ClickOnce), 573–575

custom attributes

AttributeUsage attribute and, 307–309

compilation and, 306–307

emitted as metadata, 306

FieldName attribute example, 307–310

finding dependencies for, 320

required specifications, 307

for serializing objects in XML, 702

specifying optional parameters, 309–310

specifying required parameters, 309

WhatsNewAttributes example, 310–313

custom controls (ASP.NET)

complexity of, 952

deriving from WebControl class, 952

.NET Framework and, 944

RainbowLabel example, 953–956

<%@ Register %> directive for, 952–953

user controls versus, 952

using in ASP.NET pages, 952–953

using statements, 953

custom controls (Windows Forms)

attributes useful to add to, 787–788

deriving from existing controls, 787

requirements for, 788

starting from scratch, 787

TreeView-based example, 788–794

user controls, 794–799

custom cultures, 549–550

custom generic classes

constraints, 294–296

default values, 294

defining, 293

DocumentManager class example, 293–294

custom interfaces (COM), 1153

Customer class, 1112–1113

CustomerTable class, 835–837

Cycle() method, 954




Professional C# 2005
Pro Visual C++ 2005 for C# Developers
ISBN: 1590596080
EAN: 2147483647
Year: 2005
Pages: 351
Authors: Dean C. Wills

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net