consuming windows service

icefireren 2004-03-23 03:03:16
由于我需要在普通用户下访问核心态的东西,所以我试图做一个windows service with localsystem 去操作,我试过我的windows services没问题,但现在我的目的是想通过一个外部exe再与我的windows services交互,能调用他的函数并得到返回值?我该如何做?

我的windows service是exe,不是驱动!

谢谢!
...全文
79 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
unalone 2004-04-03
  • 打赏
  • 举报
回复
管道比较好一些
icefireren 2004-03-29
  • 打赏
  • 举报
回复
:) 最笨的方法:socket
diaoni 2004-03-27
  • 打赏
  • 举报
回复
to cnxiaohai(相声独一处)

怎么调用640K内存?

油箱:wicked_y_crystal@yahoo.com.cn
diaoni 2004-03-27
  • 打赏
  • 举报
回复
关注!!
gzwl 2004-03-26
  • 打赏
  • 举报
回复
关注...
cnxiaohai 2004-03-26
  • 打赏
  • 举报
回复
呵呵

现在CSDN里很多人想做黑客啊

记得我在CSDN上问的第一个问题

就是怎么调用640K内存
huang124578 2004-03-23
  • 打赏
  • 举报
回复
用户应用程序不能直接访问内核(如:windows service),只能通过Win32API访问;或者自己编写一个驱动,由驱动访问内核,用户应用程序再与该驱动交互。
yjh1982 2004-03-23
  • 打赏
  • 举报
