HAPPY BOOKSGIVING
Use code BOOKSGIVING during checkout to save 40%-55% on books and eBooks. Shop now.
Register your product to gain access to bonus material or receive a coupon.
This eBook includes the following formats, accessible from your Account page after purchase:
EPUB The open industry format known for its reflowable content and usability on supported mobile devices.
PDF The popular standard, used most often with the free Acrobat® Reader® software.
This eBook requires no passwords or activation to read. We customize your eBook by discreetly watermarking it with your name, making it uniquely yours.
Using Visual Basic 2015, developers can build cutting-edge applications that run practically anywhere: on Windows desktops, new Windows 10 devices, in mobile and cloud environments, and beyond. Visual Basic 2015 Unleashed is the most comprehensive, practical reference to modern programming with VB 2015.
Long-time Visual Basic MVP Alessandro Del Sole walks you through the latest version of the language, helping you thoroughly master its most valuable features, most powerful programming techniques, and most effective development patterns. Next, he shows how to use Visual Basic 2015 to build robust, effective software in a wide range of environments.
Extensively updated for Visual Basic 2015’s major improvements, this guide covers both Visual Basic 2015 Professional Edition for professional developers and the free Community Edition for hobbyists, novices, and students. Del Sole has added detailed coverage of building new universal Windows apps for Windows 10 and using new Visual Studio 2015 capabilities to supercharge your productivity as a developer. If you want to leverage all of VB 2015’s power, this is the book you need.
Detailed information on how to...
Introduction 1
Code Samples and Software Requirements 2
Part I: Learning the Basics of VB
Chapter 1: Introducing .NET 2015 3
.NET 2015: A New Vision for Development 3
The .NET Framework 4.6 for Desktop 5
Introducing .NET Core 5 10
Programming Languages in Visual Studio 2015 12
What’s New with Compilers 13
The Windows Software Development Kit 15
Summary 15
Chapter 2: The Visual Studio 2015 IDE for Visual Basic 17
What’s New in Visual Studio 2015 17
Status Bar and Start Page 18
Working with Projects and Solutions 20
Working with Tool Windows 35
The My Project Window 42
Compiling Projects 48
Debugging Overview 58
Browsing the Visual Basic and .NET Documentation 65
Quick Launch Tool 67
Showing the Hierarchy of Method Calls 69
Summary 70
Chapter 3: The Anatomy of a Visual Basic Project 71
Brief Overview of Types and Members 71
Visual Basic 2015 Reserved Keywords 80
Understanding Project Files 82
Understanding References 92
Summary 97
Chapter 4: Data Types and Expressions 99
Introducing the Common Type System 99
Understanding Value Types 103
Understanding Reference Types 113
Differences Between Value Types and Reference Types 116
Converting Between Value Types and Reference Types 121
Understanding Conversion Operators 129
Working with .NET Fundamental Types 135
Common Operators 172
Iterations, Loops, and Conditional Code Blocks 188
Summary 197
Chapter 5: Debugging Visual Basic 2015 Applications 199
Preparing an Example 199
Debugging Instrumentation 200
Inspecting Object Details with Debugger Visualizers 215
Debugging in Code 216
Summary 230
Chapter 6: Errors, Exceptions, and Code Refactoring 231
Introducing Exceptions 231
Handling Exceptions 233
Refactoring Your Code: Light Bulbs and Quick Actions 249
Summary 266
Part II: Object-Oriented Programming with Visual Basic 2015
Chapter 7: Class Fundamentals 267
Declaring Classes 267
Storing Information with Properties 271
Types and Members Visibility: Scope 276
Executing Actions with Methods 278
Organizing Code with Partial Classes 290
Splitting Method Definitions with Partial Methods 293
Instantiating Objects with Constructors 295
Shared Members 301
Common Language Specification 306
Summary 311
Chapter 8: Managing an Object’s Lifetime 313
Understanding Memory Allocation 313
Understanding Garbage Collection 314
Understanding the Finalize Method 315
Understanding Dispose and the IDisposable Interface 317
Advanced Garbage Collection 323
Summary 326
Chapter 9: Organizing Types Within Namespaces 327
Understanding Namespaces 327
Organizing Types Within Namespaces 328
Global Namespaces and the Global Keyword 342
Summary 345
Chapter 10: Modules 347
Modules Overview 347
Differences Between Modules and Classes 349
Summary 350
Chapter 11: Structures and Enumerations 351
Understanding Structures 351
Overloading Operators 356
Structures and Common Language Specification 360
Grouping Constants with Enumerations 361
Summary 367
Chapter 12: Inheritance 369
Applying Inheritance 370
Introducing Polymorphism 375
Overriding Members 377
Conditioning Inheritance 380
Accessing Base Classes Members 383
Constructors’ Inheritance 387
Shadowing 388
Overriding Shared Members 389
Practical Inheritance: Building Custom Exceptions 390
Summary 392
Chapter 13: Interfaces 393
Defining Interfaces 393
Implementing and Accessing Interfaces 394
Partial Interfaces 399
Interfaces and Polymorphism 399
Interfaces Inheritance 400
Defining CLS-Compliant Interfaces 402
Most Common .NET Interfaces 402
Summary 412
Chapter 14: Generics and Nullable Types 413
Introducing Generics 413
Creating and Consuming Generics 414
Introducing Nullable Types 422
Summary 425
Chapter 15: Delegates and Events 427
Understanding Delegates 427
Handling Events 431
Offering Events to the External World 433
Summary 439
Chapter 16: Working with Collections and Iterators 441
Understanding Collections Architecture 442
Working with Nongeneric Collections 442
Working with Generic Collections 451
The Null-Conditional Operator and Collections 461
Building Custom Collections 462
Concurrent Collections 463
Immutable Collections 463
Iterators 464
Summary 472
Chapter 17: Working with Objects: Visual Tools and Code Sharing 473
Visual Studio Class Designer 473
Class View Window 484
Creating Types with Generate from Usage 485
Creating Portable Classes 491
Shared Projects 503
Summary 512
Part III: Advanced Language Features
Chapter 18: Manipulating Files and Streams 513
Manipulating Directories and Pathnames 513
Handling Exceptions for Directories and Pathnames 519
Manipulating Files 519
Introducing Streams 524
Summary 535
Chapter 19: The My Namespace 537
Introducing the My Namespace 537
My.Application 538
My.Computer 542
My.Settings 550
My.Resources 556
My.User 560
My.WebServices 562
Extending My 562
My in Different Applications 566
Summary 570
Chapter 20: Advanced Language Features 571
Local Type Inference 571
Array Literalsv575
Extension Methods 577
Anonymous Types 585
Relaxed Delegates 586
Lambda Expressions 587
Generic Variance 596
Summary 598
Part IV: Data Access with ADO.NET and LINQ
Chapter 21: Introducing ADO.NET and DataSets 599
System Requirements 599
Introducing ADO.NET 600
Introducing DataSets 603
Summary 608
Chapter 22: Introducing LINQ 609
What Is LINQ? .609
LINQ Examples 611
Language Support 612
Understanding Providers 613
Overview of LINQ Architecture 613
Summary 614
Chapter 23: LINQ to Objects 615
Introducing LINQ to Objects 615
Querying in Memory Objects 616
Introducing Standard Query Operators 625
Summary 644
Chapter 24: LINQ to SQL 645
Introducing LINQ to SQL 646
Querying Data with LINQ to SQL 658
Insert/Update/Delete Operations with LINQ 663
Advanced LINQ to SQL 672
Summary 677
Chapter 25: LINQ to DataSets 679
Querying DataSets with LINQ 679
LINQ to DataSets’ Extension Methods 682
Summary 685
Chapter 26: Introducing ADO.NET Entity Framework 687
Introducing Entity Framework 687
Understanding Entity Data Models 688
Insert/Update/Delete Operations for Entities 703
Querying EDMs with LINQ to Entities 710
Querying EDMs with Entity SQL 712
Mapping Stored Procedures 712
Introducing the Code First Approach 716
Summary 727
Chapter 27: Manipulating XML Documents with LINQ and XML Literals 729
Introducing LINQ to XML 730
Writing XML Markup in VB with XML Literals 735
Summary 743
Part V: Building Windows Desktop Applications
Chapter 28: Creating WPF Applications 745
What Is WPF? 746
Introducing the WPF Architecture 747
Building WPF Applications with Visual Studio 2015 749
Understanding the eXtensible Application Markup Language 751
Understanding Visual Tree and Logical Tree 757
Handling Events in WPF 759
Arranging Controls with Panels 762
Managing Windows 770
Introducing the Application Object 772
Brief Overview of WPF Browser Applications 774
Live Visual Tree 777
Summary 778
Chapter 29: WPF Common Controls 779
Introducing WPF Controls Features 779
Understanding the ContentControl 780
Understanding Common Controls 781
Using Common Dialogs 809
Summary 810
Chapter 30: Brushes, Styles, Templates, and Animations in WPF 811
Introducing Brushes 812
Introducing Styles 828
Introducing Control Templates 833
Introducing Transformations 836
Introducing Animations 840
Summary 849
Chapter 31: Manipulating Media and Documents 851
Viewing Images 851
Playing Media 853
Manipulating Documents 857
Viewing XPS Documents 866
Summary 867
Chapter 32: Introducing Data-Binding 869
Introducing the Data-Binding in WPF 869
Discussing the Drag and Drop Data-Binding 876
Summary 900
Chapter 33: Localizing Applications 901
Introducing .NET Localization 902
Introducing the Multilingual App Toolkit 902
Windows Forms Localization 903
WPF Localization 906
Summary 908
Part VI: Building Web and Mobile Applications
Chapter 34: Building and Publishing ASP.NET Web Applications 909
Introducing the ASP.NET Model 910
Web Forms and Master Pages 914
ASP.NET Controls 917
Handling Events 919
Understanding State Management 920
Creating a Web Application with VB 2015 with Data Access and Pages 923
Publishing ASP.NET Web Applications 940
Summary 949
Chapter 35: Building and Deploying Applications for Microsoft Azure 951
Overview of the Microsoft Azure Platform 951
Registering for Microsoft Azure 953
Downloading and Installing Tools for Visual Studio 954
Introducing the Management Portal 954
Creating a SQL Azure Database 955
Creating an ASP.NET Application for the Cloud 961
Deploying Applications to Microsoft Azure 964
A Step Further: Web Roles and Worker Roles 967
Additional Tools 970
Summary 972
Chapter 36: Building Universal Apps for Windows 10 973
Introducing Universal Windows Apps 974
Introducing the Universal Windows Platform 975
Registering with the Windows Store 976
Installing the Developer Tools 976
Creating Apps with Visual Basic 977
Customizing the Application Manifest 998
Starting and Debugging Universal Windows Apps 1002
Creating and Testing App Packages 1009
Submitting Apps to the Store 1010
Summary 1011
Part VII: Networking and Exposing Data Through Networks
Chapter 37: Creating and Consuming WCF Services 1013
Introducing Windows Communication Foundation 1014
Implementing WCF Services 1015
Consuming WCF Services 1024
Handling Exceptions in WCF 1030
Hosting WCF Services in Internet Information Services and Microsoft Azure 1031
Configuring Services with the Configuration Editor 1033
Summary 1034
Chapter 38: Implementing and Consuming OData Services 1035
What Are OData Services? 1035
Creating an OData Endpoint 1036
Consuming OData Services 1060
Implementing and Consuming Functions 1068
Summary 1071
Part VIII: Advanced .NET Framework with VB 2015
Chapter 39: Serialization 1073
Objects Serialization 1074
XML Serialization 1081
Custom Serialization 1083
Serialization with XAML 1086
Serialization in Windows Communication Foundation 1088
Serialization in the ADO.NET Entity Framework 1091
Summary 1092
Chapter 40: Processes and Multithreading 1095
Managing Processes 1096
Introducing Multithreading 1098
Understanding the .NET Thread Pool 1099
Threads Synchronization 1101
Summary 1104
Chapter 41: Parallel Programming and Parallel LINQ 1105
Introducing Parallel Computing 1106
Understanding and Using Tasks 1107
Parallel Loops 1116
Debugging Tools for Parallel Tasks 1122
Concurrent Collections 1124
Introducing Parallel LINQ 1128
Summary 1137
Chapter 42: Asynchronous Programming 1139
Overview of Asynchrony 1140
The Old-Fashioned Way: Event-Based Asynchrony 1140
The Old-Fashioned Way: The Asynchronous Programming Model 1142
The Modern Way: The Async Pattern 1143
Getting Started with Async/Await 1147
Exception Handling in Async 1161
Implementing Task-Based Asynchrony 1161
Cancellation and Progress 1165
Asynchronous Lambda Expressions 1170
Asynchronous I/O File Operations in .NET 4.6 1171
Debugging Tasks 1175
Summary 1176
Chapter 43: Working with Assemblies 1177
Assembly Overview 1177
Understanding Application Domains 1179
Security Model in .NET 4.6 1182
Summary 1189
Chapter 44: Reflection 1191
Introducing Reflection 1191
Understanding Assemblies’ Metadata 1192
Getting Assembly Information 1194
Reflecting Types 1196
Invoking Code Dynamically 1204
Generating Code at Runtime with Reflection.Emit 1206
Caller Information 1212
Summary 1215
Chapter 45: Coding Attributes 1217
Applying Attributes 1217
Coding Custom Attributes 1220
Reflecting Attributes 1225
Summary 1226
Chapter 46: Platform Invokes and Interoperability with the COM Architecture 1229
Importing and Using COM Objects 1230
Catching Exceptions 1233
Releasing COM Objects 1233
Calling COM Objects from WPF 1234
P/Invokes and Unmanaged Code 1237
References to the Win32 API Calls 1244
Summary 1244
Chapter 47: Documenting Source Code with XML Comments 1245
Understanding XML Comments 1246
Implementing XML Comments 1248
Generating Compiled Help Files 1258
Summary 1259
Part IX: Applications Deployment
Chapter 48: Understanding the Global Assembly Cache 1261
The Dll Hell Problem 1261
The Global Assembly Cache 1263
Summary 1267
Chapter 49: Setup and Deployment Projects with InstallShield for Visual Studio 1269
Windows Installer Overview 1270
Introducing InstallShield 1271
Creating a Setup Project 1272
Configuring the Setup Project 1283
Building and Deploying the Windows Installer Package 1285
Summary 1285
Chapter 50: Deploying Applications with ClickOnce 1287
Introducing ClickOnce 1287
Deploying Applications with ClickOnce 1289
Configuring ClickOnce 1294
Security Considerations 1299
Programmatically Accessing ClickOnce 1301
Registration-Free COM 1302
Summary 1304
Part X: Code Analysis with VB 2015
Chapter 51: Code Analysis: The .NET Compiler Platform and Tools 1305
Live Code Analysis with the .NET Compiler Platform 1306
Calculating Code Metrics 1349
Diagnostic Tools and IntelliTrace 1351
Code Clone Detection 1359
Summary 1361
Appendix A: Useful Resources and Tools for Visual Basic 2015 1363
Visual Basic Resources in MSDN 1363
Useful Developer Tools for Visual Basic 1364
Index 1367
Online-Only Chapters
Chapter 52: Advanced IDE Features
Chapter 53: Testing Code with Unit Tests and Test-Driven Development