safety checking. See type safety
safety palette for colors, 866
SAX versus XmlReader class, 664
sbyte type, 41, 42
sc.exe utility, 1294–1295
schemas (Active Directory)
domain tree and, 717
getting the naming context for, 741–742
overview, 715, 719–720
schemas (database)
building an XSD schema, 827–832
defined, 601
hand-coded, 606–608
runtime generation of, 606
XLM schemas, 612–618, 691
SCM (Service Control Manager), 1273, 1274
scope of variables
clashes for fields and local variables, 37–38
clashes for local variables, 36–37
defined, 35
fields (member variables), 35
general rules, 35–36
local variables, 35–36
managed heap and, 197–198
reference variables, 197–198
stack and, 194–195, 197–198
using statement and, 202
scripting languages, interoperability with .NET, 7
scrolling windows in graphics applications
adding scroll bars, 858–859
converting coordinates relative to client area, 861–862
determining document size, 858–859
Form1 class for, 856–857
OnPaint() method override and, 859–860, 862
screen redraw and, 860–861
setting minimum document size at startup, 858–859
standard controls and, 857–858
SDI (Single Document Interface), 781
sealed modifier, 117–118, 125
searching in Active Directory
with DSML, 746–748
filters for, 736–737
PropertiesToLoad, 737
read-mostly access and, 736
SearchRoot, 736
SearchScope, 737
setting search limits, 737–740
UserSearch application, 740–745
security. See also authentication
ACLs, 1222–1226
Active Directory, 714–715
ASP.NET, 963–973
asserting permissions, 486–487
ClickOnce settings, 569–570
code access security, 464–478
configuration file, 489–492
declarative, 488, 509–510
demanding permissions, 478, 479–480
denying permissions, 485–486
Enterprise Services, 1068
file security, 1222–1226
implicit permission, 484–485
mobile code issues, 463
.NET Framework support for, 478–488
.NET Remoting, 1035, 1054–1055, 1126
performance issues, 478
policy management, 489–506
public key cryptography, 442–443
requesting permissions, 480–484
role-based, 506–510, 1068
role-based versus code-based, 14
strong data typing in IL and, 14
turning on and off, 493
Web services specifications and, 1128–1129
security policies. See also caspol.exe (Code Access Security Policy tool)
applying full trust, 492
changing permissions for code groups, 494–495
creating and applying permissions sets, 495–497
creating custom code groups, 493–494
deleting code groups, 494
distributing code using certificates, 499–504
distributing code using strong names, 497–499
files storing, 489
managing, 489–506
managing code groups and permissions, 492
managing zones, 504–506
resetting, 493
security configuration file, 489–492
viewing code groups at enterprise level, 477–478
viewing code groups at user level, 476–477
Security Wizard (ASP.NET), 964–969
SecurityException, 480, 482, 492
secutil.exe tool, 498–499, 502
SelfPlacingWindow application, 1232–1238
semicolon (;)
ending C# statements, 31
preprocessor directives not ended by, 71
Send() method (MessageQueue class), 1106, 1108
serializing. See also serializing objects in XML
base classes and interfaces for, 1187
defined, 1187
UDTs, 637–638
serializing objects in XML
custom attributes for, 702
namespace for, 701–702
.NET Remoting security and, 1035
serializing, defined, 701
simple application for, 702–708
without source code access, 708–711
xsd.exe tool for, 702
server controls (ASP.NET)
adding to PCSWebApp1 example, 911–913
control palette, 913–914
Crystal Reports Web server controls, 914
data Web server controls, 917–918
event handlers for, 911–912
example using, 920–925
further information, 910
HTML server controls, defined, 910
icon in system tray, 912
login Web server controls, 970–971
navigation Web server controls, 960–963
runat="server" attribute, 910
standard Web server controls, 914–917
validation Web server controls, 918–920
Web server controls, defined, 910
WebParts Web server controls, 920
Server Explorer (Visual Studio), 1295
Server Explorer window (Visual Studio 2005), 398
server platforms supported by .NET, 553
Service Control Manager (SCM), 1273, 1274
ServiceBase class, 1283–1284, 1302, 1305, 1314
ServiceController class
application using, 1295–1296
controlling services using, 1299–1301
methods, 1300
monitoring services using, 1296–1299
properties, 1297
ServicedComponent class, 1070
ServiceInstaller class, 1289, 1290–1291
ServiceInstallerDialog class, 1291
ServiceProcessInstaller class, 1289–1290
Services administration tool, 1272
set accessor of properties
access modifiers, 94
overview, 93
for user controls (ASP.NET), 948
SetDateAndNumber() method, 535–536
setreg.exe utility, 501
setup programs. See Windows Installer projects
SetValue() method (RegistryKey class), 1231
shapes. See also graphics
application for drawing, 844–847
drawing, 868–870
painting, 847–848
ScrollMoreShapes example, 869–870
System.Drawing.Graphics methods for, 868–869
shared assemblies
Authenticode signatures for, 442
creating, 444–449
defined, 19
delayed signing of, 448
global assembly cache for, 19, 413, 438–441
installing, 446, 451
integrity using strong names, 443
namespaces for classes and, 442
overview, 413, 419
public key cryptography, 442–443
references, 449
risks, 19
strong names for, 441–443, 444–445
using, 446–448
versioning, 412, 413, 451–460
SharePoint Web sites information, 920
short type, 41, 42
Show() method (Form class), 782, 845
ShowActivatedServiceTypes() method, 1044–1045
ShowChannelProperties() method, 1023
ShowDialog() method (Form class), 782–784
ShowRegionInformation() method, 524
ShowSamples() method, 523
ShowWellKnownServiceTypes() method, 1044–1045
signcode.exe utility, 499
signtool.exe wizard, 499–501
Simple Object Access Protocol. See SOAP
SimpleClientApp solution
adding the assembly, 560–561
application properties and values, 559–560
Configuration Properties setting, 557
creating a desktop shortcut, 561
creating folders for deployment, 561
deployment project as separate solution, 558–562
deployment project in same solution, 563–564
project properties, 561–562
SimpleComponent class, 1072–1073
SimpleDelegate delegate, 177–180
SimpleExceptions class, 333–336
SimpleServer application (Enterprise Services)
assembly attributes, 1071
creating C# library application for, 1070
creating the component, 1072–1073
ServicedComponent class, 1070, 1072
signing the assembly, 1070
SimpleComponent class, 1072–1073
SimpleWebApp solution, 564–565
Single Document Interface (SDI), 781
single quotes ('), char literals enclosed by, 44, 46
single-threaded apartment (STA) in COM, 1156–1157, 1166
SiteMapPath control, 960–962
Size struct, 852–853
SizeF struct, 852–853
sizeof operator, 138, 211
slash (/)
for multi-line comments (/* and */), 31, 67–68
for single-line comments (//), 31, 67
Sleep() method (Thread class), 355
sn (strong name tool), 442
soap namespace, 984–985
SOAP (Simple Object Access Protocol)
calling a method in a Web service, 984–985
declaring custom header for Web service, 1002
defined, 983
exchanging data using SOAP headers, 1001–1007
overview, 984–985
performance issues, 1133
RM sequence in messages, 1130–1131
sending data over HTTP and, 984–985
SoapHeaderAttribute attribute, 1002, 1003
SOAP-over-UDP, 1133–1134
Soapsuds utility, 1052–1053
WCF message contract for, 1137, 1139
WS-Addressing specification with, 1134
Soapsuds utility, 1052–1053
Socket class, 1263, 1268
Sort() method
Array class, 525
BubbleSorter class, 180–181
globalization and, 525
List<T> generic class, 281–282
SortedList class, 257–259
sorting. See also Sort() method
bubble-sorting algorithm, 180
DataView rows, 807–809
globalization and, 524–526
specific cultures, 515–516
SplitContainer control (Windows Forms), 775
SQL Server 2005
key generation with, 627–629
namespace for, 635
as .NET runtime host, 634–635
stored procedures, 645–647
triggers, 648–650
user-defined aggregates, 643–645
user-defined functions, 647–648
user-defined types (UDTs), 636–643
XML data type, 650–657
SqlContext class, 635
SqlPipe class, 635
SqlTriggerContext class, 635
square brackets ([ ]) for arrays, 57
STA (single-threaded apartment) in COM, 1156–1157, 1166
stack
classes stored on, 9
creating stack-based arrays, 219–222
defined, 194
managed heap and, 196–198
pointer allocation on, 207–208
scope of variables and, 194–195
stack pointer, 194–195
value types stored on, 9, 39, 194–195
Stack class
foreach loops for reading values, 254
LIFO (Last In First Out) structure of stacks, 253–254
methods, 255–256
namespace for, 254
Pop() method for pulling items permanently, 254–255
Push() method for adding items, 254
Queue class versus, 256
uses for, 253
stackalloc command, 219–220, 221
StackOverflowException class, 329
Start() method
QuoteServer class, 1277–1278
Thread class, 352
static classes, 106
static constructors
example, 97–98
execution of, 96–97
instance constructor in same class, 97
static keyword, 33, 125
Stop() method (QuoteServer class), 1278
stored procedures
calling in ADO.NET, 594–597
creating for SQL Server, 645–646
naming conventions, 630
for populating a DataSet, 619–620
triggers for SQL Server, 648–650
using with SQL Server, 646–647
StreamReader class
byte code markers, 1213
closing streams, 1215
constructors, 1214
described, 1207
encoding and, 1213, 1214–1215
FileStream class versus, 1213
hooking up to a FileStream, 1215
methods for reading or writing one line at a time, 1213
options, 1214
reading in arrays, 1215–1216
ReadLine() method, 1215
ReadToEnd() method, 1215
ReadWriteText application, 1217–1219
streams. See also specific classes
base class for, 1206
BinaryFileReader application, 1210–1213
BinaryReader class, 1207
BinaryWriter class, 1207
buffered streams, 1207
class hierarchy, 1206
defined, 1205
directions of data transfer, 1205
FileStream class, 1207, 1208–1210
outside source for, 1205–1206
overview, 1205–1207
ReadWriteText application, 1217–1219
StreamReader class, 1207, 1213, 1214–1216
StreamWriter class, 1207, 1213–1214, 1216–1217
StreamWriter class
byte code markers, 1213
constructors, 1216
described, 1207
encoding and, 1213–1214
FileStream class versus, 1213
hooking up to a FileStream, 1216
methods for reading or writing one line at a time, 1213
ReadWriteText application, 1217–1219
Write() method overloads, 1216–1217
writing data into a new file, 1216
String class
Format() method, 231
inefficiency for repeated modifications, 223, 225–226
methods, 224–225
Replace() method, 226
StringBuilder class versus, 223, 226
string keyword, 45
string tables. See resources
string type
char type and, 44
converting between numeric types and, 144–145
new string objects created by changes, 45–46
other reference types versus, 45–46
overview, 45–46
stored in the heap, 45
StringBuilder class
Append() method, 227
AppendFormat() method, 231
ArrayList class compared to, 250
memory allocation for, 226–227
methods, 228–229
Replace() method, 228
String class versus, 223, 226
ToString() method, 229
StringInfo class methods, 514–515
strings. See also text, graphical
concatenating using operator overloads, 224
extracting characters, 224
formatting expressions, 223, 229–235
Type class properties for retrieving, 314–315
strong data typing in IL
application domains and, 14–16
CLS and, 12–13
CTS and, 10–12
defined, 9
garbage collection and, 13–14
generics and, 269
importance for interoperability, 10–13
security and, 14
VB6 typing versus, 9–10
strong name tool (sn), 442
strong names
distributing code using, 497–499
integrity using, 443
for shared assemblies, 441–443, 444–445
strongly typed objects in Active Directory, 715, 719
strongly typed resources, 531–533
strongly typed XML, 656–657
structs
accessing fields outside the object, 37–38
ArraySegment<T> generic struct, 303–304
classes versus, 84, 102
for color representation, 863
constructors, 104
for coordinate representation, 850
declaring instances, 84, 101
default initialization of variables in, 34
defined, 84
defining functions for, 101–102
derived-struct syntax, 113
enumerations instantiated as, 57
inheritance and, 103, 112–113
initialization, 103
Nullable<T> generic struct, 301–302
partial, 104
performance and, 103
pointers to, 211–212
primitive types as .NET structs, 40–41
public fields in, 102
stored on the stack, 84
uses for, 101
as value types, 84, 102–103
style of names, 77
StyleSheetTheme (ASP.NET), 974–975
submitButton_Click() event handler, 924, 931–932, 934
SupportsWhatsNewAttribute class, 311–312
Suspend() method
QuoteServer class, 1278–1279
Thread class, 353, 354
suspending threads, 353–354
Swap<T> generic method, 297
switch...case statements
overview, 49–51
for user control event handler, 797–798
synchronization in threading
deadlocks, avoiding, 361–363, 364
defined, 360
importance of, 359
overusing, avoiding, 361
race conditions, avoiding, 363–364
syntax of C#, 360–361
System namespace, .NET types in, 32
System.ApplicationException class, 328
System.Array class, 245
System.AttributeUsage attribute, 307–309
System.Data namespace, 580, 581
System.Data.Common namespace, 580, 581
System.Diagnostics namespace, 1309
System.DirectoryServices namespace
accessing native ADSI objects, 735–736
ADSI COM object wrappers, 723
classes, 725
System.DirectoryServices.Protocols namespace
classes, 746
described, 724, 745
System.Drawing namespace
Color struct, 863
described, 843
Graphics methods, 868–869
Image class, 871
structs defined in, 850
System.GC.Collect() method, 199
System.Globalization namespace
CultureInfo class, 515
overview, 514, 523
RegionInfo class, 515
System.Net.Sockets namespace, 1263
System.Resources namespace, 533–534
System.Security.Permissions namespace, 479
System.ServiceProcess namespace, 1275
System.SystemException class, 328, 337
System.Type class
for holding reference types, 314
methods, 315–316
obtaining a Type reference, 314
properties, 314–315
TypeView example, 316–319
System.Xml namespace. See also specific classes
advantages over MSXML, 664
classes for handling XML, 661
classes for reading and writing XML, 660–661
language interoperability and, 659
MSXML 3.0 model and, 664
overview, 659
XmlDocument class, 661, 673–678
XmlNode class, 661, 672
XmlReader class, 660, 664–670
XmlTextReader class, 661, 664
XmlTextWriter class, 661, 664
XmlWriter class, 660, 664, 670–672
System.Xml.Serialization namespace, 701–702
System.Xml.XPath namespace
described, 678
key classes in, 679
using classes from, 681–684
XPathDocument class, 678
XPathNavigator class, 678, 679–680
XPathNodeIterator class, 678, 680–681
System.Xml.Xsl namespace
invoking methods during XML transforms, 686–689
overview, 684
transforming XML into HTML, 684–686
XsltArgumentList, 686–689