回复
gz
一本不错的C#书,希望对您有帮助,本书目录: C# 3.0 Unleashed 1 Table of Contents 6 Introduction 30 Why This Book Is for You 31 Organization and Goals 32 Part 1 Learning C# Basics 36 1 Introducing the .NET Platform 38 What Is .NET? 38 The Common Language Runtime (CLR) 40 The .NET Framework Class Library (FCL) 43 C# and Other .NET Languages 45 The Common Type System (CTS) 46 The Common Language Specification (CLS) 46 Summary 46 2 Getting Started with C# and Visual Studio 2008 48 Writing a Simple C# Program 48 Creating a Visual Studio 2008 (VS2008) Project 52 Commenting Code 61 Identifiers and Keywords 64 Convention and Style 66 Variables and Types 67 Definite Assignment 73 Interacting with Programs 74 Summary 77 3 Writing C# Expressions and Statements 78 C# Operators 78 Statements 91 Blocks and Scope 92 Labels 92 Operator Precedence and Associativity 93 Selection and Looping Statements 94 Summary 106 4 Understanding Reference Types and Value Types 108 A Quick Introduction to Reference Types and Value Types 108 The Unified Type System 109 Reference Type and Value Type Memory Allocation 114 Reference Type and Value Type Assignment 117 More Differences Between Reference Types and Value Types 121 C# and .NET Framework Types 123 Nullable Types 131 Summary 132 5 Manipulating Strings 134 The C# String Type 134 The StringBuilder Class 151 Regular Expressions 153 Summary 158 6 Arrays and Enums 160 Arrays 160 The System.Array Class 166 Using Enum Types 168 The System.Enum struct 171 Summary 174 7 Debugging Applications with Visual Studio 2008 176 Stepping Through Code 176 Summary 188 Part 2 Object-Oriented Programming with C# 190 8 Designing Objects 192 Object Members 192 Instance and Static Members 193 Fields 194 Methods 195 Properties 196 Indexers 198 Reviewing Where Partial Types Fit In 199 Static Classes 200 The System.Object Class 201 Summary 204 9 Designing Object-Oriented Programs 206 Inheritance 207 Encapsulating Object Internals 213 Polymorphism 219 Summary 229 10 Coding Methods and Custom Operators 230 Methods 231 Overloading Methods 239 Overloading Operators 242 Conversions and Conversion Operator Overloads 247 Partial Methods 256 Extension Methods 257 Summary 259 11 Error and Exception Handling 260 Why Exception Handling? 261 Exception Handler Syntax: The Basic try/catch Block 261 Ensuring Resource Cleanup with finally Blocks 263 Handling Exceptions 264 Designing Your Own Exceptions 272 checked and unchecked Statements 274 Summary 277 12 Event-Based Programming with Delegates and Events 278 Exposing Delegates 279 Implementing Delegate Inference 285 Assigning Anonymous Methods 285 Coding Events 287 Summary 300 13 Naming and Organizing Types with Namespaces 302 Why Namespaces? 303 Namespace Directives 304 Creating Namespaces 307 Namespace Members 310 Scope and Visibility 311 Namespace Alias Qualifiers 312 Extern Namespaces Alias 313 Summary 315 14 Implementing Abstract Classes and Interfaces 316 Abstract Classes 317 Abstract Class and Interface Differences 319 Implementing Interfaces 320 Defining Interface Types 320 Implicit Implementation 322 Explicit Implementation 333 Interface Mapping 339 Interface Inheritance 341 Summary 344 Part 3 Applying Advanced C# Language Features 346 15 Managing Object Lifetime 348 Object Initialization 349 Object Initializers 355 Object Finalization 356 Automatic Memory Management 357 Proper Resource Cleanup 360 Interacting with the Garbage Collector 364 Summary 366 16 Declaring Attributes and Examining Code with Reflection 368 Using Attributes 369 Using Attribute Parameters 371 Attribute Targets 373 Creating Your Own Attributes 374 Using Reflection 378 Reflecting on Attributes 385 Summary 392 17 Parameterizing Type with Generics and Writing Iterators 394 Nongeneric Collections 395 Understanding the Benefits of Generics 395 Building Generic Types 401 Implementing Iterators 417 Summary 425 18 Using Lambda Expressions and Expression Trees 426 Lambda Expressions 427 Expression Trees 433 Summary 435 Part 4 Learning LINQ and .NET Data Access 436 19 Accessing Data with LINQ 438 LINQ to Objects 439 Querying Relational Data with LINQ to SQL 443 Standard Query Operators 456 Summary 468 20 Managing Data with ADO.NET 470 ADO.NET Architecture 470 Making Connections 474 Viewing Data 476 Manipulating Data 479 Calling Stored Procedures 481 Working with Disconnected Data 482 LINQ to DataSet 487 Summary 488 21 Manipulating XML Data 490 Streaming XML Data 491 Writing XML 491 Reading XML 494 Working with the XML DOM 495 Easier Manipulation with LINQ to XML 497 Summary 502 22 Creating Data Abstractions with the ADO.NET Entity Framework 504 An Overview of Entities 505 Starting the Entity Data Model in VS2008 505 Querying Entities with Entity SQL 509 Creating Custom Entities 511 Coding with LINQ to Entities 515 Summary 518 23 Working with Data in the Cloud with ADO.NET Data Services 520 Adding ADO.NET Data Services to Your Project 521 Accessing ADO.NET Data Services via HTTP URIs 522 Writing Code with the ADO.NET Data Services Client Library 528 Summary 533 Part 5 Building Desktop User Interfaces 534 24 Taking Console Applications to the Limit 536 Introducing the PasswordGenerator Console Application 537 Interacting with the User 537 Handling Command-Line Input 539 Adding Color and Positioning to Consoles 540 Summary 543 25 Writing Windows Forms Applications 544 Windows Forms Fundamentals 545 VS2008 Support for Windows Forms 548 Using Windows Forms Controls 557 MenuStrip, StatusStrip, and ToolStrip Controls 560 Data Grids and Data Binding 562 GDI+ Essentials 565 Additional Windows and Dialogs 568 Summary 574 26 Creating Windows Presentation Foundation (WPF) Applications 576 Just Enough XAML 577 Managing Layout 580 WPF Controls 589 Event Handling 602 Data Binding 603 Using Styles 607 Summary 609 Part 6 Designing Web User Interfaces 610 27 Building Web Applications with ASP.NET 612 The Web Application Model 612 Starting an ASP.NET Project with VS2008 615 A Lap Around an ASP.NET Page 617 Controls 622 State Management 625 Navigation 632 Theming a Site 638 Securing a Website 641 Data Binding 643 Summary 646 28 Adding Interactivity to Your Web Apps with ASP.NET AJAX 648 What Is AJAX? 648 Setting Up an ASP.NET AJAX Site 649 The AJAX Page Life Cycle 650 Loading Custom Script Libraries 652 ASP.NET AJAX Controls 654 Accessing Controls via JavaScript 657 Calling Web Services with ASP.NET AJAX 664 Summary 669 29 Crafting Rich Web Applications with Silverlight 670 What Makes Silverlight Tick? 670 Starting a Silverlight Project in VS2008 671 Handling Silverlight Events with C# 677 Playing Media 681 Animating UI Elements 684 Summary 686 Part 7 Communicating with .NET Technologies 688 30 Using .NET Network Communications Technologies 690 Implementing Sockets 690 Working with HTTP 698 Performing FTP File Transfers 700 Sending SMTP Mail 704 Summary 705 31 Building Windows Service Applications 708 Creating Windows Service Projects in VS2008 709 Coding Windows Services 712 Installing a Windows Service 717 Building a Controller to Communicate with a Windows Service 720 Summary 722 32 Remoting 724 Basic Remoting 724 Channels 735 Lifetime Management 738 Summary 741 33 Writing Traditional ASMX Web Services 742 Web Service Basics 742 Using Web Services 748 Summary 752 34 Creating Web and Services with WCF 754 Creating a WCF Application in VS2008 755 Creating a Web Service Contract 756 Implementing Web Service Logic 761 Configuring a Web Service 763 Consuming a Web Service 766 Summary 768 Part 8 Examining .NET Application Architecture and Design 770 35 Using the Visual Studio 2008 Class Designer 772 Visualizing Code 772 Building an Object Model with the Class Designer 778 Summary 783 36 Sampling Design Patterns in C# 784 Overview of Design Patterns 784 The Iterator Pattern 785 Implementing the Proxy Pattern 797 Implementing the Template Pattern 801 Summary 807 37 Building N-Tier/Layer Systems 808 Potential Drag-and-Drop Problems 808 Introducing N-Layer/N-Tier 810 N-Layer Architecture Examples 813 Summary 824 38 Automating Logic with Windows Workflow 826 Starting a Workflow Project 826 Building a Sequential Workflow 827 Building a State Workflow 832 Summary 842 Part 9 Surveying More of the .NET Framework Class Library 844 39 Managing Processes and Threads 846 .NET Process Support 847 Multithreading Overview 852 Thread Synchronization 855 Summary 858 40 Localizing and Globalization 860 Resource Files 860 Multiple Locales 872 Summary 880 41 Performing Interop (P/Invoke and COM) and Writing Unsafe Code 882 Unsafe Code 883 Platform Invoke 893 Communicating with COM from .NET 895 Exposing a .NET Component as a COM Component 898 Introduction to .NET Support for COM+ Services 900 Summary 905 42 Instrumenting Applications with System.Diagnostics Types 908 Simple Debugging 909 Conditional Debugging 910 Runtime Tracing 913 Making Assertions 915 Accessing Built-In Performance Counters 917 Implementing Timers 925 Building a Customized Performance Counter 926 Analyzing Performance with Sampling 937 Summary 946 Part 10 Deploying Code 948 43 Assemblies and Versioning 950 Inside Assemblies 950 Assembly Features 954 Configuration 956 Deployment 959 Summary 959 44 Securing Code 962 Code-Based Security 962 Role-Based Security 971 Security Utilities 973 Summary 974 45 Creating Visual Studio 2008 Setup Projects 976 Running the VS2008 Setup Project Wizard 976 Additional Setup Configuration 979 Summary 983 46 Deploying Desktop Applications 984 Deploying via ClickOnce 984 Configuring ClickOnce 986 Summary 988 47 Publishing Web Applications 990 The Anatomy of a Web Application 990 Web Server Setup 991 Virtual Directory Setup 992 Web Server Deployment 994 Publishing a Web App from VS2008 994 Summary 995 Part 11 Appendixes 996 A: Compiling Programs 998 Advanced 998 Assemblies 1000 B: Getting Help with the .NET Framework 1002 Read This Book 1002 Index 1003 .NET Framework Class Library Documentation 1003 Search Engines 1004 Favorite Websites 1004 Summary 1004
是英文的,全面包含了c#的各方面。是非常好的一本书,绝对值得下载。 Introduction xxvii Part I: The C# Language 1 Chapter 1: .NET Architecture 3 The Relationship of C# to .NET 4 The Common Language Runtime 4 Advantages of Managed Code 4 A Closer Look at Intermediate Language 7 Support for Object Orientation and Interfaces 8 Distinct Value and Reference Types 9 Strong Data Typing 9 Error Handling with Exceptions 16 Use of Attributes 17 Assemblies 17 Private Assemblies 18 Shared Assemblies 19 Reflection 19 .NET Framework Classes 19 Namespaces 21 Creating .NET Applications Using C# 21 Creating ASP.NET Applications 21 Creating Windows Forms 24 Windows Services 24 The Role of C# in the .NET Enterprise Architecture 24 Summary 26 Chapter 2: C# Basics 29 Before We Start 30 Our First C# Program 30 The Code 30 Compiling and Running the Program 31 Contents A Closer Look 31 Variables 34 Initialization of Variables 34 Variable Scope 35 Constants 38 Predefined Data Types 39 Value Types and Reference Types 39 CTS Types 40 Predefined Value Types 41 Predefined Reference Types 44 Flow Control 47 Conditional Statements 47 Loops 51 Jump Statements 54 Enumerations 55 Arrays 57 Namespaces 58 The using Statement 59 Namespace Aliases 60 The Main() Method 61 Multiple Main() Methods 61 Passing Arguments to Main() 62 More on Compiling C# Files 63 Console I/O 65 Using Comments 67 Internal Comments Within the Source Files 67 XML Documentation 68 The C# Preprocessor Directives 70 #define and #undef 70 #if, #elif, #else, and #endif 71 #warning and #error 72 #region and #endregion 72 #line 72 C# Programming Guidelines 73 Rules for Identifiers 73 Usage Conventions 74 Summary 81 Chapter 3: Objects and Types 83 Classes and Structs 84 Class Members 85 Data Members 85 Function Members 85 xi Contents readonly Fields 99 Structs 101 Structs Are Value Types 102 Structs and Inheritance 103 Constructors for Structs 103 The Object Class 104 System.Object Methods 104 The ToString() Method 105 Summary 107 Chapter 4: Inheritance 109 Types of Inheritance 109 Implementation Versus Interface Inheritance 109 Multiple Inheritance 110 Structs and Classes 110 Implementation Inheritance 111 Virtual Methods 112 Hiding Methods 113 Calling Base Versions of Functions 114 Abstract Classes and Functions 115 Sealed Classes and Methods 115 Constructors of Derived Classes 116 Modifiers 122 Visibility Modifiers 122 Other Modifiers 123 Interfaces 123 Defining and Implementing Interfaces 125 Derived Interfaces 128 Summary 130 Chapter 5: Operators and Casts 131 Operators 131 Operator Shortcuts 133 The Ternary Operator 134 The checked and unchecked Operators 134 The is Operator 135 The as Operator 136 The sizeof Operator 136 The typeof Operator 136 Contents Operator Precedence 137 Type Safety 137 Type Conversions 138 Boxing and Unboxing 141 Comparing Objects for Equality 142 Comparing Reference Types for Equality 142 The ReferenceEquals() Method 142 The virtual Equals() Method 143 The static Equals() Method 143 Comparison Operator (==) 143 Comparing Value Types for Equality 143 Operator Overloading 144 How Operators Work 145 Operator Overloading Example: The Vector Struct 146 Which Operators Can You Overload? 153 User-Defined Casts 154 Implementing User-Defined Casts 155 Multiple Casting 161 Summary 165 Chapter 6: Delegates and Events 167 Delegates 167 Using Delegates in C# 169 SimpleDelegate Example 172 BubbleSorter Example 174 Multicast Delegates 177 Events 179 The Receiver’s View of Events 180 Generating Events 182 Summary 186 Chapter 7: Memory Management and Pointers 187 Memory Management under the Hood 187 Value Data Types 188 Reference Data Types 190 Garbage Collection 192 Freeing Unmanaged Resources 193 Destructors 193 The IDisposable Interface 195 xiii Contents Implementing IDisposable and a Destructor 196 Unsafe Code 197 Pointers 198 Pointer Example: PointerPlayaround 207 Using Pointers to Optimize Performance 212 Summary 216 Chapter 8: Strings and Regular Expressions 217 System.String 218 Building Strings 219 Format Strings 223 Regular Expressions 229 Introduction to Regular Expressions 229 The RegularExpressionsPlayaround Example 230 Displaying Results 233 Matches, Groups, and Captures 234 Summary 237 Chapter 9: Collections 239 Examining Groups of Objects 239 Array Lists 240 Collections 241 Dictionaries 245 Summary 256 Chapter 10: Reflection 257 Custom Attributes 258 Writing Custom Attributes 258 Custom Attribute Example: WhatsNewAttributes 262 Reflection 265 The System.Type Class 266 The TypeView Example 268 The Assembly Class 271 Completing the WhatsNewAttributes Sample 272 Summary 276 Contents Chapter 11: Errors and Exceptions 277 Looking into Errors and Exception Handling 277 Exception Classes 278 Catching Exceptions 280 User-Defined Exception Classes 290 Summary 297 Part II: The .NET Environment 299 Chapter 12: Visual Studio .NET 301 Working with Visual Studio .NET 2003 301 Creating a Project 304 Solutions and Projects 311 Windows Application Code 314 Reading in Visual Studio 6 Projects 314 Exploring and Coding a Project 315 Building a Project 326 Debugging 331 Other .NET Tools 334 The ASP.NET Web Matrix Project 335 WinCV 335 Summary 337 Chapter 13: Assemblies 339 What Are Assemblies? 339 The Answer to DLL Hell 340 Features of Assemblies 341 Application Domains and Assemblies 341 Assembly Structure 344 Assembly Manifests 346 Namespaces, Assemblies, and Components 346 Private and Shared Assemblies 347 Viewing Assemblies 347 Building Assemblies 348 Cross-Language Support 353 The CTS and the CLS 353 Language Independence in Action 354 CLS Requirements 364 xv Contents Global Assembly Cache 366 Native Image Generator 366 Global Assembly Cache Viewer 367 Global Assembly Cache Utility (gacutil.exe) 368 Creating Shared Assemblies 369 Shared Assembly Names 369 Creating a Shared Assembly 371 Configuration 376 Configuration Categories 376 Versioning 377 Configuring Directories 387 Summary 390 Chapter 14: .NET Security 391 Code Access Security 392 Code Groups 393 Code Access Permissions and Permissions Sets 399 Policy Levels: Machine, User, and Enterprise 403 Support for Security in the Framework 405 Demanding Permissions 406 Requesting Permissions 407 Implicit Permission 410 Denying Permissions 411 Asserting Permissions 412 Creating Code Access Permissions 414 Declarative Security 414 Role-Based Security 415 The Principal 415 Windows Principal 416 Roles 417 Declarative Role-Based Security 418 Managing Security Policy 419 The Security Configuration File 419 Managing Code Groups and Permissions 423 Turning Security On and Off 423 Resetting Security Policy 423 Creating a Code Group 423 Deleting a Code Group 424 Changing a Code Group’s Permissions 424 Creating and Applying Permissions Sets 425 Distributing Code Using a Strong Name 427 Contents Distributing Code Using Certificates 429 Managing Zones 435 Summary 437 Chapter 15: Threading 439 Threading 439 Applications with Multiple Threads 441 Manipulating Threads 441 The ThreadPlayaround Sample 444 Thread Priorities 448 Synchronization 449 Summary 453 Chapter 16: Distributed Applications with .NET Remoting 455 What Is .NET Remoting? 456 Application Types and Protocols 456 CLR Object Remoting 457 .NET Remoting Overview 457 Contexts 460 Activation 461 Attributes and Properties 461 Communication between Contexts 462 Remote Objects, Clients, and Servers 462 Remote Objects 462 A Simple Server 464 A Simple Client 465 .NET Remoting Architecture 466 Channels 466 Formatters 470 ChannelServices and RemotingConfiguration 471 Object Activation 472 Message Sinks 476 Passing Objects in Remote Methods 476 Lifetime Management 481 Miscellaneous .NET Remoting Features 484 Configuration Files 484 Hosting Applications 494 Classes, Interfaces, and SoapSuds 495 Asynchronous Remoting 498 Remoting and Events 499 Call Contexts 505 Summary 507 xvii Contents Chapter 17: Localization 509 Namespace System.Globalization 510 Unicode Issues 510 Cultures and Regions 511 Cultures in Action 516 Sorting 520 Resources 522 Creating Resource Files 522 ResGen 523 ResourceWriter 523 Using Resource Files 524 The System.Resources Namespace 527 Localization Example Using Visual Studio .NET 527 Outsourcing Translations 533 Changing the Culture Programmatically 534 Using Binary Resource Files 536 Using XML Resource Files 537 Automatic Fallback for Resources 539 Globalization and Localization with ASP.NET 539 A Custom Resource Reader 540 Creating a DatabaseResourceReader 541 Creating a DatabaseResourceSet 542 Creating a DatabaseResourceManager 543 Client Application for DatabaseResourceReader 544 Summary 544 Chapter 18: Deployment 545 Designing for Deployment 545 Deployment Options 546 Xcopy 546 Copy Project 546 Deployment Projects 546 Deployment Requirements 546 Simple Deployment 547 Xcopy 548 Xcopy and Web Applications 548 Copy Project 550 Installer Projects 551 What Is Windows Installer? 551 Creating Installers 552 Advanced Options 562 Summary 569 Contents Part III: Windows Forms 571 Chapter 19: Windows Forms 573 Creating a Windows Form Application 574 Control Class 579 Size and Location 580 Appearance 580 User Interaction 580 Windows Functionality 582 Miscellaneous Functionality 582 Class Hierarchy 582 Standard Controls and Components 584 Forms 598 Form Class 599 Multiple Document Interface (MDI) 607 Custom Controls 610 Summary 622 Chapter 20: Graphics with GDI+ 623 Understanding Drawing Principles 624 GDI and GDI+ 624 Drawing Shapes 626 Painting Shapes Using OnPaint() 629 Using the Clipping Region 630 Measuring Coordinates and Areas 632 Point and PointF 632 Size and SizeF 634 Rectangle and RectangleF 635 Region 636 A Note about Debugging 637 Drawing Scrollable Windows 638 World, Page, and Device Coordinates 644 Colors 645 Red-Green-Blue (RGB) Values 645 The Named Colors 646 Graphics Display Modes and the Safety Palette 646 The Safety Palette 647 Pens and Brushes 648 Brushes 648 Pens 649 xix Contents Drawing Shapes and Lines 650 Displaying Images 652 Issues When Manipulating Images 655 Drawing Text 655 Simple Text Example 656 Fonts and Font Families 657 Example: Enumerating Font Families 659 Editing a Text Document: The CapsEditor Sample 661 The Invalidate() Method 666 Calculating Item Sizes and Document Size 667 OnPaint() 668 Coordinate Transforms 670 Responding to User Input 671 Printing 675 Implementing Print and Print Preview 676 Summary 680 Part IV: Data 683 Chapter 21: Data Access with .NET 685 ADO.NET Overview 685 Namespaces 686 Shared Classes 686 Database-Specific Classes 687 Using Database Connections 688 Using Connections Efficiently 689 Transactions 692 Commands 693 Executing Commands 694 Calling Stored Procedures 698 Fast Data Access: The Data Reader 701 Managing Data and Relationships: The DataSet Class 704 Data Tables 704 Data Columns 705 Data Relationships 711 Data Constraints 713 XML Schemas 715 Generating Code with XSD 716 Populating a DataSet 721 Populating a DataSet Class with a Data Adapter 722 Populating a DataSet from XML 723 xx Contents Persisting DataSet Changes 723 Updating with Data Adapters 724 Writing XML Output 726 Working with ADO.NET 728 Tiered Development 728 Key Generation with SQL Server 730 Naming Conventions 732 Summary 734 Chapter 22: Viewing .NET Data 735 The DataGrid Control 735 Displaying Tabular Data 735 Data Sources 738 DataGrid Class Hierarchy 746 Data Binding 750 Simple Binding 750 Data-Binding Objects 751 Visual Studio.NET and Data Access 757 Creating a Connection 758 Selecting Data 759 Generating a DataSet 762 Updating the Data Source 763 Building a Schema 764 Other Common Requirements 770 Summary 778 Chapter 23: Manipulating XML 781 XML Standards Support in .NET 782 Introducing the System.Xml Namespace 782 Using MSXML in .NET 783 Using System.Xml Classes 786 Reading and Writing Streamed XML 786 Using the XmlTextReader Class 787 Using the XmlValidatingReader Class 791 Using the XmlTextWriter Class 794 Using the DOM in .NET 795 Using the XmlDocument Class 797 Using XPath and XSLT in .NET 802 The System.Xml.XPath Namespace 803 The System.Xml.Xsl Namespace 807 Contents XML and ADO.NET 812 Converting ADO.NET Data to XML 812 Converting XML to ADO.NET Data 820 Reading and Writing a DiffGram 822 Serializing Objects in XML 825 Serialization without Source Code Access 833 Summary 836 Chapter 24: Working with Active Directory 837 The Architecture of Active Directory 838 Features 838 Active Directory Concepts 839 Characteristics of Active Directory Data 843 Schema 843 Administration Tools for Active Directory 845 Active Directory Users and Computers 845 ADSI Edit 846 Active Directory Service Interfaces (ADSI) 847 Programming Active Directory 848 Classes in System.DirectoryServices 849 Binding 849 Getting Directory Entries 854 Object Collections 855 Cache 857 Creating New Objects 857 Updating Directory Entries 858 Accessing Native ADSI Objects 859 Searching in Active Directory 860 Searching for User Objects 864 User Interface 864 Get the Schema Naming Context 864 Get the Property Names of the User Class 866 Search for User Objects 867 Summary 869 Part V: Web Programming 871 Chapter 25: ASP.NET Pages 873 ASP.NET Introduction 874 State Management in ASP.NET 875 xxii Contents ASP.NET Web Forms 875 ASP.NET Server Controls 880 ADO.NET and Data Binding 892 Updating the Event-Booking Application 893 More on Data Binding 901 Application Configuration 906 Summary 907 Chapter 26: Web Services 909 SOAP 910 WSDL 911 Web Services 913 Exposing Web Services 913 Consuming Web Services 916 Extending the Event-Booking Example 918 The Event-Booking Web Service 919 The Event-Booking Client 922 Exchanging Data Using SOAP Headers 924 Summary 929 Chapter 27: User Controls and Custom Controls 931 User Controls 932 A Simple User Control 932 Custom Controls 939 Custom Control Project Configuration 940 Basic Custom Controls 944 Creating a Composite Custom Control 949 A Straw Poll Control 951 The Candidate Controls 953 The StrawPoll Control Builder 954 Straw Poll Style 955 The Straw Poll Control 956 Summary 962 Part VI: Interop 963 Chapter 28: COM Interoperability 965 .NET and COM 966 Metadata 966 Freeing Memory 966 xxiii Contents Interfaces 967 Method Binding 969 Data Types 969 Registration 969 Threading 969 Error Handling 971 Event Handling 972 Marshaling 972 Using a COM Component from a .NET Client 973 Creating a COM Component 973 Creating a Runtime Callable Wrapper 977 Threading Issues 980 Adding Connection Points 980 Using ActiveX Controls in Windows Forms 982 Using COM Objects from within ASP.NET 985 Using a .NET Component from a COM Client 985 COM Callable Wrapper 986 Creating a .NET Component 986 Creating a Type Library 987 COM Interop Attributes 989 COM Registration 992 Creating a COM Client 993 Adding Connection Points 995 Creating a Client with a Sink Object 996 Running Windows Forms Controls in Internet Explorer 997 Summary 998 Chapter 29: Enterprise Services 999 Overview 999 History 999 Where to Use Enterprise Services? 1000 Contexts 1001 Automatic Transactions 1001 Distributed Transactions 1001 Object Pooling 1002 Role-based Security 1002 Queued Components 1002 Loosely Coupled Events 1002 Creating a Simple COM+ Application 1003 Class ServicedComponent 1003 Application Attributes 1003 Creating the Component 1004 Contents Deployment 1005 Automatic Deployment 1005 Manual Deployment 1005 Component Services Admin Tool 1006 Client Application 1008 Transactions 1009 ACID Properties 1009 Transaction Attributes 1009 Transaction Results 1010 Sample Application 1011 Summary 1021 Part VII: Windows Base Services 1023 Chapter 30: File and Registry Operations 1025 Managing the File System 1026 .NET Classes That Represent Files and Folders 1027 The Path Class 1029 Example: A File Browser 1030 Moving, Copying, and Deleting Files 1035 Example: FilePropertiesAndMovement 1035 Reading and Writing to Files 1039 Streams 1040 Reading and Writing to Binary Files 1042 Reading and Writing to Text Files 1047 Reading and Writing to the Registry 1054 The Registry 1055 The .NET Registry Classes 1057 Example: SelfPlacingWindow 1059 Summary 1066 Chapter 31: Accessing the Internet 1067 The WebClient Class 1068 Downloading Files 1068 Basic Web Client Example 1068 Uploading Files 1070 WebRequest and WebResponse Classes 1070 Other WebRequest and WebResponse Features 1071 Displaying Output as an HTML Page 1074 The Web Request and Web Response Hierarchy 1075 xxv Contents Utility Classes 1077 URIs 1077 IP Addresses and DNS Names 1079 Lower-Level Protocols 1082 Lower-Level Classes 1083 Summary 1088 Chapter 32: Windows Services 1091 What Is a Windows Service? 1091 Windows Services Architecture 1093 Service Program 1093 Service Control Program 1095 Service Configuration Program 1095 System.ServiceProcess Namespace 1095 Creating a Windows Service 1096 A Class Library Using Sockets 1096 TcpClient Example 1100 Windows Service Project 1102 Threading and Services 1107 Service Installation 1107 Installation Program 1108 Monitoring and Controlling the Service 1113 MMC Computer Management 1114 net.exe 1114 sc.exe 1115 Visual Studio .NET Server Explorer 1116 ServiceController Class 1116 Troubleshooting 1122 Interactive Services 1123 Event Logging 1123 Performance Monitoring 1130 Power Events 1135 Summary 1135 At www.wrox.com Appendix A: Principles of Object-Oriented Programming 1137 Appendix B: C# for Visual Basic 6 Developers 1177 Appendix C: C# for Java Developers 1225 Appendix D: C# for C++ Developers 1253 Index 1307
Part I Getting Started 1 Introducing Microsoft SharePoint 2010 . 3 What Is SharePoint? 3 Main Capabilities 4 Sites . 5 Communities 5 Content . 5 Search . 6 Insights 6 Composites 6 SharePoint Basic Concepts 7 SharePoint Central Administration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Site Collections and Websites . 8 Lists, Libraries, Items, and Documents 10 Web Parts and Web Part Pages 12 Architectural Overview . 12 Logical and Physical Architecture 14 Service Applications . 16 The Role of Databases 17 SharePoint Editions . 18 SharePoint Foundation 18 SharePoint Server Standard 19 SharePoint Server Enterprise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 SharePoint for Internet Sites . 20 SharePoint Online . 20 SharePoint for Developers . 20 ASP.NET Integration . 21 Server-Side Technologies 21 Client-Side Technologies 22 Download at Pin5i.Com viii Table of Contents Web Parts and UI 22 Data Provisioning 22 Event Receivers and Workflows 23 Security Infrastructure 23 Business Connectivity Services . 23 Windows PowerShell Support 24 Developer Tools . 24 Microsoft SharePoint Designer 2010 . 24 Microsoft Visual Studio 2010 26 SharePoint Server Explorer 28 Solution Explorer and Feature Designer . 29 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 2 Data Foundation 31 Lists of Items and Contents . 31 Site Columns 46 Content Types 47 Websites 50 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Part II Programming Microsoft SharePoint 2010 3 Server Object Model . 55 Startup Environment 56 Objects Hierarchy 56 SPFarm, SPServer, SPService, and SPWebApplication . . . . . . . . . . . . . . . . 57 SPSite and SPWeb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 SPList and SPListItem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 SPDocumentLibrary and SPFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 SPGroup, SPUser, and Other Security Types . 69 SPControl and SPContext . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 Common and Best Practices 72 Disposing Resources . 73 Handling Exceptions . 76 Transactions . 78 AllowUnsafeUpdates and FormDigest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 Download at Pin5i.Com Table of Contents ix Real-Life Examples 80 Creating a New Site Collection . 80 Creating a New Website 82 Lists and Items . 83 Document Libraries and Files 92 Groups and Users 97 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4 LINQ to SharePoint 101 LINQ Overview 101 The Goal of LINQ 102 LINQ Under the Covers 104 Introducing LINQ to SharePoint . 106 Modeling with SPMetal.EXE 107 Querying Data . 117 Managing Data 122 Inserting a New Item 124 Deleting or Recycling an Existing Item . 125 Advanced Topics 126 Handling Concurrency Conflicts 126 Identity Management and Refresh 130 Disconnected Entities . 132 Model Extensions and Versioning 134 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136 5 Client-Side Technologies . 137 Architectural Overview . 137 SharePoint Client Object Model . 138 Managed Client Object Model . 139 Silverlight Client Object Model 147 ECMAScript Client Object Model . 152 Client Object Model by Examples 158 Lists and Items . 159 Document Libraries and Files 165 SOAP Services 168 The REST API 171 Querying for Data with .NET and LINQ 173 Managing Data 177 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Download at Pin5i.Com x Table of Contents Part III Developing Web Parts 6 Web Part Basics 183 Web Part Architecture 183 A “Hello World” Web Part 184 Web Part Deployment 188 Real Web Parts . 192 Classic Web Parts 192 Visual Web Parts . 195 Configurable Web Parts . 197 Configurable Parameters . 198 Editor Parts . 200 Handling Display Modes 204 Custom Web Part Verbs . 205 The SharePoint-Specific WebPart class 207 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 7 Advanced Web Parts . 209 Connectable Web Parts 209 Supporting AJAX 215 Connectable Web Parts with AJAX 217 Silverlight and External Applications . 220 Asynchronous Programming 223 XSLT Rendering 226 Deployment, Security, and Versioning 233 Deployment and Versioning . 233 SafeControls and Cross-Site-Scripting SafeGuard . 236 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 238 Part IV Extending Microsoft SharePoint 2010 8 SharePoint Features and Solutions 241 Features and Solutions . 241 Feature Element Types . 246 Features and Solutions Deployment 248 Packaging with Visual Studio 2010 254 Upgrading Solutions and Features . 256 Feature Receivers 259 Handling FeatureUpgrading Events . 262 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264 Download at Pin5i.Com Table of Contents xi 9 Extending the User Interface . 265 Custom Actions 265 The CustomAction Element . 265 The CustomActionGroup Element 273 The HideCustomAction Element . 275 Server-Side Custom Actions 276 Ribbons . 279 Ribbon Command . 279 Delegate Controls . 291 Custom Contents . 295 Images and Generic Content 295 Application Pages . 297 Content Pages, Web Part Pages, and Galleries 299 Status Bar and Notification Area 305 Dialog Framework . 309 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 10 Data Provisioning . 315 Site Columns 315 Content Types 320 Content Type IDs . 323 More about Content Types . 326 Document Content Types 328 List Definitions . 329 List Schema File . 329 Defining a Custom View 339 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 11 Developing Custom Fields 345 Fields Type Basics 345 The SPField Class . 347 Developing Custom Field Types . 349 A Basic E-Mail Field Type . 349 A Multicolumn Field Type 354 Field Rendering Control . 358 Field Rendering Templates 361 Field Rendering Using CAML 365 Field Rendering Using XSLT 367 Download at Pin5i.Com xii Table of Contents Supporting Mobile Devices . 369 Field Rendering Mobile Templates 374 Custom Field Editor 376 Custom Properties Persistence . 381 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 384 12 Event Receivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385 Types of Receivers . 385 Item-Level Event Receivers 386 List-Level Event Receivers 391 Web-Level Event Receivers 393 Workflow Event Receivers 394 E-Mail Event Receivers 395 Avoiding Event Loops . 396 Event Deployment and Binding 397 Event Synchronization 398 Event Security 400 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400 13 Document Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 401 Document Sets 401 Provisioning Document Sets . 403 Handling Document Sets by Code . 410 Document ID 411 Custom Document ID Provider 414 File Conversion Services . 417 Word Automation Services . 417 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422 14 Site Templates 423 Native Site Definitions 424 Site Definitions . 428 Site Definitions with Visual Studio 431 Custom Web Templates . 439 Site Definitions versus Web Templates 444 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .444 Download at Pin5i.Com Table of Contents xiii 15 Developing Service Applications . 445 Service Application Architecture 445 Service Application Framework 449 Creating a Service Application 449 Custom Protocol Service Application 450 Solution Outline 453 Service Application . 454 Service Application Database . 456 Service 458 Service Instance 465 Administrative Pages 466 Service Application Deployment 467 Service Application Proxy 469 Service Application Consumer 473 Service Application Proxy Deployment 473 Final Thoughts . 474 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 Part V Developing Workflows 16 SharePoint Workflows Architecture 479 Workflow Foundation Overview . 479 Workflow Foundation Architecture . 479 Workflow Types . 483 Workflows Definition 484 Custom Activities 486 Workflow Execution Model . 489 Workflows in SharePoint 489 Workflow Targets and Association 491 SharePoint 2010 Custom Activities 492 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 494 17 Workflows with SharePoint Designer 2010 495 SharePoint Designer 2010 Workflows 495 Workflow Designer . 496 Conditions and Actions 498 Structure of a Published Workflow 502 Download at Pin5i.Com xiv Table of Contents Designing a Workflow 502 Workflow Outline Definition . 503 Workflow Settings 507 Workflow User Experience 508 Visio 2010 Integration 510 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513 18 Workflows with Visual Studio 2010 . 515 Workflow Modeling 515 Creating the Workflow Project . 515 Workflow Outline 519 Correlation Tokens 533 Site Workflows . 534 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 534 19 Workflow Forms . 535 Management Forms 535 Association Form 537 Initiation Form . 544 Modification Form 547 Task Forms 547 Workflow Tasks 547 Forms Deployment . 553 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554 20 Advanced Workflows 555 Custom Actions and Conditions . 555 Dependency Properties . 555 Custom Actions for SharePoint Designer 2010 557 Custom Conditions for SharePoint Designer 2010 563 Workflow Event Receivers 565 Workflow Services . 566 Implementing the Service . 568 Workflow Service Deployment . 573 Communication Activities 575 Workflow Management by Code . 576 Workflow Server Object Model 576 Workflow Web Service . 579 Download at Pin5i.Com Table of Contents xv SPTimer Service and Workflows . 585 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 586 Part VI Security Infrastructure 21 Authentication and Authorization Infrastructure 589 Authentication Infrastructure 589 Classic Mode Authentication 590 Claims-Authentication Types . 592 Configuring FBA with SQL Membership Provider . 597 Configuring the SQL Server Database . 597 Authorization Infrastructure 603 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 606 22 Claims-Based Authentication and Federated Identities . 607 Claims-Based Authentication and WS-Federation 607 Implementing an STS with Windows Identity Foundation 611 Building a Security Token Service 611 Building a Relying Party 617 SharePoint Trusted Identity Providers . 621 Trusting the IP/STS 622 Configuring the Target Web Application 625 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627 23 Code Access Security and Sandboxed Solutions . 629 Code Access Security 629 Partially Trusted ASP.NET Code 631 Sandboxed Solutions Overview 639 Sandboxed Solutions Architecture . 640 Creating a Sandboxed Solution 645 Implementing a Solution Validator 647 Full-Trust Proxies . 650 Implementing a Full-Trust Proxy 651 Registering the Full-Trust Proxy 652 Consuming the Full-Trust Proxy . 654 Sandboxed Solutions and Office 365 655 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656 Download at Pin5i.Com xvi Table of Contents Part VII Enterprise Features 24 Programming the Search Engine . 659 Search Engine Overview for Developers . 659 Customizing and Extending the User Interface . 662 Customizing the Output via XSLT 664 Developing Custom Web Parts 668 Federation Framework . 670 Implementing a Custom Federation Provider 674 Using the Search Engine by Code 678 Federated Search Object Model 678 Query Object Model 681 Query Web Service . 684 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 687 25 Business Connectivity Services 689 Overview of Business Connectivity Services . 689 Accessing a Database . 691 BDC Model File 700 Offline Capabilities 703 Accessing a WCF/SOAP Service 705 .NET Custom Model 710 Developing a Custom Model from Scratch 712 Associating Entities . 719 Programming with BCS Object Model 721 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 723 Index . 725
Contents xvii Web Forms 133 Intellisense 134 Customizing the IDE 135 Customizing the Code Editor 135 Customizing Shortcut Keys 135 Customizing the Toolbars 136 Exercise 3.4 Adding a New Toolbar to the Existing Set 136 Exercise 3.5 Adding Commands to Toolbars 137 Customizing Built-In Commands 137 Exercise 3.6 Creating an Alias 138 Customizing the Start Page 139 Accessibility Options 141 Summary 142 Solutions Fast Track 142 Frequently Asked Questions 143 Chapter 4 Common Language Runtime 145 Introduction 146 Component Architecture 148 Managed Code versus Unmanaged Code 150 Interoperability with Managed Code 152 System Namespace 153 File I/O 155 Drawing 156 Printing 157 Common Type System 158 Type Casting 160 Garbage Collection 163 Object Allocation/Deallocation 164 Close/Dispose 165 Summary 166 Solutions Fast Track 167 Frequently Asked Questions 168 Developing & Deploying… Embrace Your Parameters VB.NET is insistent upon enclosing parameters of function calls within parentheses regardless of whether we are returning a value or whether we are using the Call statement. It makes the code much more readable and is a new standard for VB programmers that is consistent with the standard that nearly all other languages adopted long ago. 153_VBnet_TOC 8/16/01 1:12 PM Page xvii xviii Contents Chapter 5 .NET Programming Fundamentals 171 Introduction 172 Variables 173 Constants 175 Structures 176 Program Flow Control 178 If…Then…Else 178 Select Case 182 While Loops 184 For Loops 186 Arrays 187 Declaring an Array 188 Multidimensional Arrays 189 Dynamic Arrays 191 Functions 192 Object Oriented Programming 196 Inheritance 196 Polymorphism 197 Encapsulation 197 Classes 198 Adding Properties 198 Adding Methods 200 System.Object 201 Constructors 201 Overloading 202 Overriding 203 Shared Members 205 String Handling 206 Error Handling 210 Summary 213 Solutions Fast Track 214 Frequently Asked Questions 217 NOTE When porting Visual Basic applications to Visual Basic .NET, be careful of the lower bounds of arrays. If you are using a for loop to iterate through the array, and it is hard-coded to initialize the counter at 1, the first element will be skipped. Remember that all arrays start with the index of 0. 153_VBnet_TOC 8/16/01 1:12 PM Page xviii Contents xix Chapter 6 Advanced Programming Concepts 219 Introduction 220 Using Modules 221 Utilizing Namespaces 222 Creating Namespaces 222 Understanding the Imports Keyword 226 Implementing Interfaces 229 Delegates and Events 232 Simple Delegates 235 Multicast Delegates 236 Event Programming 236 Handles Keyword 236 Language Interoperability 237 File Operations 239 Directory Listing 239 Data Files 241 Text Files 243 Appending to Files 246 Collections 246 The Drawing Namespace 248 Images 253 Printing 256 Understanding Free Threading 262 SyncLock 263 Summary 265 Solutions Fast Track 265 Frequently Asked Questions 267 Chapter 7 Creating Windows Forms 269 Introduction 270 Application Model 270 Properties 271 Manipulating Windows Forms 275 Properties of Windows Forms 275 Methods of Windows Forms 276 Creating Windows Forms 287 What Are Collections? Collectionsare groups of like objects. Collections are similar to arrays, but they don’t have to be redimensioned. You can use the Addmethod to add objects to a collection. Collections take a little more code to create than arrays do, and sometimes accessing a collection can be a bit slower than an array, but they offer significant advantages because a collection is a group of objects whereby an array is a data type. 153_VBnet_TOC 8/16/01 1:12 PM Page xix xx Contents Displaying Modal Forms 288 Displaying Modeless Forms 289 Displaying Top-Most Forms 289 Changing the Borders of a Form 289 Resizing Forms 291 Setting Location of Forms 292 Form Events 294 Creating Multiple Document Interface Applications 297 Creating an MDI Parent Form 297 Creating MDI Child Forms 298 Exercise 7.1 Creating an MDI Child Form 298 Determining the Active MDI Child Form 299 Arranging MDI Child Forms 299 Adding Controls to Forms 300 Anchoring Controls on Forms 301 Docking Controls on Forms 303 Layering Objects on Forms 304 Positioning Controls on Forms 304 Dialog Boxes 305 Displaying Message Boxes 306 Common Dialog Boxes 306 The OpenFileDialog Control 306 The SaveFileDialog Control 309 The FontDialog Control 311 The ColorDialog Control 313 The PrintDialog Control 315 The PrintPreviewDialog Control 316 The PageSetupDialog Control 321 Creating Dialog Boxes 322 Creating and Working with Menus 323 Adding Menus to a Form 323 Exercise 7.2 Adding a Menu to a Form at Design Time 323 Creating Dialog Boxes 1.Create a form. 2.Set the BorderStyle property of the form to FixedDialog. 3.Set the ControlBox, MinimizeBox, and MaximizeBox properties of the form to False. 4.Customize the appearance of the form appropriately. 5.Customize event handlers in the Code window appropriately. 153_VBnet_TOC 8/16/01 1:12 PM Page xx Contents xxi Dynamically Creating Menus 326 Exercise 7.3 Adding a Menu to a Form at Design Time 326 Adding Status Bars to Forms 328 Adding Toolbars to Forms 330 Data Binding 332 Simple Data Binding 332 Complex Data Binding 333 Data Sources for Data Binding 333 Using the Data Form Wizard 334 Using the Windows Forms Class Viewer 338 Using the Windows Forms ActiveX Control Importer 338 Summary 340 Solutions Fast Track 340 Frequently Asked Questions 344 Chapter 8 Windows Forms Components and Controls 347 Introduction 348 Built-In Controls 348 Label Control 351 LinkLabel Control 354 TextBox Control 357 Button Control 361 CheckBox Control 364 RadioButton Control 365 RichTextBox Control 367 TreeView Control 369 ListBox Control 371 CheckedListBox Control 374 ListView Control 376 ComboBox Control 381 DomainUpDown Control 384 NumericUpDown Control 386 PictureBox Control 388 TrackBar Control 389 Adding Items to a Combo Box at Design-Time 1.Select the ComboBox control on the form. 2.If necessary, use the Viewmenu to open the Properties window. 3.In the Properties window, click the Itemsproperty, then click the ellipsis. 4.In String Collection Editor, type the first item, then press Enter. 5.Type the next items, pressing Enterafter each item. 6.Click OK. 153_VBnet_TOC 8/16/01 1:13 PM Page xxi xxii Contents DateTimePicker Control 391 Panel Control 394 GroupBox Control 396 TabControl Control 397 Creating Custom Windows Components 399 Exercise 8.1:Creating a Custom Windows Component 399 Creating Custom Windows Controls 403 Exercise 8.2:Creating a Custom Windows Control 404 Summary 407 Solutions Fast Track 407 Frequently Asked Questions 408 Chapter 9 Using ADO.NET 409 Introduction 410 Overview of XML 411 XML Documents 411 XSL 411 XDR 412 XPath 412 Understanding ADO.NET Architecture 412 Differences between ADO and ADO.NET 414 XML Support 414 ADO.NET Configuration 415 Remoting in ADO.NET 415 Maintaining State 415 Using the XML Schema Definition Tool 416 Connected Layer 417 DataProviders 418 Connection Strings 418 Exercise 9.1 Creating a Connection String 419 Command Objects 421 DataReader 425 DataSet 426 XML Documents XML documents are the heart of the XML standard. An XML document has at least one element that is delimited with one start tag and one end tag. XML documents are similar to HTML, except that the tags are made up by the author. 153_VBnet_TOC 8/16/01 1:13 PM Page xxii Contents xxiii Disconnected Layer 427 Using DataSet 428 Relational Schema 428 Collection of Tables 430 Data States 431 Populating with the DataSet Command 432 Populating with XML 433 Populating Programmatically 434 Using the SQL Server Data Provider 435 TDS 436 Exercise 9.2 Using TypedDataSet 437 Remoting 439 Data Controls 440 DataGrid 440 Exercise 9.3 Using TypedDataSet and DataRelation 441 DataList 446 Repeater 450 Summary 454 Solutions Fast Track 454 Frequently Asked Questions 457 Chapter 10 Developing Web Applications 459 Introduction 460 Web Forms 461 A Simple Web Form 462 Exercise 10.1 Creating a Simple Web Form 462 How Web Forms Differ from Windows Forms 464 Why Web Forms Are Better Than Classic ASP 465 Adding Controls to Web Forms 467 Exercise 10.2 Adding Web Controls to a Web Form 468 Code Behind 473 NOTE Web form controls not only detect browsers such as Internet Explorer and Netscape, but they also detect devices such as Palm Pilots and cell phones and generate appropriate HTML accordingly. 153_VBnet_TOC 8/16/01 1:13 PM Page xxiii xxiv Contents How Web Form Controls Differ from Windows Form Controls 476 ASP.NET Server Controls 476 Intrinsic Controls 476 Bound Controls 478 Exercise 10.3 Using the DataGrid Control 478 Exercise 10.4 Customizing DataGrid Control 482 Custom Controls 487 Validation Controls 488 Exercise 10.5 Using the Validation Controls 489 Creating Custom Web Form Controls 492 Exercise 10.6 A Simple Custom Control 493 Exercise 10.7 Creating a Composite Custom Control 497 Web Services 504 How Web Services Work 505 Developing Web Services 505 Exercise 10.8 Developing Web Services 507 Web Service Utilities 509 Service Description Language 509 Discovery 510 Proxy Class 510 Consuming Web Services from Web Forms 511 Exercise 10.9 Consuming Web Services from Web Forms 511 Using Windows Forms in Distributed Applications 513 Exercise 10.10 Consuming Web Services from Windows Forms 514 Exercise 10.11 Developing a Sample Application 516 Summary 519 Solutions Fast Track 519 Frequently Asked Questions 521 153_VBnet_TOC 8/16/01 1:13 PM Page xxiv Contents xxv Chapter 11 Optimizing, Debugging, and Testing 523 Introduction 524 Debugging Concepts 524 Debug Menu 528 Watches 529 Breakpoints 531 Exceptions Window 532 Command Window 534 Conditional Compilation 536 Trace 538 Assertions 540 Code Optimization 541 Finalization 542 Transitions 542 Parameter Passing Methods 542 Strings 543 Garbage Collection 544 Compiler Options 544 Optimization Options 544 Output File Options 544 .NET Assembly Options 545 Preprocessor Options 546 Miscellaneous Options 546 Testing Phases and Strategies 546 Unit Testing 547 Integration Testing 547 Beta Testing 547 Regression Testing 548 Stress Testing 548 Monitoring Performance 548 Summary 550 Solutions Fast Track 551 Frequently Asked Questions 552 What Are Watches? Watchesprovide us with a mechanism where we can interact with the actual data that is stored in our programs at runtime. They allow us to see the values of variables and the values of properties on objects. In addition to being able to view these values, you can also assign new values. 153_VBnet_TOC 8/16/01 1:13 PM Page xxv xxvi Contents Chapter 12 Security 553 Introduction 554 Security Concepts 555 Permissions 555 Principal 556 Authentication 557 Authorization 557 Security Policy 558 Type Safety 558 Code Access Security 558 .NET Code Access Security Model 559 Stack Walking 559 Code Identity 561 Code Groups 562 Declarative and Imperative Security 564 Requesting Permissions 565 Demanding Permissions 570 Overriding Security Checks 572 Custom Permissions 576 Role-Based Security 578 Principals 578 WindowsPrincipal 579 GenericPrincipal 580 Manipulating Identity 581 Role-Based Security Checks 583 Security Policies 585 Creating a New Permission Set 588 Modifying the Code Group Structure 593 Remoting Security 600 Cryptography 600 Security Tools 603 Summary 606 Solutions Fast Track 607 Frequently Asked Questions 611 Within the .NET Framework, Three Namespaces Involve Cryptography 1.System.Security .CryptographyThe most important one; resembles the CryptoAPI functionalities. 2.System.Security .Cryptography.X509 certificatesRelates only to the X509 v3 certificate used with Authenticode. 3.System.Security .Cryptography.XmlFor exclusive use within the .NET Framework security system. 153_VBnet_TOC 8/16/01 1:13 PM Page xxvi Contents xxvii Chapter 13 Application Deployment 615 Introduction 616 Packaging Code 617 Configuring the .NET Framework 622 Creating Configuration Files 622 Machine/Administrator Configuration Files 623 Application Configuration Files 625 Security Configuration Files 626 Deploying the Application 629 Common Language Runtime 629 Windows Installer 630 CAB Files 631 Internet Explorer 5.5 632 Resource Files 633 Deploying Controls 637 Summary 639 Solutions Fast Track 640 Frequently Asked Questions 642 Chapter 14 Upgrading Visual Basic Applications to .NET 647 Introduction 648 Considerations Before Upgrading 648 Early Binding of Variables 649 Avoiding Null Propagation 650 Using ADO 651 Using Date Data Type 652 Using Constants 652 Considering Architecture Before Migration 653 Intranet/Internet Applications 653 Internet Information Server (IIS) Applications 654 DHTML Applications 655 ActiveX Documents 655 Client/Server and Multi-Tier Applications 655 Single-Tier Applications 656 Data Access Applications 656 WARNING You should under no circumstance edit the Security.config and Enterprise.config files directly. It is very easy to compromise the integrity of these files. Always use the Code Access Security Policy utility (caspol.exe) or the .NET Configuration tool; these will guard the integrity of the files and will also make a backup copy of the last saved version. 153_VBnet_TOC 8/16/01 1:13 PM Page xxvii xxviii Contents Data Types 657 Variants 657 Integers 658 Dates 658 Boolean 659 Arrays 659 Fixed-Length Strings 660 Windows API Data Types 661 Converting VB Forms to Windows Forms 662 Control Anchoring 664 Keyword Changes 665 Goto 666 GoSub 666 Option Base 666 AND/OR 666 Lset 666 VarPtr 667 StrPtr 667 Def 667 Programming Differences 668 Method Implementation 668 Optional Parameters 668 Static Modifier 669 Return Statement 669 Procedure Calls 670 External Procedure Declaration 671 Passing Parameters 672 ParamArray 672 Overloading 674 References to Unmanaged Libraries 677 Metadata 679 Runtime Callable Wrapper 681 COM Callable Wrapper 682 Properties 684 Working with Property Procedures 684 Control Property Name Changes 685 Default Property 687 Avoiding Null Propagation Nullpropagation means that if Null is used in an expression, the resulting expression is always Null. In previous versions of Visual Basic, the Null value disseminated throughout the expression. 153_VBnet_TOC 8/16/01 1:13 PM Page xxviii Contents xxix Null Usage 690 Understanding Error Handling 690 Exercise 14.1:Using Error Handling 692 Data Access Changes in Visual Basic .NET 693 Dataset and Recordset 694 Application Interoperability 694 Cursor Location 695 Disconnected Access 695 Data Navigation 695 Lock Implementation 696 Upgrading Interfaces 696 Upgrading Interfaces from Visual Basic 6.0 699 Using the Upgrade Tool 703 Exercise 14.2 Using the Upgrade Wizard 703 Summary 708 Solutions Fast Track 709 Frequently Asked Questions 712 Index 713 Contents xiii From the Series Editor xxxi Chapter 1 New Features in Visual Basic .NET 1 Introduction 2 Examining the New IDE 3 Cosmetic Improvements 3 Development Accelerators 5 .NET Framework 6 A Very Brief and Simplified History 6 .NET Architecture 7 ASP.NET 7 Framework Classes 8 .NET Servers 8 Common Language Runtime 8 History 8 Convergence 9 Object-Oriented Language 10 Object-Oriented Concepts 10 Advantages of Object-Oriented Design 11 History of Object Orientation and VB 13 Namespaces 13 Web Applications 13 Web Applications Overview 13 Web Forms 14 Web Services 15 HyperText Transport Protocol 16 Simple Object Access Protocol 17 .NET Architecture .NET Framework ASP.NET Updated ASP Engine Web Forms Engine Framework Classes System.Math, System.Io, System.Data, Etc. Common Language Runtime Memory Management Common Type System Garbage Collection .NET .NET Servers 153_VBnet_TOC 8/16/01 1:12 PM Page xiii xiv Contents Security 17 Type Safety 18 Casting 18 Data Conversion 19 Bitwise Operations 20 New Compiler 20 Compiling an Executable 20 Architecture 21 File Management in Previous Versions of VB 21 File Management 22 Changes from Visual Basic 6.0 23 Variants 23 Variable Lower Bounds 23 Fixed Length Strings 23 NULL Propagation 23 Other Items Removed 24 Function Values 24 Short Circuits 25 Properties and Variables 25 Variable Lengths 25 Get and Set 26 Date Type 26 Default Properties 27 Summary 28 Solutions Fast Track 28 Frequently Asked Questions 31 Chapter 2 The Microsoft .NET Framework 33 Introduction 34 What Is the .NET Framework? 34 Introduction to the Common Language Runtime 35 Using .NET-Compliant Programming Languages 37 Creating Assemblies 39 Using the Manifest 42 Compiling Assemblies 45 Assembly Cache 45 Locating an Assembly 45 153_VBnet_TOC 8/16/01 1:12 PM Page xiv Contents xv Private Assembly Files 51 Shared Assembly Files 51 Understanding Metadata 51 The Benefits of Metadata 52 Identifying an Assembly with Metadata 53 Types 53 Defining Members 54 Using Contracts 54 Assembly Dependencies 55 Unmanaged Assembly Code 55 Reflection 56 Attributes 57 Ending DLL Hell 58 Side-by-Side Deployment 58 Versioning Support 59 Using System Services 60 Exception Handling 60 StackTrace 61 InnerException 61 Message 61 HelpLink 62 Garbage Collection 62 Console I/O 62 Microsoft Intermediate Language 63 The Just-In-Time Compiler 63 Using the Namespace System to Organize Classes 64 The Common Type System 65 Type Safety 68 Relying on Automatic Resource Management 68 The Managed Heap 69 Garbage Collection and the Managed Heap 71 Assigning Generations 77 Utilizing Weak References 77 Security Services 79 Framework Security 80 Granting Permissions 81 NOTE Visualization is still key! Die-hard VB programmers may find themselves having a hard time visualizing all the new concepts in VB.NET (and we all know that proper logic visualization plays a big role in what we do). Something that may help is to think about VB.NET as a completely flexible language that can accommodate Web, console, and desktop use. 153_VBnet_TOC 8/16/01 1:12 PM Page xv xvi Contents Gaining Representation through a Principal 82 Security Policy 83 Summary 85 Solutions Fast Track 85 Frequently Asked Questions 88 Chapter 3 Installing and Configuring VB.NET 91 Introduction 92 Editions 92 Installing Visual Studio .NET 93 Exercise 3.1:Installing Visual Studio .NET 94 Installing on Windows 2000 99 The New IDE 100 Integrated Development Environment Automation Model 100 Add-Ins 104 Exercise 3.2 Creating an Add-In Using the Add-In Wizard 105 Wizards 109 Macros 109 Home Page 110 Project Options 112 Toolbox 116 Child Windows 120 Window Types 122 Arranging Windows 123 Task List 123 Exercise 3.3 Setting Up a Custom Token 124 TaskList Views 124 Locating Code 126 Annotating Code 126 Solution Explorer 127 Properties Window 129 Form Layout Toolbar 130 Hide/Show Code Elements 132 Installing Visual Studio .NET IPhase 1: Installing Windows components IPhase 2: Installing Visual Studio .NET IPhase 3: Checking for service releases 153_VBnet_TOC 8/16/01 1:12 PM Page xvi
中文名: Beginning C# Object-Oriented Programming (第1版, 涵盖.NET 4.0 and C# 4.0) 原名: Beginning C# Object-Oriented Programming, 1st edition 作者: Dan Clark 资源格式: PDF 出版社: Apress书号: 978-1430235309发行时间: 2011年05月31日 地区: 美国 语言: 英文 简介: 内容介绍: Beginning C# Object-Oriented Programming brings you into the modern world of development as you master the fundamentals of programming with C# and learn to develop efficient, reusable, elegant code through the object-oriented programming (OOP) methodology. Take your skills out of the 20th century and into this one with Dan Clark's accessible, quick-paced guide to C# and object-oriented programming, completely updated for .NET 4.0 and C# 4.0. As you develop techniques and best practices for coding in C#, one of the world's most popular contemporary languages, you'll experience modeling a “real world” application through a case study, allowing you to see how both C# and OOP (a methodology you can use with any number of languages) come together to make your code reusable, modern, and efficient. With more than 30 fully hands-on activities, you'll discover how to transform a simple model of an application into a fully-functional C# project, including designing the user interface, implementing the business logic, and integrating with a relational database for data storage. Along the way, you will explore the .NET Framework, the creation of a Windows-based user interface, a web-based user interface, and service-oriented programming, all using Microsoft's industry-leading Visual Studio 2010, C#, Silverlight, the Entity Framework, and more. 目录: Overview of Object-Oriented Programming Designing OOP Solutions: Identifying the Class Structure Designing OOP Solutions: Modeling the Object Interaction Designing OOP Solutions: A Case Study Introducing the .NET Framework and Visual Studio Creating Classes Creating Class Hierarchies Implementing Object Collaboration Working with Collections Implementing the Data Access Layer Developing Windows Applications Developing Web Applications Developing and Consuming WCF Services Developing the OSO Application Wrapping Up Fundamental Programming Concepts Exception Handling in C# Installing the Required Software

64,676

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