diff --git a/557.html b/557.html new file mode 100644 index 0000000..285cd90 --- /dev/null +++ b/557.html @@ -0,0 +1,19 @@ +Part One Debugging in the VB .NET World
+Chapter 1: Strategic Debugging Issues
+Chapter 2: Language Surprises in VB .NET
+Part Two The Debugging Tools
+Chapter 3: The Visual Studio .NET Debugger
+Chapter 4: Using the Visual Studio .NET Debugger
+Chapter 5: Other Debugging Tools
+Chapter 6: Tracing and Instrumentation
+Part Three Debugging Applications
+Chapter 7: Windows Forms Debugging
+Chapter 8: Web Services Debugging
+Chapter 9: ASP.NET Debugging
+Chapter 10: Windows Services Debugging
+Chapter 11: VB.Classic Debugging
+Chapter 12: SQL Server Debugging
+Part Four Debugging Common Scenarios
+Chapter 13: Error Handling and Exception Management
+Chapter 14: Debugging Multithreaded Applications
+Chapter 15: Debugging Distributed Systems \ No newline at end of file diff --git a/919.pdf b/919.pdf new file mode 100644 index 0000000..bb9faf6 Binary files /dev/null and b/919.pdf differ diff --git a/920.pdf b/920.pdf new file mode 100644 index 0000000..f4298d7 Binary files /dev/null and b/920.pdf differ diff --git a/9781590590508.jpg b/9781590590508.jpg new file mode 100644 index 0000000..df80a96 Binary files /dev/null and b/9781590590508.jpg differ diff --git a/Inetpub/wwwroot/AspNetDebugDemo/AspNetDebugDemo.vbproj b/Inetpub/wwwroot/AspNetDebugDemo/AspNetDebugDemo.vbproj new file mode 100644 index 0000000..ce4ab0f --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/AspNetDebugDemo.vbproj @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/AspNetDebugDemo.vbproj.webinfo b/Inetpub/wwwroot/AspNetDebugDemo/AspNetDebugDemo.vbproj.webinfo new file mode 100644 index 0000000..645711c --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/AspNetDebugDemo.vbproj.webinfo @@ -0,0 +1,4 @@ + + + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/AssemblyInfo.vb b/Inetpub/wwwroot/AspNetDebugDemo/AssemblyInfo.vb new file mode 100644 index 0000000..e9e06d0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx b/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx new file mode 100644 index 0000000..1c53086 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx @@ -0,0 +1,17 @@ +<%@ Page Language="vb" AutoEventWireup="false" Codebehind="CustomErrorPage.aspx.vb" Inherits="AspNetDebugDemo.CustomErrorPage"%> + + + + CustomErrorPage + + + + + + +
+ This PAGE-level custom error page was defined in MainForm.ErrorPage
+ + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx.resx new file mode 100644 index 0000000..cb94e8a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx.resx @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + False + + \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx.vb new file mode 100644 index 0000000..346af60 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/CustomErrorPage.aspx.vb @@ -0,0 +1,33 @@ +Public Class CustomErrorPage + Inherits System.Web.UI.Page + +#Region " Web Form Designer Generated Code " + + 'This call is required by the Web Form Designer. + Private Sub InitializeComponent() + + End Sub + Protected WithEvents lblText As System.Web.UI.WebControls.Label + Protected WithEvents btnBack As System.Web.UI.WebControls.Button + + 'NOTE: The following placeholder declaration is required by the Web Form Designer. + 'Do not delete or move it. + Private designerPlaceholderDeclaration As System.Object + + Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init + 'CODEGEN: This method call is required by the Web Form Designer + 'Do not modify it using the code editor. + InitializeComponent() + End Sub + +#End Region + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Put user code to initialize the page here + End Sub + + Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click + Server.ClearError() + Response.Redirect(Request.QueryString("aspxErrorPath")) + End Sub +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx b/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx new file mode 100644 index 0000000..3845a82 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx @@ -0,0 +1,18 @@ +<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DefaultErrorPage.aspx.vb" Inherits="AspNetDebugDemo.DefaultErrorPage"%> + + + + DefaultErrorPage + + + + + + +
+ This APP-level custom error page was defined in Web.config +
+ + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx.resx new file mode 100644 index 0000000..cb94e8a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx.resx @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + False + + \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx.vb new file mode 100644 index 0000000..be4fdd1 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/DefaultErrorPage.aspx.vb @@ -0,0 +1,33 @@ +Public Class DefaultErrorPage + Inherits System.Web.UI.Page + +#Region " Web Form Designer Generated Code " + + 'This call is required by the Web Form Designer. + Private Sub InitializeComponent() + + End Sub + Protected WithEvents btnBack As System.Web.UI.WebControls.Button + Protected WithEvents lblText As System.Web.UI.WebControls.Label + + 'NOTE: The following placeholder declaration is required by the Web Form Designer. + 'Do not delete or move it. + Private designerPlaceholderDeclaration As System.Object + + Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init + 'CODEGEN: This method call is required by the Web Form Designer + 'Do not modify it using the code editor. + InitializeComponent() + End Sub + +#End Region + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Put user code to initialize the page here + End Sub + + Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click + Server.ClearError() + Response.Redirect(Request.QueryString("aspxErrorPath")) + End Sub +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo/Global.asax b/Inetpub/wwwroot/AspNetDebugDemo/Global.asax new file mode 100644 index 0000000..b94fec6 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.vb" Inherits="AspNetDebugDemo.Global" %> \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo/Global.asax.resx b/Inetpub/wwwroot/AspNetDebugDemo/Global.asax.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/Global.asax.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/Global.asax.vb b/Inetpub/wwwroot/AspNetDebugDemo/Global.asax.vb new file mode 100644 index 0000000..26c73b8 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/Global.asax.vb @@ -0,0 +1,60 @@ +Imports System.Web +Imports System.Web.SessionState + +Public Class Global + Inherits System.Web.HttpApplication + +#Region " Component Designer Generated Code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +#End Region + + Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application is started + End Sub + + Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session is started + End Sub + + Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires at the beginning of each request + End Sub + + Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires upon attempting to authenticate the use + End Sub + + Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when an error occurs + Context.Trace.Write(Server.GetLastError.InnerException.Message) + End Sub + + Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session ends + End Sub + + Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application ends + End Sub + +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx b/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx new file mode 100644 index 0000000..1c9b7b0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx @@ -0,0 +1,50 @@ +<%@ Page Language="vb" AutoEventWireup="false" Codebehind="MainForm.aspx.vb" Inherits="AspNetDebugDemo.MainForm" trace="False" traceMode="SortByTime"%> + + + + MainForm + + + + + + +
+ + ASP.NET tracing demo + +   + ASP.NET debugging and error-handling demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx.resx new file mode 100644 index 0000000..cb94e8a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx.resx @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + False + + \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx.vb new file mode 100644 index 0000000..70ebe73 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/MainForm.aspx.vb @@ -0,0 +1,94 @@ +Public Class MainForm : Inherits System.Web.UI.Page + +#Region " Web Form Designer Generated Code " + + 'This call is required by the Web Form Designer. + Private Sub InitializeComponent() + + End Sub + Protected WithEvents lblMain As System.Web.UI.WebControls.Label + Protected WithEvents lblException As System.Web.UI.WebControls.Label + Protected WithEvents btnPageLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnNoLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnAppLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnProcLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnPageTracingOn As System.Web.UI.WebControls.Button + Protected WithEvents btnAppTracingShow As System.Web.UI.WebControls.Button + Protected WithEvents lblTrace As System.Web.UI.WebControls.Label + + 'NOTE: The following placeholder declaration is required by the Web Form Designer. + 'Do not delete or move it. + Private designerPlaceholderDeclaration As System.Object + + Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init + 'CODEGEN: This method call is required by the Web Form Designer + 'Do not modify it using the code editor. + InitializeComponent() + End Sub + +#End Region + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Put user code to initialize the page here + End Sub + + Private Sub btnNoLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNoLevel.Click + 'Doesn't catch error. + 'Doesn't deal with error. + 'Displays error using ASP.NET default error page. + 'NB Ensure page-level and app-level error handling + 'switched-off before testing this procedure. + Dim Test As Object + Test.ToString() + End Sub + + Private Sub btnProcLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcLevel.Click + 'Catches error at procedure-level + 'Deals with error in Catch clause + 'Displays error using Catch clause + Try + Dim Test As Object + Test.ToString() + Catch ex As Exception + Me.lblException.Text = ex.Message + Finally + Server.ClearError() + End Try + End Sub + + Private Sub btnPageLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPageLevel.Click + 'Catches error at page-level + 'Deals with error in Me.Page_Error event + 'Displays error using Me.ErrorPage property + Me.ErrorPage = "CustomErrorPage.aspx" + Dim Test As Object + Test.ToString() + End Sub + + Private Sub btnAppLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAppLevel.Click + 'Catches error at application-level + 'Deals with error in Global.asax.Application_Error event + 'Displays error using default redirect in Web.config + Dim Test As Object + Test.ToString() + End Sub + + Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error + Trace.Write(Server.GetLastError.Message) + 'Server.ClearError() + End Sub + + Private Sub btnPageTracingOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPageTracingOn.Click + With Me.Trace + .IsEnabled = True + .TraceMode = TraceMode.SortByTime + .Write("Information", "This is some custom trace information") + .Warn("Warning", "This is a custom trace warning") + End With + End Sub + + Private Sub btnAppTracingShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAppTracingShow.Click + Response.Redirect("trace.axd") + End Sub + +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo/Styles.css b/Inetpub/wwwroot/AspNetDebugDemo/Styles.css new file mode 100644 index 0000000..8fe2cd9 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/Styles.css @@ -0,0 +1,163 @@ +/* Default CSS Stylesheet for a new Web Application project */ + +BODY +{ + BACKGROUND-COLOR: white; + FONT-FAMILY: Verdana, Helvetica, sans-serif; + FONT-SIZE: .8em; + FONT-WEIGHT: normal; + LETTER-SPACING: normal; + TEXT-TRANSFORM: none; + WORD-SPACING: normal +} + +H1, H2, H3, H4, H5, TH, THEAD, TFOOT +{ + COLOR: #003366; +} +H1 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 2em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H2 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1.75em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H3 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1.58em; + font-weight: 500; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H4 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1.33em; + font-weight: 500; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H5, DT { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H6 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: .8em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +TFOOT, THEAD { + font-size: 1em; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + font-family: Arial, Helvetica, sans-serif; + } + +TH { + vertical-align: baseline; + font-size: 1em; + font-weight: bold; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + font-family: Arial, Helvetica, sans-serif; + } + + +A:link { + text-decoration: none; + color: #3333cc; + } + +A:visited { + text-decoration: none; + color: #333399; + } + +A:active { + text-decoration: none; + color: #333399; + } + +A:hover { + text-decoration: underline; + color: #3333cc; + } + +SMALL { + font-size: .7em; + } + +BIG { + font-size: 1.17em; + } + +BLOCKQUOTE, PRE { + font-family: Courier New, monospace; + } + + +UL LI { + list-style-type: square ; + } + +UL LI LI { + list-style-type: disc; + } + +UL LI LI LI { + list-style-type: circle; + } + +OL LI { + list-style-type: decimal; + } + +OL OL LI { + list-style-type: lower-alpha; + } + +OL OL OL LI { + list-style-type: lower-roman; + } + +IMG { + margin-top: 5px; + margin-left: 10px; + margin-right: 10px; + } diff --git a/Inetpub/wwwroot/AspNetDebugDemo/Web.config b/Inetpub/wwwroot/AspNetDebugDemo/Web.config new file mode 100644 index 0000000..301ff1c --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/Web.config @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/access.cnf b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/access.cnf new file mode 100644 index 0000000..7759afe --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/access.cnf @@ -0,0 +1,4 @@ +vti_encoding:SR|utf8-nl +RealmName:CHEETAH +InheritPermissions:true +PasswordDir:c:\\inetpub\\wwwroot\\_vti_pvt diff --git a/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/deptodoc.btr b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/deptodoc.btr new file mode 100644 index 0000000..10a761c Binary files /dev/null and b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/deptodoc.btr differ diff --git a/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/doctodep.btr b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/doctodep.btr new file mode 100644 index 0000000..4b85379 Binary files /dev/null and b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/doctodep.btr differ diff --git a/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/service.cnf b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/service.cnf new file mode 100644 index 0000000..4e26c17 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/service.cnf @@ -0,0 +1,20 @@ +vti_encoding:SR|utf8-nl +vti_casesensitiveurls:IX|0 +vti_httpdversion:SX|Microsoft-IIS/5.0 +vti_textextensions:SX|.txt.actproj.asm.c.cc.cod.cpp.cs.cxx.dbs.def.dsp.dsw.etp.ext.fky.h.hpp.hxx.i.idl.inc.inl.kci.lgn.lst.mak.map.mk.odh.odl.prc.rc.rc2.rct.rgs.rul.s.sql.srf.tab.tlh.tli.trg.txt.udf.udt.user.usr.vap.vb.vcproj.viw.vspscc.vsscc.vssscc. +vti_featurelist:VX|vti_ACIPAddresses vti_ACCreateNewUsers vti_ACChangePassword vti_ACNoUserGroup vti_ACCreateNewGroups vti_ACModifyGroups vti_ServiceMarkUrlDirExec vti_ServerEmailTransport +vti_dependenciesood:IR|0 +vti_webservertype:SR|msiis +vti_publishmetainfokeys:VR|vti_assignedto vti_approvallevel vti_categories vti_description +vti_categories:VR|Travel Expense\\ Report Business Competition Goals/Objectives Ideas Miscellaneous Waiting VIP In\\ Process Planning Schedule +vti_htmlextensions:SX|.htm.html.htx.stm.stm.html.htm.shtml.shtm.htt.asp.alx.asa. +vti_approvallevels:VR|Content\\ Review Legal\\ Review Code\\ Review Manager\\ Review +vti_timecreated:TR|01 Mar 2003 13:49:55 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_longfilenames:IX|1 +vti_welcomenames:VX|Default.htm Default.asp iisstart.asp Default.aspx +vti_insecureserverurl:SR|http://localhost +vti_secureserverurl:SR|https://localhost +vti_disableautoimgsizeexts:SX|.asp +vti_oldestcompatibleversion:SR|2.0.0.0 +vti_restartmanual:IX|0 diff --git a/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/service.lck b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/service.lck new file mode 100644 index 0000000..e69de29 diff --git a/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/services.cnf b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/services.cnf new file mode 100644 index 0000000..b498fd4 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo/_vti_pvt/services.cnf @@ -0,0 +1 @@ +/ diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj b/Inetpub/wwwroot/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj new file mode 100644 index 0000000..69032e0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj @@ -0,0 +1,173 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj.webinfo b/Inetpub/wwwroot/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj.webinfo new file mode 100644 index 0000000..7b2a46a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj.webinfo @@ -0,0 +1,4 @@ + + + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/AssemblyInfo.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/AssemblyInfo.vb new file mode 100644 index 0000000..e9e06d0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx b/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx new file mode 100644 index 0000000..1c53086 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx @@ -0,0 +1,17 @@ +<%@ Page Language="vb" AutoEventWireup="false" Codebehind="CustomErrorPage.aspx.vb" Inherits="AspNetDebugDemo.CustomErrorPage"%> + + + + CustomErrorPage + + + + + + +
+ This PAGE-level custom error page was defined in MainForm.ErrorPage
+ + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx.resx new file mode 100644 index 0000000..cb94e8a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx.resx @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + False + + \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx.vb new file mode 100644 index 0000000..346af60 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/CustomErrorPage.aspx.vb @@ -0,0 +1,33 @@ +Public Class CustomErrorPage + Inherits System.Web.UI.Page + +#Region " Web Form Designer Generated Code " + + 'This call is required by the Web Form Designer. + Private Sub InitializeComponent() + + End Sub + Protected WithEvents lblText As System.Web.UI.WebControls.Label + Protected WithEvents btnBack As System.Web.UI.WebControls.Button + + 'NOTE: The following placeholder declaration is required by the Web Form Designer. + 'Do not delete or move it. + Private designerPlaceholderDeclaration As System.Object + + Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init + 'CODEGEN: This method call is required by the Web Form Designer + 'Do not modify it using the code editor. + InitializeComponent() + End Sub + +#End Region + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Put user code to initialize the page here + End Sub + + Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click + Server.ClearError() + Response.Redirect(Request.QueryString("aspxErrorPath")) + End Sub +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx b/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx new file mode 100644 index 0000000..3845a82 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx @@ -0,0 +1,18 @@ +<%@ Page Language="vb" AutoEventWireup="false" Codebehind="DefaultErrorPage.aspx.vb" Inherits="AspNetDebugDemo.DefaultErrorPage"%> + + + + DefaultErrorPage + + + + + + +
+ This APP-level custom error page was defined in Web.config +
+ + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx.resx new file mode 100644 index 0000000..cb94e8a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx.resx @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + False + + \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx.vb new file mode 100644 index 0000000..be4fdd1 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/DefaultErrorPage.aspx.vb @@ -0,0 +1,33 @@ +Public Class DefaultErrorPage + Inherits System.Web.UI.Page + +#Region " Web Form Designer Generated Code " + + 'This call is required by the Web Form Designer. + Private Sub InitializeComponent() + + End Sub + Protected WithEvents btnBack As System.Web.UI.WebControls.Button + Protected WithEvents lblText As System.Web.UI.WebControls.Label + + 'NOTE: The following placeholder declaration is required by the Web Form Designer. + 'Do not delete or move it. + Private designerPlaceholderDeclaration As System.Object + + Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init + 'CODEGEN: This method call is required by the Web Form Designer + 'Do not modify it using the code editor. + InitializeComponent() + End Sub + +#End Region + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Put user code to initialize the page here + End Sub + + Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click + Server.ClearError() + Response.Redirect(Request.QueryString("aspxErrorPath")) + End Sub +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax b/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax new file mode 100644 index 0000000..b94fec6 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.vb" Inherits="AspNetDebugDemo.Global" %> \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax.vb new file mode 100644 index 0000000..26c73b8 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/Global.asax.vb @@ -0,0 +1,60 @@ +Imports System.Web +Imports System.Web.SessionState + +Public Class Global + Inherits System.Web.HttpApplication + +#Region " Component Designer Generated Code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +#End Region + + Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application is started + End Sub + + Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session is started + End Sub + + Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires at the beginning of each request + End Sub + + Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires upon attempting to authenticate the use + End Sub + + Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when an error occurs + Context.Trace.Write(Server.GetLastError.InnerException.Message) + End Sub + + Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session ends + End Sub + + Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application ends + End Sub + +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx b/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx new file mode 100644 index 0000000..1c9b7b0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx @@ -0,0 +1,50 @@ +<%@ Page Language="vb" AutoEventWireup="false" Codebehind="MainForm.aspx.vb" Inherits="AspNetDebugDemo.MainForm" trace="False" traceMode="SortByTime"%> + + + + MainForm + + + + + + +
+ + ASP.NET tracing demo + +   + ASP.NET debugging and error-handling demo
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx.resx new file mode 100644 index 0000000..cb94e8a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx.resx @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + False + + \ No newline at end of file diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx.vb new file mode 100644 index 0000000..70ebe73 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/MainForm.aspx.vb @@ -0,0 +1,94 @@ +Public Class MainForm : Inherits System.Web.UI.Page + +#Region " Web Form Designer Generated Code " + + 'This call is required by the Web Form Designer. + Private Sub InitializeComponent() + + End Sub + Protected WithEvents lblMain As System.Web.UI.WebControls.Label + Protected WithEvents lblException As System.Web.UI.WebControls.Label + Protected WithEvents btnPageLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnNoLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnAppLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnProcLevel As System.Web.UI.WebControls.Button + Protected WithEvents btnPageTracingOn As System.Web.UI.WebControls.Button + Protected WithEvents btnAppTracingShow As System.Web.UI.WebControls.Button + Protected WithEvents lblTrace As System.Web.UI.WebControls.Label + + 'NOTE: The following placeholder declaration is required by the Web Form Designer. + 'Do not delete or move it. + Private designerPlaceholderDeclaration As System.Object + + Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init + 'CODEGEN: This method call is required by the Web Form Designer + 'Do not modify it using the code editor. + InitializeComponent() + End Sub + +#End Region + + Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Put user code to initialize the page here + End Sub + + Private Sub btnNoLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNoLevel.Click + 'Doesn't catch error. + 'Doesn't deal with error. + 'Displays error using ASP.NET default error page. + 'NB Ensure page-level and app-level error handling + 'switched-off before testing this procedure. + Dim Test As Object + Test.ToString() + End Sub + + Private Sub btnProcLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcLevel.Click + 'Catches error at procedure-level + 'Deals with error in Catch clause + 'Displays error using Catch clause + Try + Dim Test As Object + Test.ToString() + Catch ex As Exception + Me.lblException.Text = ex.Message + Finally + Server.ClearError() + End Try + End Sub + + Private Sub btnPageLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPageLevel.Click + 'Catches error at page-level + 'Deals with error in Me.Page_Error event + 'Displays error using Me.ErrorPage property + Me.ErrorPage = "CustomErrorPage.aspx" + Dim Test As Object + Test.ToString() + End Sub + + Private Sub btnAppLevel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAppLevel.Click + 'Catches error at application-level + 'Deals with error in Global.asax.Application_Error event + 'Displays error using default redirect in Web.config + Dim Test As Object + Test.ToString() + End Sub + + Private Sub Page_Error(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Error + Trace.Write(Server.GetLastError.Message) + 'Server.ClearError() + End Sub + + Private Sub btnPageTracingOn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPageTracingOn.Click + With Me.Trace + .IsEnabled = True + .TraceMode = TraceMode.SortByTime + .Write("Information", "This is some custom trace information") + .Warn("Warning", "This is a custom trace warning") + End With + End Sub + + Private Sub btnAppTracingShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAppTracingShow.Click + Response.Redirect("trace.axd") + End Sub + +End Class diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/Styles.css b/Inetpub/wwwroot/AspNetDebugDemo_2002/Styles.css new file mode 100644 index 0000000..8fe2cd9 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/Styles.css @@ -0,0 +1,163 @@ +/* Default CSS Stylesheet for a new Web Application project */ + +BODY +{ + BACKGROUND-COLOR: white; + FONT-FAMILY: Verdana, Helvetica, sans-serif; + FONT-SIZE: .8em; + FONT-WEIGHT: normal; + LETTER-SPACING: normal; + TEXT-TRANSFORM: none; + WORD-SPACING: normal +} + +H1, H2, H3, H4, H5, TH, THEAD, TFOOT +{ + COLOR: #003366; +} +H1 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 2em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H2 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1.75em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H3 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1.58em; + font-weight: 500; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H4 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1.33em; + font-weight: 500; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H5, DT { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 1em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +H6 { + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: .8em; + font-weight: 700; + font-style: normal; + text-decoration: none; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + } + +TFOOT, THEAD { + font-size: 1em; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + font-family: Arial, Helvetica, sans-serif; + } + +TH { + vertical-align: baseline; + font-size: 1em; + font-weight: bold; + word-spacing: normal; + letter-spacing: normal; + text-transform: none; + font-family: Arial, Helvetica, sans-serif; + } + + +A:link { + text-decoration: none; + color: #3333cc; + } + +A:visited { + text-decoration: none; + color: #333399; + } + +A:active { + text-decoration: none; + color: #333399; + } + +A:hover { + text-decoration: underline; + color: #3333cc; + } + +SMALL { + font-size: .7em; + } + +BIG { + font-size: 1.17em; + } + +BLOCKQUOTE, PRE { + font-family: Courier New, monospace; + } + + +UL LI { + list-style-type: square ; + } + +UL LI LI { + list-style-type: disc; + } + +UL LI LI LI { + list-style-type: circle; + } + +OL LI { + list-style-type: decimal; + } + +OL OL LI { + list-style-type: lower-alpha; + } + +OL OL OL LI { + list-style-type: lower-roman; + } + +IMG { + margin-top: 5px; + margin-left: 10px; + margin-right: 10px; + } diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/Web.config b/Inetpub/wwwroot/AspNetDebugDemo_2002/Web.config new file mode 100644 index 0000000..301ff1c --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/Web.config @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AspNetDebugDemo.vbproj b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AspNetDebugDemo.vbproj new file mode 100644 index 0000000..3254769 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AspNetDebugDemo.vbproj @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|30 Apr 2003 18:43:04 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|30 Apr 2003 18:43:04 -0000 +vti_filesize:IR|6643 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AspNetDebugDemo.vbproj.webinfo b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AspNetDebugDemo.vbproj.webinfo new file mode 100644 index 0000000..96d6de4 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AspNetDebugDemo.vbproj.webinfo @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|30 Apr 2003 18:44:54 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|30 Apr 2003 18:44:54 -0000 +vti_filesize:IR|133 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AssemblyInfo.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AssemblyInfo.vb new file mode 100644 index 0000000..bd11e4c --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/AssemblyInfo.vb @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|01 Mar 2003 13:50:04 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|01 Mar 2003 13:50:04 -0000 +vti_filesize:IR|1044 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx new file mode 100644 index 0000000..2b0fb67 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|02 Mar 2003 16:45:40 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|02 Mar 2003 16:45:40 -0000 +vti_filesize:IR|1050 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx.resx new file mode 100644 index 0000000..a3f799d --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx.resx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|02 Mar 2003 16:45:41 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|02 Mar 2003 16:45:41 -0000 +vti_filesize:IR|5318 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx.vb new file mode 100644 index 0000000..958e85d --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/CustomErrorPage.aspx.vb @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|02 Mar 2003 16:45:41 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|02 Mar 2003 16:45:41 -0000 +vti_filesize:IR|1284 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx new file mode 100644 index 0000000..b86c3d6 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|02 Mar 2003 16:45:41 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|02 Mar 2003 16:45:41 -0000 +vti_filesize:IR|1049 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx.resx new file mode 100644 index 0000000..a3f799d --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx.resx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|02 Mar 2003 16:45:41 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|02 Mar 2003 16:45:41 -0000 +vti_filesize:IR|5318 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx.vb new file mode 100644 index 0000000..feb4ea0 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/DefaultErrorPage.aspx.vb @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|02 Mar 2003 16:45:41 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|02 Mar 2003 16:45:41 -0000 +vti_filesize:IR|1285 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax new file mode 100644 index 0000000..f1fa572 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|01 Mar 2003 13:50:02 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|01 Mar 2003 13:50:02 -0000 +vti_filesize:IR|80 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax.resx new file mode 100644 index 0000000..be4798a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax.resx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|30 Jan 2002 05:05:12 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|30 Jan 2002 05:05:12 -0000 +vti_filesize:IR|1733 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax.vb new file mode 100644 index 0000000..34f5236 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Global.asax.vb @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|03 Mar 2003 12:53:58 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|03 Mar 2003 12:53:58 -0000 +vti_filesize:IR|1873 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx new file mode 100644 index 0000000..9bd2ce6 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|06 Mar 2003 02:21:22 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|06 Mar 2003 02:21:22 -0000 +vti_filesize:IR|2523 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx.resx b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx.resx new file mode 100644 index 0000000..b47580e --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx.resx @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|06 Mar 2003 02:21:22 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|06 Mar 2003 02:21:22 -0000 +vti_filesize:IR|5318 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx.vb b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx.vb new file mode 100644 index 0000000..608ad67 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/MainForm.aspx.vb @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|06 Mar 2003 02:21:22 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|06 Mar 2003 02:21:22 -0000 +vti_filesize:IR|4032 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Styles.css b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Styles.css new file mode 100644 index 0000000..2e4709a --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Styles.css @@ -0,0 +1,8 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|01 Mar 2003 13:50:04 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|01 Mar 2003 13:50:04 -0000 +vti_filesize:IR|2855 +vti_cachedlinkinfo:VX| +vti_cachedsvcrellinks:VX| +vti_backlinkinfo:VX| diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Web.config b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Web.config new file mode 100644 index 0000000..85d89b1 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_cnf/Web.config @@ -0,0 +1,5 @@ +vti_encoding:SR|utf8-nl +vti_timelastmodified:TR|05 Mar 2003 00:13:21 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_cacheddtm:TX|05 Mar 2003 00:13:21 -0000 +vti_filesize:IR|4248 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/access.cnf b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/access.cnf new file mode 100644 index 0000000..7759afe --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/access.cnf @@ -0,0 +1,4 @@ +vti_encoding:SR|utf8-nl +RealmName:CHEETAH +InheritPermissions:true +PasswordDir:c:\\inetpub\\wwwroot\\_vti_pvt diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/deptodoc.btr b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/deptodoc.btr new file mode 100644 index 0000000..ea2724c Binary files /dev/null and b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/deptodoc.btr differ diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/doctodep.btr b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/doctodep.btr new file mode 100644 index 0000000..4b25c26 Binary files /dev/null and b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/doctodep.btr differ diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/linkinfo.cnf b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/linkinfo.cnf new file mode 100644 index 0000000..a48f168 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/linkinfo.cnf @@ -0,0 +1 @@ +vti_encoding:SR|utf8-nl diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/service.cnf b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/service.cnf new file mode 100644 index 0000000..227ea97 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/service.cnf @@ -0,0 +1,24 @@ +vti_encoding:SR|utf8-nl +vti_casesensitiveurls:IX|0 +vti_httpdversion:SX|Microsoft-IIS/5.0 +vti_textextensions:SX|.txt.actproj.asm.c.cc.cod.cpp.cs.cxx.dbs.def.dsp.dsw.etp.ext.fky.h.hpp.hxx.i.idl.inc.inl.kci.lgn.lst.mak.map.mk.odh.odl.prc.rc.rc2.rct.rgs.rul.s.sql.srf.tab.tlh.tli.trg.txt.udf.udt.user.usr.vap.vb.vcproj.viw.vspscc.vsscc.vssscc. +vti_featurelist:VX|vti_ACIPAddresses vti_ACCreateNewUsers vti_ACChangePassword vti_ACNoUserGroup vti_ACCreateNewGroups vti_ACModifyGroups vti_ServerEmailTransport +vti_dependenciesood:IR|0 +vti_webservertype:SR|msiis +vti_categories:VR|Travel Expense\\ Report Business Competition Goals/Objectives Ideas Miscellaneous Waiting VIP In\\ Process Planning Schedule +vti_textindexood:IR|0 +vti_htmlextensions:SX|.htm.html.htx.stm.stm.html.htm.shtml.shtm.htt.asp.alx.asa. +vti_approvallevels:VR|Content\\ Review Legal\\ Review Code\\ Review Manager\\ Review +vti_timecreated:TR|01 Mar 2003 13:49:55 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_longfilenames:IX|1 +vti_welcomenames:VX|Default.htm Default.asp iisstart.asp Default.aspx +vti_insecureserverurl:SR|http://CHEETAH +vti_secureserverurl:SR|https://CHEETAH +vti_disableautoimgsizeexts:SX|.asp +vti_oldestcompatibleversion:SR|2.0.0.0 +vti_restartmanual:IX|0 +vti_defaultcharset:SR|windows-1252 +vti_publishmetainfokeys:VR|vti_assignedto vti_approvallevel vti_categories vti_description +vti_hassearchbot:BR|false +vti_autorecalc:IX|1 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/service.lck b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/service.lck new file mode 100644 index 0000000..e69de29 diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/services.cnf b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/services.cnf new file mode 100644 index 0000000..b498fd4 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/services.cnf @@ -0,0 +1 @@ +/ diff --git a/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/writeto.cnf b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/writeto.cnf new file mode 100644 index 0000000..a48f168 --- /dev/null +++ b/Inetpub/wwwroot/AspNetDebugDemo_2002/_vti_pvt/writeto.cnf @@ -0,0 +1 @@ +vti_encoding:SR|utf8-nl diff --git a/Inetpub/wwwroot/TimeServer/AssemblyInfo.vb b/Inetpub/wwwroot/TimeServer/AssemblyInfo.vb new file mode 100644 index 0000000..a14f4f2 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Inetpub/wwwroot/TimeServer/Global.asax b/Inetpub/wwwroot/TimeServer/Global.asax new file mode 100644 index 0000000..ce277a3 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.vb" Inherits="TimeServer.Global" %> \ No newline at end of file diff --git a/Inetpub/wwwroot/TimeServer/Global.asax.resx b/Inetpub/wwwroot/TimeServer/Global.asax.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/Global.asax.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Inetpub/wwwroot/TimeServer/Global.asax.vb b/Inetpub/wwwroot/TimeServer/Global.asax.vb new file mode 100644 index 0000000..25e6587 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/Global.asax.vb @@ -0,0 +1,59 @@ +Imports System.Web +Imports System.Web.SessionState + +Public Class Global + Inherits System.Web.HttpApplication + +#Region " Component Designer Generated Code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +#End Region + + Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application is started + End Sub + + Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session is started + End Sub + + Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires at the beginning of each request + End Sub + + Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires upon attempting to authenticate the use + End Sub + + Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when an error occurs + End Sub + + Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session ends + End Sub + + Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application ends + End Sub + +End Class diff --git a/Inetpub/wwwroot/TimeServer/SoapMonitor.vb b/Inetpub/wwwroot/TimeServer/SoapMonitor.vb new file mode 100644 index 0000000..d2072be --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/SoapMonitor.vb @@ -0,0 +1,115 @@ +Option Strict On +Imports System.Web.Services.Protocols +Imports System.IO + +Public Class SoapMonitor : Inherits SoapExtension + + Private OldStream As Stream + Private NewStream As Stream + + Public Overloads Overrides Function GetInitializer(ByVal serviceType As System.Type) As Object + End Function + + Public Overloads Overrides Function GetInitializer(ByVal methodInfo As System.Web.Services.Protocols.LogicalMethodInfo, ByVal attribute As System.Web.Services.Protocols.SoapExtensionAttribute) As Object + End Function + + Public Overrides Sub Initialize(ByVal initializer As Object) + End Sub + + Public Overrides Sub ProcessMessage(ByVal Message As System.Web.Services.Protocols.SoapMessage) + 'Called after incoming or outgoing data + 'has been serialized into SOAP message + Dim Logfile As New FileStream("C:\test\test.log", FileMode.Append, FileAccess.Write) + Dim LogfileWriter As New StreamWriter(Logfile) + + Select Case Message.Stage + + Case SoapMessageStage.BeforeDeserialize + 'Write header details + With LogfileWriter + .WriteLine("******************************************************") + .WriteLine("Web service: " & Message.Url) + .WriteLine("Web method: " & Message.Action) + .WriteLine("Called at " & DateTime.Now) + .WriteLine("Message stage: SOAP REQUEST (" & Message.Stage.ToString & ")") + .WriteLine() + .Flush() + End With + 'Write incoming SOAP request message + CopyStream(OldStream, NewStream) + NewStream.Position = 0 + CopyStream(NewStream, Logfile) + NewStream.Position = 0 + 'Blank separating line + LogfileWriter.WriteLine() + + Case SoapMessageStage.AfterSerialize + 'Write header details + With LogfileWriter + .WriteLine("******************************************************") + .WriteLine("Web service: " & Message.Url) + .WriteLine("Web method: " & Message.Action) + .WriteLine("Called at " & DateTime.Now) + .WriteLine("Message stage: SOAP RESPONSE (" & Message.Stage.ToString & ")") + .Write("Exception thrown? ") + If Message.Exception Is Nothing Then + .WriteLine("No") + Else + .WriteLine("Yes") + End If + .WriteLine() + .Flush() + End With + 'Write outgoing SOAP response message + NewStream.Position = 0 + CopyStream(NewStream, Logfile) + NewStream.Position = 0 + CopyStream(NewStream, OldStream) + 'Blank separating line + LogfileWriter.WriteLine() + + End Select + + Logfile.Flush() + Logfile.Close() + + End Sub + + Public Overrides Function ChainStream(ByVal stream As System.IO.Stream) As System.IO.Stream + + OldStream = stream + NewStream = New MemoryStream + Return NewStream + + End Function + + Private Sub CopyStream(ByVal FromStream As Stream, ByVal ToStream As Stream) + Dim FromReader As TextReader = New StreamReader(FromStream) + Dim ToWriter As TextWriter = New StreamWriter(ToStream) + + ToWriter.WriteLine(FromReader.ReadToEnd) + ToWriter.Flush() + + End Sub + +End Class + +Public Class SoapMonitorAttribute : Inherits SoapExtensionAttribute + 'Add this custom attribute to any web method where you want + 'to monitor the SOAP request and response messages + + Public Overrides ReadOnly Property ExtensionType() As System.Type + Get + Return GetType(SoapMonitor) + End Get + End Property + + Public Overrides Property Priority() As Integer + Get + Return 0 + End Get + Set(ByVal Value As Integer) + End Set + End Property + +End Class \ No newline at end of file diff --git a/Inetpub/wwwroot/TimeServer/TimeServer.vbproj b/Inetpub/wwwroot/TimeServer/TimeServer.vbproj new file mode 100644 index 0000000..f683c18 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/TimeServer.vbproj @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/TimeServer/TimeServer.vbproj.webinfo b/Inetpub/wwwroot/TimeServer/TimeServer.vbproj.webinfo new file mode 100644 index 0000000..166ec16 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/TimeServer.vbproj.webinfo @@ -0,0 +1,4 @@ + + + + diff --git a/Inetpub/wwwroot/TimeServer/TimeService.asmx b/Inetpub/wwwroot/TimeServer/TimeService.asmx new file mode 100644 index 0000000..52307dc --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/TimeService.asmx @@ -0,0 +1 @@ +<%@ WebService Language="vb" Codebehind="TimeService.asmx.vb" Class="TimeServer.TimeService" %> diff --git a/Inetpub/wwwroot/TimeServer/TimeService.asmx.resx b/Inetpub/wwwroot/TimeServer/TimeService.asmx.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/TimeService.asmx.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Inetpub/wwwroot/TimeServer/TimeService.asmx.vb b/Inetpub/wwwroot/TimeServer/TimeService.asmx.vb new file mode 100644 index 0000000..5d4ff9a --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/TimeService.asmx.vb @@ -0,0 +1,125 @@ +Option Strict On + +Imports System.Xml +Imports System.Web.Services +Imports System.Web.Services.Protocols + + + _ +Public Class TimeService : Inherits System.Web.Services.WebService + +#Region " Web Services Designer Generated Code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Web Services Designer. + InitializeComponent() + + 'Add your own initialization code after the InitializeComponent() call + + End Sub + + 'Required by the Web Services Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Web Services Designer + 'It can be modified using the Web Services Designer. + 'Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container + End Sub + + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + 'CODEGEN: This procedure is required by the Web Services Designer + 'Do not modify it using the code editor. + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + +#End Region + + _ + Public Function CurrentTime() As String + Return System.DateTime.Now.ToLongTimeString + End Function + + _ + Public Sub ThrowExceptionRaw() + 'This method throws a raw exception + Dim Test As Object + Test.ToString() + + End Sub + + _ + Public Sub ThrowExceptionCustom() + 'This method throws a customized exception + Try + Dim Test As Object + Test.ToString() + Catch Exc As Exception + Throw CustomException(Exc) + End Try + + End Sub + + Private Function CustomException(ByVal Exc As Exception) As SoapException + Dim doc As New System.Xml.XmlDocument + + 'Create detail node + Dim DetailNode As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + SoapException.DetailElementName.Name, _ + SoapException.DetailElementName.Namespace) + + 'Add original exception type + Dim ExcType As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + "ExceptionType", _ + SoapException.DetailElementName.Namespace) + If Context.Request.UserHostAddress = "127.0.0.1" Then + ExcType.InnerText = Exc.GetType.ToString + Else + ExcType.InnerText = "SoapException" + End If + + 'Add original exception message + Dim ExcMessage As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + "ExceptionMessage", _ + SoapException.DetailElementName.Namespace) + If Context.Request.UserHostAddress = "127.0.0.1" Then + ExcMessage.InnerText = Exc.Message + Else + ExcMessage.InnerText = "Error - no details available" + End If + + 'Add original exception stack trace + Dim ExcStackTrace As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + "ExceptionTrace", _ + SoapException.DetailElementName.Namespace) + If Context.Request.UserHostAddress = "127.0.0.1" Then + ExcStackTrace.InnerText = Exc.StackTrace + Else + ExcStackTrace.InnerText = "No stack trace available" + End If + + 'Append the extra details to main detail node + DetailNode.AppendChild(ExcType) + DetailNode.AppendChild(ExcMessage) + DetailNode.AppendChild(ExcStackTrace) + + 'Return new custom SoapException + Return New SoapException("", SoapException.ServerFaultCode, _ + Context.Request.Url.AbsoluteUri, DetailNode) + + End Function + +End Class + diff --git a/Inetpub/wwwroot/TimeServer/Web.config b/Inetpub/wwwroot/TimeServer/Web.config new file mode 100644 index 0000000..f68fc1c --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/Web.config @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/TimeServer/_vti_pvt/access.cnf b/Inetpub/wwwroot/TimeServer/_vti_pvt/access.cnf new file mode 100644 index 0000000..7759afe --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/_vti_pvt/access.cnf @@ -0,0 +1,4 @@ +vti_encoding:SR|utf8-nl +RealmName:CHEETAH +InheritPermissions:true +PasswordDir:c:\\inetpub\\wwwroot\\_vti_pvt diff --git a/Inetpub/wwwroot/TimeServer/_vti_pvt/deptodoc.btr b/Inetpub/wwwroot/TimeServer/_vti_pvt/deptodoc.btr new file mode 100644 index 0000000..f157fe6 Binary files /dev/null and b/Inetpub/wwwroot/TimeServer/_vti_pvt/deptodoc.btr differ diff --git a/Inetpub/wwwroot/TimeServer/_vti_pvt/doctodep.btr b/Inetpub/wwwroot/TimeServer/_vti_pvt/doctodep.btr new file mode 100644 index 0000000..4b85379 Binary files /dev/null and b/Inetpub/wwwroot/TimeServer/_vti_pvt/doctodep.btr differ diff --git a/Inetpub/wwwroot/TimeServer/_vti_pvt/service.cnf b/Inetpub/wwwroot/TimeServer/_vti_pvt/service.cnf new file mode 100644 index 0000000..c839f1b --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/_vti_pvt/service.cnf @@ -0,0 +1,20 @@ +vti_encoding:SR|utf8-nl +vti_casesensitiveurls:IX|0 +vti_httpdversion:SX|Microsoft-IIS/5.0 +vti_textextensions:SX|.txt.actproj.asm.c.cc.cod.cpp.cs.cxx.dbs.def.dsp.dsw.etp.ext.fky.h.hpp.hxx.i.idl.inc.inl.kci.lgn.lst.mak.map.mk.odh.odl.prc.rc.rc2.rct.rgs.rul.s.sql.srf.tab.tlh.tli.trg.txt.udf.udt.user.usr.vap.vb.vcproj.viw.vspscc.vsscc.vssscc. +vti_featurelist:VX|vti_ACIPAddresses vti_ACCreateNewUsers vti_ACChangePassword vti_ACNoUserGroup vti_ACCreateNewGroups vti_ACModifyGroups vti_ServiceMarkUrlDirExec vti_ServerEmailTransport +vti_dependenciesood:IR|0 +vti_webservertype:SR|msiis +vti_publishmetainfokeys:VR|vti_assignedto vti_approvallevel vti_categories vti_description +vti_categories:VR|Travel Expense\\ Report Business Competition Goals/Objectives Ideas Miscellaneous Waiting VIP In\\ Process Planning Schedule +vti_htmlextensions:SX|.htm.html.htx.stm.stm.html.htm.shtml.shtm.htt.asp.alx.asa. +vti_approvallevels:VR|Content\\ Review Legal\\ Review Code\\ Review Manager\\ Review +vti_timecreated:TR|30 Oct 2002 21:11:23 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_longfilenames:IX|1 +vti_welcomenames:VX|Default.htm Default.asp iisstart.asp Default.aspx +vti_insecureserverurl:SR|http://localhost +vti_secureserverurl:SR|https://localhost +vti_disableautoimgsizeexts:SX|.asp +vti_oldestcompatibleversion:SR|2.0.0.0 +vti_restartmanual:IX|0 diff --git a/Inetpub/wwwroot/TimeServer/_vti_pvt/service.lck b/Inetpub/wwwroot/TimeServer/_vti_pvt/service.lck new file mode 100644 index 0000000..e69de29 diff --git a/Inetpub/wwwroot/TimeServer/_vti_pvt/services.cnf b/Inetpub/wwwroot/TimeServer/_vti_pvt/services.cnf new file mode 100644 index 0000000..b498fd4 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer/_vti_pvt/services.cnf @@ -0,0 +1 @@ +/ diff --git a/Inetpub/wwwroot/TimeServer/bin/TimeServer.dll b/Inetpub/wwwroot/TimeServer/bin/TimeServer.dll new file mode 100644 index 0000000..4e14a4b Binary files /dev/null and b/Inetpub/wwwroot/TimeServer/bin/TimeServer.dll differ diff --git a/Inetpub/wwwroot/TimeServer/bin/TimeServer.pdb b/Inetpub/wwwroot/TimeServer/bin/TimeServer.pdb new file mode 100644 index 0000000..a413a5f Binary files /dev/null and b/Inetpub/wwwroot/TimeServer/bin/TimeServer.pdb differ diff --git a/Inetpub/wwwroot/TimeServer_2002/AssemblyInfo.vb b/Inetpub/wwwroot/TimeServer_2002/AssemblyInfo.vb new file mode 100644 index 0000000..a14f4f2 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Inetpub/wwwroot/TimeServer_2002/Global.asax b/Inetpub/wwwroot/TimeServer_2002/Global.asax new file mode 100644 index 0000000..ce277a3 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/Global.asax @@ -0,0 +1 @@ +<%@ Application Codebehind="Global.asax.vb" Inherits="TimeServer.Global" %> \ No newline at end of file diff --git a/Inetpub/wwwroot/TimeServer_2002/Global.asax.resx b/Inetpub/wwwroot/TimeServer_2002/Global.asax.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/Global.asax.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Inetpub/wwwroot/TimeServer_2002/Global.asax.vb b/Inetpub/wwwroot/TimeServer_2002/Global.asax.vb new file mode 100644 index 0000000..25e6587 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/Global.asax.vb @@ -0,0 +1,59 @@ +Imports System.Web +Imports System.Web.SessionState + +Public Class Global + Inherits System.Web.HttpApplication + +#Region " Component Designer Generated Code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + End Sub + +#End Region + + Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application is started + End Sub + + Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session is started + End Sub + + Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires at the beginning of each request + End Sub + + Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs) + ' Fires upon attempting to authenticate the use + End Sub + + Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when an error occurs + End Sub + + Sub Session_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the session ends + End Sub + + Sub Application_End(ByVal sender As Object, ByVal e As EventArgs) + ' Fires when the application ends + End Sub + +End Class diff --git a/Inetpub/wwwroot/TimeServer_2002/SoapMonitor.vb b/Inetpub/wwwroot/TimeServer_2002/SoapMonitor.vb new file mode 100644 index 0000000..d2072be --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/SoapMonitor.vb @@ -0,0 +1,115 @@ +Option Strict On +Imports System.Web.Services.Protocols +Imports System.IO + +Public Class SoapMonitor : Inherits SoapExtension + + Private OldStream As Stream + Private NewStream As Stream + + Public Overloads Overrides Function GetInitializer(ByVal serviceType As System.Type) As Object + End Function + + Public Overloads Overrides Function GetInitializer(ByVal methodInfo As System.Web.Services.Protocols.LogicalMethodInfo, ByVal attribute As System.Web.Services.Protocols.SoapExtensionAttribute) As Object + End Function + + Public Overrides Sub Initialize(ByVal initializer As Object) + End Sub + + Public Overrides Sub ProcessMessage(ByVal Message As System.Web.Services.Protocols.SoapMessage) + 'Called after incoming or outgoing data + 'has been serialized into SOAP message + Dim Logfile As New FileStream("C:\test\test.log", FileMode.Append, FileAccess.Write) + Dim LogfileWriter As New StreamWriter(Logfile) + + Select Case Message.Stage + + Case SoapMessageStage.BeforeDeserialize + 'Write header details + With LogfileWriter + .WriteLine("******************************************************") + .WriteLine("Web service: " & Message.Url) + .WriteLine("Web method: " & Message.Action) + .WriteLine("Called at " & DateTime.Now) + .WriteLine("Message stage: SOAP REQUEST (" & Message.Stage.ToString & ")") + .WriteLine() + .Flush() + End With + 'Write incoming SOAP request message + CopyStream(OldStream, NewStream) + NewStream.Position = 0 + CopyStream(NewStream, Logfile) + NewStream.Position = 0 + 'Blank separating line + LogfileWriter.WriteLine() + + Case SoapMessageStage.AfterSerialize + 'Write header details + With LogfileWriter + .WriteLine("******************************************************") + .WriteLine("Web service: " & Message.Url) + .WriteLine("Web method: " & Message.Action) + .WriteLine("Called at " & DateTime.Now) + .WriteLine("Message stage: SOAP RESPONSE (" & Message.Stage.ToString & ")") + .Write("Exception thrown? ") + If Message.Exception Is Nothing Then + .WriteLine("No") + Else + .WriteLine("Yes") + End If + .WriteLine() + .Flush() + End With + 'Write outgoing SOAP response message + NewStream.Position = 0 + CopyStream(NewStream, Logfile) + NewStream.Position = 0 + CopyStream(NewStream, OldStream) + 'Blank separating line + LogfileWriter.WriteLine() + + End Select + + Logfile.Flush() + Logfile.Close() + + End Sub + + Public Overrides Function ChainStream(ByVal stream As System.IO.Stream) As System.IO.Stream + + OldStream = stream + NewStream = New MemoryStream + Return NewStream + + End Function + + Private Sub CopyStream(ByVal FromStream As Stream, ByVal ToStream As Stream) + Dim FromReader As TextReader = New StreamReader(FromStream) + Dim ToWriter As TextWriter = New StreamWriter(ToStream) + + ToWriter.WriteLine(FromReader.ReadToEnd) + ToWriter.Flush() + + End Sub + +End Class + +Public Class SoapMonitorAttribute : Inherits SoapExtensionAttribute + 'Add this custom attribute to any web method where you want + 'to monitor the SOAP request and response messages + + Public Overrides ReadOnly Property ExtensionType() As System.Type + Get + Return GetType(SoapMonitor) + End Get + End Property + + Public Overrides Property Priority() As Integer + Get + Return 0 + End Get + Set(ByVal Value As Integer) + End Set + End Property + +End Class \ No newline at end of file diff --git a/Inetpub/wwwroot/TimeServer_2002/TimeServer.vbproj b/Inetpub/wwwroot/TimeServer_2002/TimeServer.vbproj new file mode 100644 index 0000000..bbd96cb --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/TimeServer.vbproj @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/TimeServer_2002/TimeServer.vbproj.webinfo b/Inetpub/wwwroot/TimeServer_2002/TimeServer.vbproj.webinfo new file mode 100644 index 0000000..7812035 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/TimeServer.vbproj.webinfo @@ -0,0 +1,4 @@ + + + + diff --git a/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx b/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx new file mode 100644 index 0000000..52307dc --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx @@ -0,0 +1 @@ +<%@ WebService Language="vb" Codebehind="TimeService.asmx.vb" Class="TimeServer.TimeService" %> diff --git a/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx.resx b/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx.resx new file mode 100644 index 0000000..3f337e0 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx.vb b/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx.vb new file mode 100644 index 0000000..5d4ff9a --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/TimeService.asmx.vb @@ -0,0 +1,125 @@ +Option Strict On + +Imports System.Xml +Imports System.Web.Services +Imports System.Web.Services.Protocols + + + _ +Public Class TimeService : Inherits System.Web.Services.WebService + +#Region " Web Services Designer Generated Code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Web Services Designer. + InitializeComponent() + + 'Add your own initialization code after the InitializeComponent() call + + End Sub + + 'Required by the Web Services Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Web Services Designer + 'It can be modified using the Web Services Designer. + 'Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container + End Sub + + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + 'CODEGEN: This procedure is required by the Web Services Designer + 'Do not modify it using the code editor. + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + +#End Region + + _ + Public Function CurrentTime() As String + Return System.DateTime.Now.ToLongTimeString + End Function + + _ + Public Sub ThrowExceptionRaw() + 'This method throws a raw exception + Dim Test As Object + Test.ToString() + + End Sub + + _ + Public Sub ThrowExceptionCustom() + 'This method throws a customized exception + Try + Dim Test As Object + Test.ToString() + Catch Exc As Exception + Throw CustomException(Exc) + End Try + + End Sub + + Private Function CustomException(ByVal Exc As Exception) As SoapException + Dim doc As New System.Xml.XmlDocument + + 'Create detail node + Dim DetailNode As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + SoapException.DetailElementName.Name, _ + SoapException.DetailElementName.Namespace) + + 'Add original exception type + Dim ExcType As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + "ExceptionType", _ + SoapException.DetailElementName.Namespace) + If Context.Request.UserHostAddress = "127.0.0.1" Then + ExcType.InnerText = Exc.GetType.ToString + Else + ExcType.InnerText = "SoapException" + End If + + 'Add original exception message + Dim ExcMessage As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + "ExceptionMessage", _ + SoapException.DetailElementName.Namespace) + If Context.Request.UserHostAddress = "127.0.0.1" Then + ExcMessage.InnerText = Exc.Message + Else + ExcMessage.InnerText = "Error - no details available" + End If + + 'Add original exception stack trace + Dim ExcStackTrace As System.Xml.XmlNode = _ + doc.CreateNode(XmlNodeType.Element, _ + "ExceptionTrace", _ + SoapException.DetailElementName.Namespace) + If Context.Request.UserHostAddress = "127.0.0.1" Then + ExcStackTrace.InnerText = Exc.StackTrace + Else + ExcStackTrace.InnerText = "No stack trace available" + End If + + 'Append the extra details to main detail node + DetailNode.AppendChild(ExcType) + DetailNode.AppendChild(ExcMessage) + DetailNode.AppendChild(ExcStackTrace) + + 'Return new custom SoapException + Return New SoapException("", SoapException.ServerFaultCode, _ + Context.Request.Url.AbsoluteUri, DetailNode) + + End Function + +End Class + diff --git a/Inetpub/wwwroot/TimeServer_2002/Web.config b/Inetpub/wwwroot/TimeServer_2002/Web.config new file mode 100644 index 0000000..f68fc1c --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/Web.config @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/access.cnf b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/access.cnf new file mode 100644 index 0000000..7759afe --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/access.cnf @@ -0,0 +1,4 @@ +vti_encoding:SR|utf8-nl +RealmName:CHEETAH +InheritPermissions:true +PasswordDir:c:\\inetpub\\wwwroot\\_vti_pvt diff --git a/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/deptodoc.btr b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/deptodoc.btr new file mode 100644 index 0000000..f157fe6 Binary files /dev/null and b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/deptodoc.btr differ diff --git a/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/doctodep.btr b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/doctodep.btr new file mode 100644 index 0000000..4b85379 Binary files /dev/null and b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/doctodep.btr differ diff --git a/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/service.cnf b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/service.cnf new file mode 100644 index 0000000..c839f1b --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/service.cnf @@ -0,0 +1,20 @@ +vti_encoding:SR|utf8-nl +vti_casesensitiveurls:IX|0 +vti_httpdversion:SX|Microsoft-IIS/5.0 +vti_textextensions:SX|.txt.actproj.asm.c.cc.cod.cpp.cs.cxx.dbs.def.dsp.dsw.etp.ext.fky.h.hpp.hxx.i.idl.inc.inl.kci.lgn.lst.mak.map.mk.odh.odl.prc.rc.rc2.rct.rgs.rul.s.sql.srf.tab.tlh.tli.trg.txt.udf.udt.user.usr.vap.vb.vcproj.viw.vspscc.vsscc.vssscc. +vti_featurelist:VX|vti_ACIPAddresses vti_ACCreateNewUsers vti_ACChangePassword vti_ACNoUserGroup vti_ACCreateNewGroups vti_ACModifyGroups vti_ServiceMarkUrlDirExec vti_ServerEmailTransport +vti_dependenciesood:IR|0 +vti_webservertype:SR|msiis +vti_publishmetainfokeys:VR|vti_assignedto vti_approvallevel vti_categories vti_description +vti_categories:VR|Travel Expense\\ Report Business Competition Goals/Objectives Ideas Miscellaneous Waiting VIP In\\ Process Planning Schedule +vti_htmlextensions:SX|.htm.html.htx.stm.stm.html.htm.shtml.shtm.htt.asp.alx.asa. +vti_approvallevels:VR|Content\\ Review Legal\\ Review Code\\ Review Manager\\ Review +vti_timecreated:TR|30 Oct 2002 21:11:23 -0000 +vti_extenderversion:SR|4.0.2.5526 +vti_longfilenames:IX|1 +vti_welcomenames:VX|Default.htm Default.asp iisstart.asp Default.aspx +vti_insecureserverurl:SR|http://localhost +vti_secureserverurl:SR|https://localhost +vti_disableautoimgsizeexts:SX|.asp +vti_oldestcompatibleversion:SR|2.0.0.0 +vti_restartmanual:IX|0 diff --git a/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/service.lck b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/service.lck new file mode 100644 index 0000000..e69de29 diff --git a/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/services.cnf b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/services.cnf new file mode 100644 index 0000000..b498fd4 --- /dev/null +++ b/Inetpub/wwwroot/TimeServer_2002/_vti_pvt/services.cnf @@ -0,0 +1 @@ +/ diff --git a/Inetpub/wwwroot/TimeServer_2002/bin/TimeServer.dll b/Inetpub/wwwroot/TimeServer_2002/bin/TimeServer.dll new file mode 100644 index 0000000..ef2b653 Binary files /dev/null and b/Inetpub/wwwroot/TimeServer_2002/bin/TimeServer.dll differ diff --git a/Inetpub/wwwroot/TimeServer_2002/bin/TimeServer.pdb b/Inetpub/wwwroot/TimeServer_2002/bin/TimeServer.pdb new file mode 100644 index 0000000..8a30782 Binary files /dev/null and b/Inetpub/wwwroot/TimeServer_2002/bin/TimeServer.pdb differ diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..2b70bf8 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,27 @@ +Freeware License, some rights reserved + +Copyright (c) 2003 Mark Pearce + +Permission is hereby granted, free of charge, to anyone obtaining a copy +of this software and associated documentation files (the "Software"), +to work with the Software within the limits of freeware distribution and fair use. +This includes the rights to use, copy, and modify the Software for personal use. +Users are also allowed and encouraged to submit corrections and modifications +to the Software for the benefit of other users. + +It is not allowed to reuse, modify, or redistribute the Software for +commercial use in any way, or for a user’s educational materials such as books +or blog articles without prior permission from the copyright holder. + +The above copyright notice and this permission notice need to be included +in all copies or substantial portions of the software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS OR APRESS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + diff --git a/README.md b/README.md new file mode 100644 index 0000000..9869824 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +#Apress Source Code + +This repository accompanies [*Comprehensive VB .NET Debugging*](http://www.apress.com/9781590590508) by Mark Pearce (Apress, 2003). + +![Cover image](9781590590508.jpg) + +Download the files as a zip using the green button, or clone the repository to your machine using Git. + +##Releases + +Release v1.0 corresponds to the code in the published book, without corrections or updates. + +##Contributions + +See the file Contributing.md for more information on how you can contribute to this repository. diff --git a/Source/Changes.txt b/Source/Changes.txt new file mode 100644 index 0000000..e69de29 diff --git a/Source/ReadMe.txt b/Source/ReadMe.txt new file mode 100644 index 0000000..abb4833 --- /dev/null +++ b/Source/ReadMe.txt @@ -0,0 +1,43 @@ +Welcome! +-------- +This zip file contains the source code for my book "Comprehensive VB .NET Debugging". + +The sample code provided has been tested using the last RC of Visual Studio 2003 and version 1.1 of the .NET Framework. It has also been tested using Visual Studio 2002 and version 1.0 of the .NET Framework. + + +-------------------------- +To extract the source code +-------------------------- +Use any zip program - be sure to specify that you wish to preserve the directory structure when you unzip the files. + + +----------------- +File organization +----------------- +The source code for each sample can be found in the VisualStudio####\Source\Chapter## sub-folder, where #### is the version of Visual Studio and ## is the number of the chapter. + +To conserve space, only source files are provided. You can create the binaries by loading the solution files into Visual Studio and building the applications. + +Some folders contain ReadMe.txt files that contain additional information about building that particular example. + + +------------------------------ +Visual Studio 2002 versus 2003 +------------------------------ +You'll notice that all of the code is duplicated under subfolders for Visual Studio 2002 (with .NET Framework 1.0) and Visual Studio 2003 (with .NET Framework 1.1). This is to allow you to open each sample solution using either Visual Studio 2002 or Visual Studio 2003. This approach is necessary because it's quite likely that many readers might not yet have upgraded to Visual Studio 2003, and unfortunately Microsoft decided to make Visual Studio 2003 solutions incompatible with Visual Studio 2002. + +So to load a solution into Visual Studio 2003 and have it use version 1.1 of the .NET Framework, use the solution contained under the "VisualStudio2003" folder. + +To load the same solution into Visual Studio 2002 and have it use version 1.0 of the .NET Framework, use the solution contained under the "VisualStudio2002" folder. + + +---------------- +Web applications +---------------- +Please read the individual ReadMe.txt files contained in their respective folders for important information on creating and configuring the web applications discussed in chapters 8 and 9 of this book. + + +------- +Changes +------- +Changes and corrections from the print edition of the book can be found in the file Changes.txt. diff --git a/Source/VisualStudio2002/Chapter02/Listing2-1/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-1/AssemblyInfo.vb new file mode 100644 index 0000000..a30ae2c --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-1/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.sln b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.sln new file mode 100644 index 0000000..050d62b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-1", "Listing2-1.vbproj", "{31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Debug.ActiveCfg = Debug|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Debug.Build.0 = Debug|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Release.ActiveCfg = Release|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.suo b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.suo new file mode 100644 index 0000000..b46947f Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.vbproj new file mode 100644 index 0000000..a0dd709 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-1/Listing2-1.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-1/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-1/Test.vb new file mode 100644 index 0000000..4482e2a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-1/Test.vb @@ -0,0 +1,10 @@ +Option Strict On +Module Test + + Sub Main() + Console.WriteLine("CInt(True) = " + CInt(True).ToString) + Console.WriteLine("Convert(True) = " + Convert.ToInt16(True).ToString) + Console.ReadLine() + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter02/Listing2-10/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-10/AssemblyInfo.vb new file mode 100644 index 0000000..e112cff --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-10/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.sln b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.sln new file mode 100644 index 0000000..001af0f --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-10", "Listing2-10.vbproj", "{EF22FDFF-8665-44CF-BADC-362A5663C0C1}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Debug.ActiveCfg = Debug|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Debug.Build.0 = Debug|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Release.ActiveCfg = Release|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.suo b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.suo new file mode 100644 index 0000000..60f7581 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.vbproj new file mode 100644 index 0000000..16ca548 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-10/Listing2-10.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-10/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-10/Test.vb new file mode 100644 index 0000000..f8167fa --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-10/Test.vb @@ -0,0 +1,75 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Overrides Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + + 'This overload doesn't work for a subtle reason + ' Overloads Function Equals(ByVal AnyCat As Cat) As Boolean + ' Return True + ' End Function + + 'This overload works + Overloads Overrides Function Equals(ByVal Obj As Object) As Boolean + If Object.ReferenceEquals(Obj.GetType, New Cat().GetType) Then + Return True + Else + Return MyBase.Equals(Obj) + End If + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-11/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-11/AssemblyInfo.vb new file mode 100644 index 0000000..6b2d11e --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-11/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.sln b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.sln new file mode 100644 index 0000000..8172cdc --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-11", "Listing2-11.vbproj", "{0A591B27-8004-4912-A3B5-30B98AB99CBD}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Debug.ActiveCfg = Debug|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Debug.Build.0 = Debug|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Release.ActiveCfg = Release|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.suo b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.suo new file mode 100644 index 0000000..eaf6a2b Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.vbproj new file mode 100644 index 0000000..814b122 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-11/Listing2-11.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-11/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-11/Test.vb new file mode 100644 index 0000000..59ebfd6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-11/Test.vb @@ -0,0 +1,46 @@ +Option Strict On + +Class Animal + + Public Shared Sub Main() + + Dim objMan As New Man() + Dim objFeline As New Feline(), objCat As New Cat() + + Console.WriteLine(objMan.ClassName("This Man")) + Console.WriteLine(objFeline.ClassName("This Feline")) + Console.WriteLine(objCat.ClassName("This Cat")) + + Console.ReadLine() + + End Sub + + Protected Overridable Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be an Animal" + End Function + +End Class + +Class Man : Inherits Animal + + Protected Overrides Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be a Man" + End Function + +End Class + +Class Feline : Inherits Animal + + Protected Overridable Shadows Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be a Feline" + End Function + +End Class + +Class Cat : Inherits Feline + + Protected Overrides Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be a Cat" + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-12/AssemblyInfo.vb new file mode 100644 index 0000000..0b31830 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.sln b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.sln new file mode 100644 index 0000000..0e6cd83 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-12", "Listing2-12.vbproj", "{F7816CB3-4B61-46D1-9241-1846A926DF73}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Debug.ActiveCfg = Debug|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Debug.Build.0 = Debug|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Release.ActiveCfg = Release|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.suo b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.suo new file mode 100644 index 0000000..b780328 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.vbproj new file mode 100644 index 0000000..86d9417 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12/Listing2-12.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-12/Test.vb new file mode 100644 index 0000000..900e2ae --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12/Test.vb @@ -0,0 +1,32 @@ +Option Strict On + +Class Test + + Shared Sub Main() + Dim objDerived As New Derived() + Console.WriteLine(objDerived.ClassName()) + Console.WriteLine(objDerived.BaseName()) + Console.ReadLine() + End Sub + +End Class + +Class Base + + Public Overridable Function ClassName() As String + Return MyClass.ToString + End Function + +End Class + +Class Derived : Inherits Base + + Public Overrides Function ClassName() As String + Return MyClass.ToString + End Function + + Public Function BaseName() As String + Return MyBase.ClassName() + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/AssemblyInfo.vb new file mode 100644 index 0000000..0dcf904 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln new file mode 100644 index 0000000..1b14374 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-12Stackframe", "Listing2-12Stackframe.vbproj", "{1CFE5D0F-986E-4E1C-A72A-A210B05D289F}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Debug.ActiveCfg = Debug|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Debug.Build.0 = Debug|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Release.ActiveCfg = Release|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.suo b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.suo new file mode 100644 index 0000000..35ac77d Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj new file mode 100644 index 0000000..b5d5c71 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Test.vb new file mode 100644 index 0000000..3bc515a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-12Stackframe/Test.vb @@ -0,0 +1,37 @@ +Class Test + + Public Shared Sub Main() + Dim objDerived As New Derived(), objBase As New Base() + Console.WriteLine(objDerived.ClassName()) + Console.WriteLine(objDerived.BaseName()) + Console.ReadLine() + End Sub + + Public Shared Function ImmediateClassName() As String + Dim objStackFrame As New Diagnostics.StackFrame(1) + Return objStackFrame.GetMethod.DeclaringType.FullName + End Function + +End Class + +Class Base + + Public Overridable Function ClassName() As String + 'Return MyClass.ToString + Return Test.ImmediateClassName + End Function + +End Class + +Class Derived : Inherits Base + + Public Overrides Function ClassName() As String + 'Return MyClass.ToString + Return Test.ImmediateClassName + End Function + + Public Function BaseName() As String + Return MyBase.ClassName() + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-18/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-18/AssemblyInfo.vb new file mode 100644 index 0000000..7a043b5 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-18/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.sln b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.sln new file mode 100644 index 0000000..8a6e7be --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-18", "Listing2-18.vbproj", "{4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Debug.ActiveCfg = Debug|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Debug.Build.0 = Debug|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Release.ActiveCfg = Release|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.suo b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.suo new file mode 100644 index 0000000..b94e53a Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.vbproj new file mode 100644 index 0000000..b55281e --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-18/Listing2-18.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-18/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-18/Test.vb new file mode 100644 index 0000000..b50b6ca --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-18/Test.vb @@ -0,0 +1,32 @@ +Option Strict Off + +Module Test + + Sub Main() + + Console.WriteLine("Developer sees: " & WhatDeveloperSees.ToString) + Console.WriteLine("Compiler says: " & WhatCompilerSees.ToString) + Console.ReadLine() + + End Sub + + Function WhatDeveloperWrites() As Integer + Dim A As Integer = 0, B As Integer = 1, C As Integer = 2 + A = B = C + Return A + End Function + + Function WhatDeveloperSees() As Integer + Dim A As Integer = 0, B As Integer = 1, C As Integer = 2 + B = C + A = B + Return A + End Function + + Function WhatCompilerSees() As Integer + Dim A As Integer = 0, B As Integer = 1, C As Integer = 2 + A = CInt(CBool(B = C)) + Return A + End Function + +End Module diff --git a/Source/VisualStudio2002/Chapter02/Listing2-2/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-2/AssemblyInfo.vb new file mode 100644 index 0000000..ed6a10b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-2/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.sln b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.sln new file mode 100644 index 0000000..d8a367b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-2", "Listing2-2.vbproj", "{19A44278-676F-492D-8EB2-7C47C9EEDDDE}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Debug.ActiveCfg = Debug|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Debug.Build.0 = Debug|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Release.ActiveCfg = Release|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.suo b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.suo new file mode 100644 index 0000000..ee754ed Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.vbproj new file mode 100644 index 0000000..6211e15 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-2/Listing2-2.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-2/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-2/Test.vb new file mode 100644 index 0000000..642f4fb --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-2/Test.vb @@ -0,0 +1,35 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + Dim objMyTest As New Derived() + With objMyTest + .WriteLine(10) + .WriteLine(10.5) + .WriteLine("11") + End With + Console.ReadLine() + End Sub + +End Class + +Class Base + + Public Sub WriteLine(ByVal AnyString As String) + Console.WriteLine(AnyString + " called Base:String") + End Sub + + Public Sub WriteLine(ByVal AnyInteger As Integer) + Console.WriteLine(AnyInteger.ToString + " called Base:Integer") + End Sub + +End Class + +Class Derived : Inherits Base + + Public Overloads Sub WriteLine(ByVal AnyDouble As Double) + Console.WriteLine(AnyDouble.ToString + " called Derived:Double") + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/App.ico b/Source/VisualStudio2002/Chapter02/Listing2-21/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-21/App.ico differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/AssemblyInfo.cs b/Source/VisualStudio2002/Chapter02/Listing2-21/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-21/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.csproj b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.csproj new file mode 100644 index 0000000..22008bb --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.csproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.csproj.user b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.csproj.user new file mode 100644 index 0000000..e1f4628 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.sln b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.sln new file mode 100644 index 0000000..3f6c9f3 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-21", "Listing2-21.csproj", "{4A3E4205-AC32-4528-BAA8-9A29F869DB90}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Debug.ActiveCfg = Debug|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Debug.Build.0 = Debug|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Release.ActiveCfg = Release|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.suo b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.suo new file mode 100644 index 0000000..7cb9849 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-21/Listing2-21.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/Test.cs b/Source/VisualStudio2002/Chapter02/Listing2-21/Test.cs new file mode 100644 index 0000000..59f688d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-21/Test.cs @@ -0,0 +1,10 @@ +class Test + { + public static void Main() + { + int A = 0; int B = 1; int C = 2; + A = B = C; + System.Console.WriteLine("Developer and compiler both see: " + A); + System.Console.ReadLine(); + } + } diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/obj/Debug/Listing2-21.exe.incr b/Source/VisualStudio2002/Chapter02/Listing2-21/obj/Debug/Listing2-21.exe.incr new file mode 100644 index 0000000..5e28457 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-21/obj/Debug/Listing2-21.exe.incr differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-21/obj/Debug/Listing2-21.projdata b/Source/VisualStudio2002/Chapter02/Listing2-21/obj/Debug/Listing2-21.projdata new file mode 100644 index 0000000..ac541ef Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-21/obj/Debug/Listing2-21.projdata differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-23/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-23/AssemblyInfo.vb new file mode 100644 index 0000000..92cb0fe --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-23/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.sln b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.sln new file mode 100644 index 0000000..8da8d1a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-23", "Listing2-23.vbproj", "{A32A373F-CB08-48F6-80B2-5C6C0671BB58}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Debug.ActiveCfg = Debug|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Debug.Build.0 = Debug|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Release.ActiveCfg = Release|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.suo b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.suo new file mode 100644 index 0000000..1810824 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.vbproj new file mode 100644 index 0000000..0553928 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-23/Listing2-23.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-23/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-23/Test.vb new file mode 100644 index 0000000..cb46568 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-23/Test.vb @@ -0,0 +1,23 @@ +Option Strict On + +Module BoxingTest + + Sub Main() + Dim MyBoolean As Boolean = False + Dim MyObject As Object = False + + SwitchBoolean(CType(MyBoolean, Boolean)) + Console.WriteLine("MyBoolean = " & MyBoolean.ToString) + + SwitchBoolean(MyObject) + Console.WriteLine("MyObject = " & MyObject.ToString) + + Console.ReadLine() + + End Sub + + Private Sub SwitchBoolean(ByRef TestBoolean As Object) + TestBoolean = True + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter02/Listing2-24/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-24/AssemblyInfo.vb new file mode 100644 index 0000000..c10371f --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-24/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.sln b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.sln new file mode 100644 index 0000000..cfcc213 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-24", "Listing2-24.vbproj", "{9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Debug.ActiveCfg = Debug|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Debug.Build.0 = Debug|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Release.ActiveCfg = Release|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.suo b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.suo new file mode 100644 index 0000000..18ff258 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.vbproj new file mode 100644 index 0000000..55af9a8 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-24/Listing2-24.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-24/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-24/Test.vb new file mode 100644 index 0000000..ed87459 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-24/Test.vb @@ -0,0 +1,107 @@ +Option Strict On + +Module Test + + Sub Main() + Dim intTest As Integer, dblTest As Double + Dim intZero As Integer = 0, blnExceptionThrown As Boolean = False + + 'First test + Console.WriteLine("Integer division by zero assigned to integer:") + blnExceptionThrown = False + Try + intTest = 5 \ intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + intTest.ToString) + End If + Console.WriteLine() + End Try + + 'Second test + Console.WriteLine("Integer division by zero assigned to double:") + blnExceptionThrown = False + Try + dblTest = 5 \ intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + dblTest.ToString) + End If + Console.WriteLine() + End Try + + 'Third test + Console.WriteLine("Float division by zero assigned to integer:") + blnExceptionThrown = False + Try + intTest = CInt(5 / intZero) + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + intTest.ToString) + End If + Console.WriteLine() + End Try + + 'Fourth test + Console.WriteLine("Float division by zero assigned to double:") + blnExceptionThrown = False + Try + dblTest = 5 / intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + dblTest.ToString) + Console.WriteLine("Is infinity: " + CStr(Double.IsInfinity(dblTest))) + Console.WriteLine("Is not a number: " + CStr(Double.IsNaN(dblTest))) + End If + Console.WriteLine() + End Try + + 'Fifth test + Console.WriteLine("Float division of zero by zero assigned to double:") + blnExceptionThrown = False + Try + dblTest = intZero / intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + dblTest.ToString) + Console.WriteLine("Is infinity: " + CStr(Double.IsInfinity(dblTest))) + Console.WriteLine("Is not a number: " + CStr(Double.IsNaN(dblTest))) + End If + Console.WriteLine() + End Try + + Console.ReadLine() + + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter02/Listing2-25/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-25/AssemblyInfo.vb new file mode 100644 index 0000000..84c17c4 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-25/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.sln b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.sln new file mode 100644 index 0000000..82d6b70 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-25", "Listing2-25.vbproj", "{A67EAD24-F695-4109-A756-A2E90EAA7FC8}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Debug.ActiveCfg = Debug|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Debug.Build.0 = Debug|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Release.ActiveCfg = Release|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.suo b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.suo new file mode 100644 index 0000000..5acfc3c Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.vbproj new file mode 100644 index 0000000..e254014 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-25/Listing2-25.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-25/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-25/Test.vb new file mode 100644 index 0000000..17f8202 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-25/Test.vb @@ -0,0 +1,19 @@ +Option Strict On + +Module Test + + Sub Main() + + Console.WriteLine(Single.NaN = Single.NaN) + Console.WriteLine((Single.NaN - Single.NaN) = 0) + + Console.WriteLine(Single.PositiveInfinity = Single.PositiveInfinity) + Console.WriteLine((Single.PositiveInfinity - Single.PositiveInfinity) = 0) + + Console.WriteLine(1.0 < Single.NaN) + Console.WriteLine(1.0 >= Single.NaN) + Console.ReadLine() + + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter02/Listing2-26/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-26/AssemblyInfo.vb new file mode 100644 index 0000000..001c7ee --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-26/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.sln b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.sln new file mode 100644 index 0000000..d11ea21 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-26", "Listing2-26.vbproj", "{DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Debug.ActiveCfg = Debug|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Debug.Build.0 = Debug|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Release.ActiveCfg = Release|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.suo b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.suo new file mode 100644 index 0000000..352a558 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.vbproj new file mode 100644 index 0000000..faafda0 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-26/Listing2-26.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-26/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-26/Test.vb new file mode 100644 index 0000000..cd14f55 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-26/Test.vb @@ -0,0 +1,33 @@ +Option Strict On + +Module Test + + Sub Main() + + Try + Console.WriteLine(CalcTotalOne(Single.NaN)) + Console.WriteLine(CalcTotalTwo(Single.NaN)) + Catch ex As Exception + Console.WriteLine(ex.Message) + Finally + Console.ReadLine() + End Try + + End Sub + + Function CalcTotalOne(ByVal PurchaseAmount As Single) As Single + If PurchaseAmount < 0.0 Then + Throw New ArgumentException("PurchaseAmount must be >= zero") + End If + Return PurchaseAmount * 1.08F + End Function + + Function CalcTotalTwo(ByVal PurchaseAmount As Single) As Single + If PurchaseAmount >= 0.0 Then + Return PurchaseAmount * 1.08F + Else + Throw New ArgumentException("PurchaseAmount must be >= zero") + End If + End Function + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter02/Listing2-27/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-27/AssemblyInfo.vb new file mode 100644 index 0000000..8f8910b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-27/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.sln b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.sln new file mode 100644 index 0000000..6c4f1e3 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-27", "Listing2-27.vbproj", "{32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Debug.ActiveCfg = Debug|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Debug.Build.0 = Debug|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Release.ActiveCfg = Release|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.suo b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.suo new file mode 100644 index 0000000..e2f21f1 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.vbproj new file mode 100644 index 0000000..d7d1ce7 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-27/Listing2-27.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-27/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-27/Test.vb new file mode 100644 index 0000000..97b4892 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-27/Test.vb @@ -0,0 +1,15 @@ +Option Strict On + +Module Test + + Sub Main() + + Dim X As Double, Y As Double + X = 10 ^ 18 + Y = X + 1 + Console.WriteLine("X = Y? " + (X = Y).ToString) + Console.ReadLine() + + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter02/Listing2-28/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-28/AssemblyInfo.vb new file mode 100644 index 0000000..46393c4 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-28/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.sln b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.sln new file mode 100644 index 0000000..873642b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-28", "Listing2-28.vbproj", "{B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Debug.ActiveCfg = Debug|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Debug.Build.0 = Debug|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Release.ActiveCfg = Release|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.suo b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.suo new file mode 100644 index 0000000..bb6cc1a Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.vbproj new file mode 100644 index 0000000..87f30cd --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.vbproj.user new file mode 100644 index 0000000..c168d10 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-28/Listing2-28.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-28/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-28/Test.vb new file mode 100644 index 0000000..fbc67ae --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-28/Test.vb @@ -0,0 +1,12 @@ +Option Strict On + +Module Test + + Sub Main() + Dim X As Double = 2.45, Y As Double = 245 + X *= 100 + Console.WriteLine("X = Y? " + (X = Y).ToString) + Console.ReadLine() + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter02/Listing2-3/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-3/AssemblyInfo.vb new file mode 100644 index 0000000..ecb4d27 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-3/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.sln b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.sln new file mode 100644 index 0000000..3c4cdcd --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-3", "Listing2-3.vbproj", "{E1D2974A-2952-4B9D-A767-0783A0FE75F8}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Debug.ActiveCfg = Debug|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Debug.Build.0 = Debug|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Release.ActiveCfg = Release|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.suo b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.suo new file mode 100644 index 0000000..3358830 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.vbproj new file mode 100644 index 0000000..e9677ae --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-3/Listing2-3.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-3/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-3/Test.vb new file mode 100644 index 0000000..e27213b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-3/Test.vb @@ -0,0 +1,35 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + Dim objDerived As New Derived() + Dim objTest As New MyTest() + objDerived.DoSomething(objTest) + Console.ReadLine() + End Sub + +End Class + +Class MyTest +End Class + +Class Base + + Public Overridable Sub DoSomething(ByVal NewValue As MyTest) + Console.WriteLine("Base:DoSomething(MyTest) called") + End Sub + +End Class + +Class Derived : Inherits Base + + Public Overloads Overrides Sub DoSomething(ByVal NewValue As MyTest) + Console.WriteLine("Derived:DoSomething(MyTest) called") + End Sub + + Public Overloads Sub DoSomething(ByVal NewValue As Object) + Console.WriteLine("Derived:DoSomething(Object) called") + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/App.ico b/Source/VisualStudio2002/Chapter02/Listing2-4/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-4/App.ico differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/AssemblyInfo.cs b/Source/VisualStudio2002/Chapter02/Listing2-4/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-4/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.csproj b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.csproj new file mode 100644 index 0000000..f724ae3 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.csproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.csproj.user b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.csproj.user new file mode 100644 index 0000000..6893790 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.sln b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.sln new file mode 100644 index 0000000..acd5370 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-4", "Listing2-4.csproj", "{19931BA2-7550-4959-A597-ECECD054B2C8}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {19931BA2-7550-4959-A597-ECECD054B2C8}.Debug.ActiveCfg = Debug|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Debug.Build.0 = Debug|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Release.ActiveCfg = Release|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.suo b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.suo new file mode 100644 index 0000000..68b8fae Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-4/Listing2-4.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/Test.cs b/Source/VisualStudio2002/Chapter02/Listing2-4/Test.cs new file mode 100644 index 0000000..6ed7d5b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-4/Test.cs @@ -0,0 +1,32 @@ +class Test +{ + public static void Main() + { + Derived objDerived = new Derived(); + MyTest objMyTest = new MyTest(); + objDerived.DoSomething(objMyTest); + System.Console.ReadLine(); + } +} + +class MyTest {} + +class Base +{ + public virtual void DoSomething(MyTest MyParameter) + { + System.Console.WriteLine("Base:DoSomething(MyTest) called"); + } +} + +class Derived : Base +{ + public override void DoSomething(MyTest MyParameter) + { + System.Console.WriteLine("Derived:DoSomething(MyTest) called"); + } + public void DoSomething(object MyParameter) + { + System.Console.WriteLine("Derived:DoSomething(Object) called"); + } +} diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/obj/Debug/Listing2-4.exe.incr b/Source/VisualStudio2002/Chapter02/Listing2-4/obj/Debug/Listing2-4.exe.incr new file mode 100644 index 0000000..d696965 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-4/obj/Debug/Listing2-4.exe.incr differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-4/obj/Debug/Listing2-4.projdata b/Source/VisualStudio2002/Chapter02/Listing2-4/obj/Debug/Listing2-4.projdata new file mode 100644 index 0000000..b81a845 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-4/obj/Debug/Listing2-4.projdata differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-5/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-5/AssemblyInfo.vb new file mode 100644 index 0000000..a0c7309 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-5/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.sln b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.sln new file mode 100644 index 0000000..4c8d15d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-5", "Listing2-5.vbproj", "{8D6E435F-6608-4BEE-90FF-7B7CC145399E}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Debug.ActiveCfg = Debug|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Debug.Build.0 = Debug|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Release.ActiveCfg = Release|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.suo b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.suo new file mode 100644 index 0000000..f88aa8e Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.vbproj new file mode 100644 index 0000000..39758dd --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-5/Listing2-5.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-5/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-5/Test.vb new file mode 100644 index 0000000..c32567b --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-5/Test.vb @@ -0,0 +1,33 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + Dim objDerived As New Derived() + objDerived.DoSomething(CLng(8)) + Console.ReadLine() + End Sub + +End Class + +Class Base + + Public Overridable Sub DoSomething(ByVal NewValue As Long) + Console.WriteLine("Base:DoSomething(Long) called") + End Sub + + Public Sub DoSomething(ByVal NewValue As Double) + Console.WriteLine("Base:DoSomething(Double) called") + End Sub +End Class + +Class Derived : Inherits Base + + Public Overloads Overrides Sub DoSomething(ByVal NewValue As Long) + Console.WriteLine("Derived:DoSomething(Long) called") + End Sub + + Public Overloads Sub DoSomething(ByVal NewValue As Integer) + Console.WriteLine("Derived:DoSomething(Integer) called") + End Sub +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/App.ico b/Source/VisualStudio2002/Chapter02/Listing2-6/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-6/App.ico differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/AssemblyInfo.cs b/Source/VisualStudio2002/Chapter02/Listing2-6/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-6/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.csproj b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.csproj new file mode 100644 index 0000000..d3e03d5 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.csproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.csproj.user b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.csproj.user new file mode 100644 index 0000000..c8340ea --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.sln b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.sln new file mode 100644 index 0000000..41c076e --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-6", "Listing2-6.csproj", "{3A2336E2-DF01-47F4-97DC-F20E39391250}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Debug.ActiveCfg = Debug|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Debug.Build.0 = Debug|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Release.ActiveCfg = Release|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.suo b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.suo new file mode 100644 index 0000000..d339a74 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-6/Listing2-6.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/Test.cs b/Source/VisualStudio2002/Chapter02/Listing2-6/Test.cs new file mode 100644 index 0000000..f07f788 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-6/Test.cs @@ -0,0 +1,35 @@ +class Test +{ + public static void Main() + { + Derived objDerived = new Derived(); + objDerived.DoSomething((long) 8); + System.Console.ReadLine(); + } +} + +class Base +{ + public virtual void DoSomething(long NewValue) + { + System.Console.WriteLine("Base:DoSomething(Long) called"); + } + + public void DoSomething(double NewValue) + { + System.Console.WriteLine("Base:DoSomething(Double) called"); + } +} + +class Derived : Base +{ + override public void DoSomething(long NewValue) + { + System.Console.WriteLine("Derived:DoSomething(long) called"); + } + + public void DoSomething(int NewValue) + { + System.Console.WriteLine("Derived:DoSomething(Integer) called"); + } +} diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/obj/Debug/Listing2-6.exe.incr b/Source/VisualStudio2002/Chapter02/Listing2-6/obj/Debug/Listing2-6.exe.incr new file mode 100644 index 0000000..145ffd4 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-6/obj/Debug/Listing2-6.exe.incr differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-6/obj/Debug/Listing2-6.projdata b/Source/VisualStudio2002/Chapter02/Listing2-6/obj/Debug/Listing2-6.projdata new file mode 100644 index 0000000..965f944 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-6/obj/Debug/Listing2-6.projdata differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-7/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-7/AssemblyInfo.vb new file mode 100644 index 0000000..78700b2 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-7/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.sln b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.sln new file mode 100644 index 0000000..1a557d4 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-7", "Listing2-7.vbproj", "{D582898F-DD17-42D9-A004-E22CF2E2CEB2}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Debug.ActiveCfg = Debug|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Debug.Build.0 = Debug|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Release.ActiveCfg = Release|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.suo b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.suo new file mode 100644 index 0000000..d415f71 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.vbproj new file mode 100644 index 0000000..0f69392 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-7/Listing2-7.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-7/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-7/Test.vb new file mode 100644 index 0000000..b625010 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-7/Test.vb @@ -0,0 +1,14 @@ +Option Strict On + +Class Base + Overridable Sub DoSomething() + 'The method definition goes here + End Sub +End Class + +Class Derived : Inherits Base + Sub DoSomething() + 'This method will actually shadow its base method rather than Override it, + 'because the developer forgot to add the Overrides keyword + End Sub +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-8/AssemblyInfo.vb new file mode 100644 index 0000000..5b7ce5a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.sln b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.sln new file mode 100644 index 0000000..95b3330 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-8", "Listing2-8.vbproj", "{56218072-CB2B-49E2-B000-3180711BBC10}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {56218072-CB2B-49E2-B000-3180711BBC10}.Debug.ActiveCfg = Debug|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Debug.Build.0 = Debug|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Release.ActiveCfg = Release|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.suo b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.suo new file mode 100644 index 0000000..ac269f6 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.vbproj new file mode 100644 index 0000000..f318073 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8/Listing2-8.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-8/Test.vb new file mode 100644 index 0000000..234fa28 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8/Test.vb @@ -0,0 +1,59 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Overrides Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/AssemblyInfo.vb new file mode 100644 index 0000000..58b4bee --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln new file mode 100644 index 0000000..86cfd7a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-8Shadows", "Listing2-8Shadows.vbproj", "{BB663C40-7108-4457-8984-E194358B1817}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB663C40-7108-4457-8984-E194358B1817}.Debug.ActiveCfg = Debug|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Debug.Build.0 = Debug|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Release.ActiveCfg = Release|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.suo b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.suo new file mode 100644 index 0000000..9b54850 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj new file mode 100644 index 0000000..83b139e --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Test.vb new file mode 100644 index 0000000..24757cc --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-8Shadows/Test.vb @@ -0,0 +1,59 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Shadows Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter02/Listing2-9/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter02/Listing2-9/AssemblyInfo.vb new file mode 100644 index 0000000..73c3d1a --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-9/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.sln b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.sln new file mode 100644 index 0000000..35d2b2d --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-9", "Listing2-9.vbproj", "{BDC11796-30AC-4600-9B6C-7446DD16279D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Debug.ActiveCfg = Debug|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Debug.Build.0 = Debug|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Release.ActiveCfg = Release|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.suo b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.suo new file mode 100644 index 0000000..e81ec59 Binary files /dev/null and b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.suo differ diff --git a/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.vbproj b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.vbproj new file mode 100644 index 0000000..488767e --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.vbproj.user b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-9/Listing2-9.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter02/Listing2-9/Test.vb b/Source/VisualStudio2002/Chapter02/Listing2-9/Test.vb new file mode 100644 index 0000000..a0489ac --- /dev/null +++ b/Source/VisualStudio2002/Chapter02/Listing2-9/Test.vb @@ -0,0 +1,66 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Overrides Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + + 'This overload doesn't work for a subtle reason + Overloads Function Equals(ByVal AnyCat As Cat) As Boolean + Return True + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter04/SortingSpeed/AssemblyInfo.vb new file mode 100644 index 0000000..e68a407 --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemo.sln b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemo.sln new file mode 100644 index 0000000..b71c4dc --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemo.sln @@ -0,0 +1,33 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoLogic", "SortingDll\DebugDemoLogic.vbproj", "{057FA2D6-5280-4393-BE33-C6631BA07451}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoForm", "DebugDemoForm.vbproj", "{1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + ConfigName.2 = ReleaseCustom + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.0 = {057FA2D6-5280-4393-BE33-C6631BA07451} + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.ActiveCfg = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.Build.0 = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.ActiveCfg = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.Build.0 = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.ActiveCfg = ReleaseCustom|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.Build.0 = ReleaseCustom|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.ActiveCfg = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.Build.0 = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.Build.0 = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemo.suo b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemo.suo new file mode 100644 index 0000000..f1ee9bc Binary files /dev/null and b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemo.suo differ diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemoForm.vbproj b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemoForm.vbproj new file mode 100644 index 0000000..1eff798 --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemoForm.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemoForm.vbproj.user b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemoForm.vbproj.user new file mode 100644 index 0000000..7d7a099 --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/DebugDemoForm.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/DemoForm.resx b/Source/VisualStudio2002/Chapter04/SortingSpeed/DemoForm.resx new file mode 100644 index 0000000..363456d --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/DemoForm.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + Assembly + + + True + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + DebugDemo + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/DemoForm.vb b/Source/VisualStudio2002/Chapter04/SortingSpeed/DemoForm.vb new file mode 100644 index 0000000..cf4ee1a --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/DemoForm.vb @@ -0,0 +1,207 @@ +Public Class DebugDemo + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents lblTwo As System.Windows.Forms.Label + Friend WithEvents lblOne As System.Windows.Forms.Label + Friend WithEvents boxSort As System.Windows.Forms.GroupBox + Friend WithEvents Timing As System.Windows.Forms.Label + Friend WithEvents StartSort As System.Windows.Forms.Button + Friend WithEvents MaxValue As System.Windows.Forms.TextBox + Friend WithEvents NumberItems As System.Windows.Forms.TextBox + Friend WithEvents SortCounting As System.Windows.Forms.RadioButton + Friend WithEvents SortQuick As System.Windows.Forms.RadioButton + Friend WithEvents SortSelection As System.Windows.Forms.RadioButton + Friend WithEvents SortBubble As System.Windows.Forms.RadioButton + Private Sub InitializeComponent() + Me.lblTwo = New System.Windows.Forms.Label() + Me.lblOne = New System.Windows.Forms.Label() + Me.StartSort = New System.Windows.Forms.Button() + Me.MaxValue = New System.Windows.Forms.TextBox() + Me.NumberItems = New System.Windows.Forms.TextBox() + Me.boxSort = New System.Windows.Forms.GroupBox() + Me.SortCounting = New System.Windows.Forms.RadioButton() + Me.SortQuick = New System.Windows.Forms.RadioButton() + Me.SortSelection = New System.Windows.Forms.RadioButton() + Me.SortBubble = New System.Windows.Forms.RadioButton() + Me.Timing = New System.Windows.Forms.Label() + Me.boxSort.SuspendLayout() + Me.SuspendLayout() + ' + 'lblTwo + ' + Me.lblTwo.Location = New System.Drawing.Point(32, 96) + Me.lblTwo.Name = "lblTwo" + Me.lblTwo.Size = New System.Drawing.Size(112, 30) + Me.lblTwo.TabIndex = 14 + Me.lblTwo.Text = "Max item value" + ' + 'lblOne + ' + Me.lblOne.Location = New System.Drawing.Point(32, 40) + Me.lblOne.Name = "lblOne" + Me.lblOne.Size = New System.Drawing.Size(112, 30) + Me.lblOne.TabIndex = 12 + Me.lblOne.Text = "Number of items" + ' + 'StartSort + ' + Me.StartSort.Location = New System.Drawing.Point(280, 285) + Me.StartSort.Name = "StartSort" + Me.StartSort.Size = New System.Drawing.Size(92, 39) + Me.StartSort.TabIndex = 10 + Me.StartSort.Text = "Start sort" + ' + 'MaxValue + ' + Me.MaxValue.Location = New System.Drawing.Point(160, 96) + Me.MaxValue.Name = "MaxValue" + Me.MaxValue.Size = New System.Drawing.Size(72, 22) + Me.MaxValue.TabIndex = 13 + Me.MaxValue.Text = "10000" + ' + 'NumberItems + ' + Me.NumberItems.Location = New System.Drawing.Point(160, 40) + Me.NumberItems.Name = "NumberItems" + Me.NumberItems.Size = New System.Drawing.Size(72, 22) + Me.NumberItems.TabIndex = 11 + Me.NumberItems.Text = "1000" + ' + 'boxSort + ' + Me.boxSort.Controls.AddRange(New System.Windows.Forms.Control() {Me.SortCounting, Me.SortQuick, Me.SortSelection, Me.SortBubble}) + Me.boxSort.Location = New System.Drawing.Point(280, 16) + Me.boxSort.Name = "boxSort" + Me.boxSort.Size = New System.Drawing.Size(232, 247) + Me.boxSort.TabIndex = 9 + Me.boxSort.TabStop = False + Me.boxSort.Text = "Sort algorithm" + ' + 'SortCounting + ' + Me.SortCounting.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortCounting.Location = New System.Drawing.Point(41, 178) + Me.SortCounting.Name = "SortCounting" + Me.SortCounting.Size = New System.Drawing.Size(164, 29) + Me.SortCounting.TabIndex = 3 + Me.SortCounting.Text = "Counting sort" + ' + 'SortQuick + ' + Me.SortQuick.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortQuick.Location = New System.Drawing.Point(41, 128) + Me.SortQuick.Name = "SortQuick" + Me.SortQuick.Size = New System.Drawing.Size(164, 30) + Me.SortQuick.TabIndex = 2 + Me.SortQuick.Text = "Quick sort" + ' + 'SortSelection + ' + Me.SortSelection.Location = New System.Drawing.Point(41, 79) + Me.SortSelection.Name = "SortSelection" + Me.SortSelection.Size = New System.Drawing.Size(164, 30) + Me.SortSelection.TabIndex = 1 + Me.SortSelection.Text = "Selection sort" + ' + 'SortBubble + ' + Me.SortBubble.Checked = True + Me.SortBubble.Location = New System.Drawing.Point(41, 30) + Me.SortBubble.Name = "SortBubble" + Me.SortBubble.Size = New System.Drawing.Size(164, 29) + Me.SortBubble.TabIndex = 0 + Me.SortBubble.TabStop = True + Me.SortBubble.Text = "Bubble sort" + ' + 'Timing + ' + Me.Timing.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.Timing.Location = New System.Drawing.Point(400, 288) + Me.Timing.Name = "Timing" + Me.Timing.Size = New System.Drawing.Size(112, 32) + Me.Timing.TabIndex = 15 + ' + 'DebugDemo + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(544, 348) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Timing, Me.lblTwo, Me.lblOne, Me.StartSort, Me.MaxValue, Me.NumberItems, Me.boxSort}) + Me.Name = "DebugDemo" + Me.Text = "Debug demo" + Me.boxSort.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private m_SortType As DemoSort.SortType = DemoSort.SortType.BubbleSort + + Private Sub StartSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartSort.Click + Dim SortObject As New DemoSort() + + 'Show that we're busy + Cursor.Current = Cursors.WaitCursor + Me.StartSort.Enabled = False + + 'Build a list to sort + Me.Timing.Text = "Building list to sort..." + Me.Timing.Refresh() + SortObject.ListBuild(Convert.ToInt32(Me.NumberItems.Text), 1, Convert.ToInt32(Me.MaxValue.Text)) + + 'Do the sort and report timing + Me.Timing.Text = "Performing sort..." + Me.Timing.Refresh() + Me.Timing.Text = SortObject.DoSort(m_SortType).ToString & " seconds" + + 'Show that we've finished + Me.StartSort.Enabled = True + Cursor.Current = Cursors.Default + + End Sub + + Private Sub SortBubble_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortBubble.CheckedChanged + m_SortType = DemoSort.SortType.BubbleSort + End Sub + + Private Sub SortSelection_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortSelection.CheckedChanged + m_SortType = DemoSort.SortType.SelectionSort + End Sub + + Private Sub SortQuick_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortQuick.CheckedChanged + m_SortType = DemoSort.SortType.QuickSort + End Sub + + Private Sub SortCounting_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortCounting.CheckedChanged + m_SortType = DemoSort.SortType.CountingSort + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/AssemblyInfo.vb new file mode 100644 index 0000000..240f036 --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/AssemblyInfo.vb @@ -0,0 +1,30 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj new file mode 100644 index 0000000..498d34a --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj.user b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj.user new file mode 100644 index 0000000..ff746ab --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj.user @@ -0,0 +1,64 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DemoSort.vb b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DemoSort.vb new file mode 100644 index 0000000..13cc2f8 --- /dev/null +++ b/Source/VisualStudio2002/Chapter04/SortingSpeed/SortingDll/DemoSort.vb @@ -0,0 +1,265 @@ +Option Strict On + +Public Class DemoSort + + 'These are the sorting lists + Private ListUnsorted() As Int32 + Private ListBeingSorted() As Int32 + 'These are max and minimum sort settings + Private ListLengthMin As Int32 + Private ListLengthMax As Int32 + Private ListValueMin As Int32 + Private ListValueMax As Int32 + + Public Enum SortType As Integer + BubbleSort = 1 + SelectionSort = 2 + QuickSort = 3 + CountingSort = 4 + End Enum + + Public Sub ListBuild(ByVal ListLength As Int32, ByVal ValueMin As Int32, ByVal ValueMax As Int32) + Dim ArrayItem As Int32, objRandom As New System.Random(1) + + 'If parameters haven't changed, just use previous list + 'This enables multiple timing checks on an identical array + If ListLength = ListLengthMax And ValueMin = ListValueMin And ValueMax = ListValueMax Then + Exit Sub + End If + + 'Build a new list with given parameters + ReDim ListUnsorted(ListLength) + For ArrayItem = 1 To ListLength + ListUnsorted(ArrayItem) = objRandom.Next(ValueMin, ValueMax) + Next ArrayItem + + 'Set length of sorted list to match + ReDim ListBeingSorted(ListLength) + + 'Store min and max list items and values + ListLengthMin = 1 + ListLengthMax = ListLength + ListValueMin = ValueMin + ListValueMax = ValueMax + + End Sub + + Public Function DoSort(ByVal Sort As SortType) As Double + Dim TimeStart As Int32, TimeFinish As Int32, ArrayItem As Int32 + + 'Copy to array that will contain newly-sorted list + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ArrayItem) = ListUnsorted(ArrayItem) + Next + + 'Start the clock so we can report how long the sorting took + TimeStart = System.Environment.TickCount() + + 'Do the sort + Select Case Sort + Case SortType.BubbleSort + SortBubble(ListLengthMin, ListLengthMax) + Case SortType.QuickSort + SortQuick(ListLengthMin, ListLengthMax) + Case SortType.SelectionSort + SortSelection() + Case SortType.CountingSort + SortCounting() + Case Else + Trace.Fail(CStr(Sort) & " is an invalid sort type") + End Select + + 'Stop the clock and report how long the sorting took + TimeFinish = System.Environment.TickCount() + 'Check sort + SortCheck() + 'Convert elapsed time into seconds + Return (TimeFinish - TimeStart) / 1000 + + End Function + + Private Sub SortBubble(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim intLastSwap As Int32, intLoop1 As Int32, intLoop2 As Int32 + Dim intDrop As Int32 + + 'Repeat until we are done + Do While ItemLow < ItemHigh + + 'First bubble upwards + intLastSwap = ItemLow - 1 + intLoop1 = ItemLow + 1 + + Do While intLoop1 <= ItemHigh + 'Find a bubble + If ListBeingSorted(intLoop1 - 1) > ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 - 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) < intDrop + ListBeingSorted(intLoop2 - 1) = ListBeingSorted(intLoop2) + intLoop2 += 1 + If intLoop2 > ItemHigh Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 - 1) = intDrop + intLastSwap = intLoop2 - 1 + intLoop1 = intLoop2 + 1 + Else + intLoop1 += 1 + End If + Loop + + 'Update maximum value + ItemHigh = intLastSwap - 1 + + 'Next bubble downwards + intLastSwap = ItemHigh + 1 + intLoop1 = ItemHigh - 1 + + Do While intLoop1 >= ItemLow + 'Find a bubble + If ListBeingSorted(intLoop1 + 1) < ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 + 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) > intDrop + ListBeingSorted(intLoop2 + 1) = ListBeingSorted(intLoop2) + intLoop2 -= 1 + If intLoop2 < ItemLow Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 + 1) = intDrop + intLastSwap = intLoop2 + 1 + intLoop1 = intLoop2 - 1 + Else + intLoop1 -= 1 + End If + Loop + + 'Update minimum value + ItemLow = intLastSwap + 1 + + Loop + + End Sub + + Private Sub SortSelection() + Dim LoopOuter As Int32, LoopInner As Int32, BestValue As Int32, BestInnerIndex As Int32 + + For LoopOuter = ListLengthMin To ListLengthMax - 1 + + 'Init lowest-value search + BestValue = ListBeingSorted(LoopOuter) + BestInnerIndex = LoopOuter + + 'Find lowest value that hasn't already been sorted + For LoopInner = LoopOuter + 1 To ListLengthMax + If ListBeingSorted(LoopInner) < BestValue Then + BestValue = ListBeingSorted(LoopInner) + BestInnerIndex = LoopInner + End If + Next LoopInner + + 'Swap lowest value into proper position + ListBeingSorted(BestInnerIndex) = ListBeingSorted(LoopOuter) + ListBeingSorted(LoopOuter) = BestValue + + Next LoopOuter + + End Sub + + Private Sub SortQuick(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim IntermediateValue As Int32, Position As Int32 + Dim objRandom As New System.Random() + Dim intLow As Int32, intHigh As Int32 + + 'If the list has only 1 element, it's already sorted + If ItemLow >= ItemHigh Then Exit Sub + + 'Pick a dividing item + Position = objRandom.Next(ItemLow, ItemHigh) + IntermediateValue = ListBeingSorted(Position) + + 'Swap it to the front so we can find it easily + ListBeingSorted(Position) = ListBeingSorted(ItemLow) + + 'Move the items smaller than this into the left + 'half of the list. Move the others into the right. + intLow = ItemLow + intHigh = ItemHigh + Do + 'Look down from low item for a value < IntermediateValue + Do While ListBeingSorted(intHigh) >= IntermediateValue + intHigh -= 1 + If intHigh <= intLow Then Exit Do + Loop + If intHigh <= intLow Then + ListBeingSorted(intLow) = IntermediateValue + Exit Do + End If + + 'Swap the low and high values + ListBeingSorted(intLow) = ListBeingSorted(intHigh) + + 'Look up from ItemLow for a value >= IntermediateValue + intLow += 1 + Do While ListBeingSorted(intLow) < IntermediateValue + intLow += 1 + If intLow >= intHigh Then Exit Do + Loop + If intLow >= intHigh Then + intLow = intHigh + ListBeingSorted(intHigh) = IntermediateValue + Exit Do + End If + + 'Swap the low and high items + ListBeingSorted(intHigh) = ListBeingSorted(intLow) + Loop + + 'Sort the two sublists recursively + SortQuick(ItemLow, intLow - 1) + SortQuick(intHigh + 1, ItemHigh) + + End Sub + + Private Sub SortCounting() + Dim ListCounts(ListValueMax) As Int32 + Dim ArrayItem As Int32, ThisCount As Int32, NextOffset As Int32 + + 'Count the items + For ArrayItem = ListLengthMin To ListLengthMax + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + 'Convert the ListCounts into offsets + NextOffset = ListLengthMin + For ArrayItem = ListValueMin To ListValueMax + ThisCount = ListCounts(ArrayItem) + ListCounts(ArrayItem) = NextOffset + NextOffset += ThisCount + Next ArrayItem + + 'Place the items in the sorted array + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ListCounts(ListUnsorted(ArrayItem))) = ListUnsorted(ArrayItem) + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + End Sub + + Private Function SortCheck() As Boolean + Dim ArrayItem As Int32 + + For ArrayItem = 2 To ListLengthMax + If ListBeingSorted(ArrayItem - 1) > ListBeingSorted(ArrayItem) Then + Trace.Fail("Item " & (ArrayItem - 1).ToString & " is larger than item " & ArrayItem.ToString) + Exit For + End If + Next ArrayItem + + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter04/SortingSpeed/obj/Debug/DebugDemo.DebugDemo.resources b/Source/VisualStudio2002/Chapter04/SortingSpeed/obj/Debug/DebugDemo.DebugDemo.resources new file mode 100644 index 0000000..24379ba Binary files /dev/null and b/Source/VisualStudio2002/Chapter04/SortingSpeed/obj/Debug/DebugDemo.DebugDemo.resources differ diff --git a/Source/VisualStudio2002/Chapter05/ErrorHandling/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter05/ErrorHandling/AssemblyInfo.vb new file mode 100644 index 0000000..1ab76fe --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/ErrorHandling/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.sln b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.sln new file mode 100644 index 0000000..8c51823 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ErrorHandling", "ErrorHandling.vbproj", "{20437FF3-C011-4EBB-B7E5-3E4313ED2279}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Debug.ActiveCfg = Debug|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Debug.Build.0 = Debug|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Release.ActiveCfg = Release|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.suo b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.suo new file mode 100644 index 0000000..9d7b118 Binary files /dev/null and b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.suo differ diff --git a/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.vbproj b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.vbproj new file mode 100644 index 0000000..25ec03f --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.vbproj.user b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorHandling.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorTest.vb b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorTest.vb new file mode 100644 index 0000000..6d67bed --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/ErrorHandling/ErrorTest.vb @@ -0,0 +1,41 @@ +Option Strict On +Imports System.Data.SqlClient + +Module ErrorTest + + Sub Main() + Dim strConnection As String + 'Set up database connection + strConnection = "Initial Catalog = Northwind;" + strConnection += "Data Source = CHEETAH;" + strConnection += "Integrated Security = SSPI" + 'Try old and new error-handling functions + MethodOld(strConnection) + MethodNew(strConnection) + End Sub + + Function MethodOld(ByVal ConnectString As String) As Boolean + Dim objSqlConnect As SqlConnection + 'Test database connection with old error handling + On Error Resume Next + objSqlConnect = New SqlConnection(ConnectString) + MethodOld = CBool(Err.Number = 0) + objSqlConnect.Close() + objSqlConnect.Dispose() + End Function + + Function MethodNew(ByVal ConnectString As String) As Boolean + Dim objSqlConnect As SqlConnection + 'Test database connection with new error handling + Try + objSqlConnect = New SqlConnection(ConnectString) + objSqlConnect.Close() + objSqlConnect.Dispose() + Return True + Catch + Return False + Finally + End Try + End Function + +End Module diff --git a/Source/VisualStudio2002/Chapter05/HelloWorld/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter05/HelloWorld/AssemblyInfo.vb new file mode 100644 index 0000000..bdcac6c --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/HelloWorld/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.sln b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.sln new file mode 100644 index 0000000..1fad0c7 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HelloWorld", "HelloWorld.vbproj", "{B17D4890-3D55-4530-9BAB-331E9F4DB432}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Debug.ActiveCfg = Debug|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Debug.Build.0 = Debug|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Release.ActiveCfg = Release|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.suo b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.suo new file mode 100644 index 0000000..f632aa2 Binary files /dev/null and b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.suo differ diff --git a/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vb b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vb new file mode 100644 index 0000000..c1e98de --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vb @@ -0,0 +1,9 @@ +Module HelloWorld + + Sub Main() + + System.Console.WriteLine("Hello VB.Net world") + + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vbproj b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vbproj new file mode 100644 index 0000000..a41c892 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vbproj.user b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/HelloWorld/HelloWorld.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestOne/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/AssemblyInfo.vb new file mode 100644 index 0000000..b81bc27 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.sln b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.sln new file mode 100644 index 0000000..0429d40 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringPerfTestOne", "StringPerfTestOne.vbproj", "{8454C1C9-B876-4ACF-8562-02C70E18505E}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.ActiveCfg = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.Build.0 = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.ActiveCfg = Release|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.suo b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.suo new file mode 100644 index 0000000..ccc943d Binary files /dev/null and b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.suo differ diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj new file mode 100644 index 0000000..aedc68e --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj.user b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestOne/Test.vb b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/Test.vb new file mode 100644 index 0000000..aafbbb1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestOne/Test.vb @@ -0,0 +1,15 @@ +Option Strict On + +Module StringPerfTestOne + + Sub Main() + Dim strTest As String = "Coming up: ", intTest As Integer = 0 + System.Console.WriteLine("Starting...") + For intTest = 1 To 20000 + strTest += "another test " + Next + System.Console.WriteLine("Finished") + System.Console.ReadLine() + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/AssemblyInfo.vb new file mode 100644 index 0000000..b81bc27 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln new file mode 100644 index 0000000..8a00ffe --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringPerfTestTwo", "StringPerfTestTwo.vbproj", "{8454C1C9-B876-4ACF-8562-02C70E18505E}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.ActiveCfg = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.Build.0 = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.ActiveCfg = Release|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.suo b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.suo new file mode 100644 index 0000000..e069035 Binary files /dev/null and b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.suo differ diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj new file mode 100644 index 0000000..aedc68e --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj.user b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/Test.vb b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/Test.vb new file mode 100644 index 0000000..19a18e8 --- /dev/null +++ b/Source/VisualStudio2002/Chapter05/StringPerfTestTwo/Test.vb @@ -0,0 +1,16 @@ +Option Strict On + +Module StringPerfTestTwo + + Sub Main() + Dim sbTest As New System.Text.StringBuilder("Coming up: ") + Dim intTest As Integer = 0 + System.Console.WriteLine("Starting...") + For intTest = 1 To 20000 + sbTest.Append("another test ") + Next + System.Console.WriteLine("Finished") + System.Console.ReadLine() + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/AssemblyInfo.vb new file mode 100644 index 0000000..c42de65 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln new file mode 100644 index 0000000..2e701cf --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BooleanSwitchTest", "BooleanSwitchTest.vbproj", "{74999BA0-648F-4433-B23B-66CD0A996617}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {74999BA0-648F-4433-B23B-66CD0A996617}.Debug.ActiveCfg = Debug|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Debug.Build.0 = Debug|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Release.ActiveCfg = Release|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.suo b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.suo new file mode 100644 index 0000000..fb5ca22 Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.suo differ diff --git a/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj new file mode 100644 index 0000000..3b4418f --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj.user b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/Test.vb b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/Test.vb new file mode 100644 index 0000000..2a785a3 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/BooleanSwitchTest/Test.vb @@ -0,0 +1,25 @@ +Option Strict On + +Module Test + + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + Private bswTraceOutput As New Diagnostics.BooleanSwitch("MyAppTracing", "Test BooleanSwitch") + + Public Sub Main() + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + bswTraceOutput.Enabled = True + Test() + End Sub + + Public Sub Test() + 'Show whether the BooleanSwitch is enabled or disabled + If bswTraceOutput.Enabled Then + Trace.WriteLine(bswTraceOutput.DisplayName & " is enabled") + Else + Trace.WriteLine(bswTraceOutput.DisplayName & " is disabled") + End If + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter06/CustomSwitchTest/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/AssemblyInfo.vb new file mode 100644 index 0000000..17cf2fd --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.sln b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.sln new file mode 100644 index 0000000..a26faad --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomSwitchTest", "CustomSwitchTest.vbproj", "{02FBDF20-1D73-429D-928A-15C519BAD91D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Debug.ActiveCfg = Debug|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Debug.Build.0 = Debug|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Release.ActiveCfg = Release|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.suo b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.suo new file mode 100644 index 0000000..5e98f16 Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.suo differ diff --git a/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj new file mode 100644 index 0000000..05dcbbd --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj.user b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/CustomSwitchTest/Test.vb b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/Test.vb new file mode 100644 index 0000000..b265118 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomSwitchTest/Test.vb @@ -0,0 +1,96 @@ +Option Strict On + +Module Test + + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + Private AppTrace As New TraceSwitchCustom("AppTrace", "A custom trace switch") + + Public Sub Main() + 'Show a trace information message + AppTrace.MessageInfo("Trace information message", _ + "This is a verbose version of the trace information") + 'Show a trace warning message + AppTrace.MessageWarning("Trace warning message", _ + "This is a verbose version of the trace warning") + 'Show a trace error message + AppTrace.MessageError("Trace error message", _ + "This is a verbose version of the trace error") + End Sub + +End Module + +Public Class TraceSwitchCustom : Inherits TraceSwitch + + Sub New(ByVal DisplayName As String, ByVal Description As String) + 'Chain call to base class, then show that tracing has started + MyBase.New(DisplayName, Description) + ControlTraceOutput(TraceLevel.Info, Me.DisplayName & _ + " trace listener created - trace level is " & Me.Level.ToString, "", 1) + End Sub + + Protected Overrides Sub OnSwitchSettingChanged() + 'Show that switch setting has changed + If Me.TraceInfo Then + ControlTraceOutput(TraceLevel.Info, Me.DisplayName & _ + " trace level is now " & Me.Level.ToString, "", 1) + End If + End Sub + + Public Sub MessageError(ByVal Message As String, ByVal VerboseMessage As String) + 'Show trace error message if errors are switched on + If Me.TraceError Then + ControlTraceOutput(TraceLevel.Error, Message, VerboseMessage, 2) + End If + End Sub + + Public Sub MessageWarning(ByVal Message As String, ByVal VerboseMessage As String) + 'Show trace warning message if warnings are switched on + If Me.TraceWarning Then + ControlTraceOutput(TraceLevel.Warning, Message, VerboseMessage, 2) + End If + End Sub + + Public Sub MessageInfo(ByVal Message As String, ByVal VerboseMessage As String) + 'Show trace information message if information messages are switched on + If Me.TraceInfo Then + ControlTraceOutput(TraceLevel.Info, Message, VerboseMessage, 2) + End If + End Sub + + Private Sub ControlTraceOutput(ByVal MessageLevel As TraceLevel, ByVal Message As String, ByVal VerboseMessage As String, ByVal StackDepth As Int16) + 'Validate parameters supplied by caller + If Message Is Nothing Then Message = "" + If VerboseMessage Is Nothing Then VerboseMessage = "" + 'Add system date/time to the trace message + Dim strDateTime As String = New System.DateTime().Now.ToString + 'Add originating module/procedure name to the trace message + '(catch any stackframe error, probably a permission problem) + Dim strTraceSource As String + Try + Dim objStackFrame As New System.Diagnostics.StackFrame(StackDepth) + strTraceSource = objStackFrame.GetMethod.DeclaringType.FullName & _ + "." & objStackFrame.GetMethod.Name + Catch + strTraceSource = _ + "unknown procedure (stackframe call failed - check permissions)" + Finally + Trace.WriteLine _ + (MessageLevel.ToString & " message at " & strDateTime & _ + " from " & strTraceSource, Me.DisplayName) + End Try + 'Write augmented trace message + Trace.Indent() + Trace.WriteLine(Message) + 'Emit verbose trace message if allowed and supplied + If Me.TraceVerbose And VerboseMessage.Length > 0 Then + Trace.Indent() + Trace.WriteLine(VerboseMessage) + Trace.Unindent() + End If + 'Finish message + Trace.Unindent() + Trace.Flush() + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/CustomTraceListener/AssemblyInfo.vb new file mode 100644 index 0000000..0e631e6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomTraceListener/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.sln b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.sln new file mode 100644 index 0000000..1e7ea25 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomTraceListener", "CustomTraceListener.vbproj", "{39549A95-F908-4BE4-AF53-C349C8E49FC5}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Debug.ActiveCfg = Debug|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Debug.Build.0 = Debug|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Release.ActiveCfg = Release|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.suo b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.suo new file mode 100644 index 0000000..45f3962 Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.suo differ diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.vbproj b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.vbproj new file mode 100644 index 0000000..e5c1f5a --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.vbproj.user b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomTraceListener/CustomTraceListener.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/Test.vb b/Source/VisualStudio2002/Chapter06/CustomTraceListener/Test.vb new file mode 100644 index 0000000..1ef4e2a --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomTraceListener/Test.vb @@ -0,0 +1,114 @@ +Option Strict On +Imports System.Diagnostics +Imports System.Threading +Imports System.Text +Imports System.IO +Imports System + +Public Module Test + + Public Sub Main() + 'Activate the custom trace listener and its output file stream + Dim objPerformOutput As Stream = File.Create("Performance.xml") + Dim objPerformRecorder As New TimerTraceListener(objPerformOutput) + Trace.Listeners.Add(objPerformRecorder) + 'Add this statement at the start of every monitored procedure + Trace.WriteLine("Entering procedure") + 'Add this statement at the end of every monitored procedure + Trace.WriteLine("Leaving procedure") + 'Add these statements when closing the custom trace listener + objPerformRecorder.Flush() + objPerformRecorder.Close() + End Sub + +End Module + +Public Class TimerTraceListener : Inherits TextWriterTraceListener + + Private msbBuffer As New StringBuilder() + + 'All of our constructors are here + Public Sub New(ByVal Stream As Stream) + MyBase.New(Stream) + EmitHeader() + End Sub + + Public Sub New(ByVal Stream As Stream, ByVal Name As String) + MyBase.New(Stream, Name) + EmitHeader() + End Sub + + Public Sub New(ByVal Writer As TextWriter) + MyBase.New(Writer) + EmitHeader() + End Sub + + Public Sub New(ByVal Writer As TextWriter, ByVal Name As String) + MyBase.New(Writer, Name) + EmitHeader() + End Sub + + Protected Sub EmitHeader() + 'Start tracing performance data + MyBase.WriteLine("") + End Sub + + Public Overloads Overrides Sub Write(ByVal Message As String) + If msbBuffer Is Nothing Then + msbBuffer = New StringBuilder() + End If + msbBuffer.Append(Message) + End Sub + + Public Overloads Overrides Sub WriteLine(ByVal Message As String) + If Not (msbBuffer Is Nothing) Then + Message = msbBuffer.ToString & Message + msbBuffer = Nothing + End If + EmitMessage(Message) + End Sub + + Protected Sub EmitMessage(ByVal Message As String) + 'Write performance data + Dim objNow As DateTime = New System.DateTime().Now + Dim objCalledFrom As New StackFrame(4) + MyBase.WriteLine("") + 'Timing data + With objNow + MyBase.WriteLine(CreateTag("time", .ToLongTimeString() & "." & .Millisecond.ToString)) + MyBase.WriteLine(CreateTag("message", Message)) + End With + 'Caller data + With objCalledFrom.GetMethod + MyBase.WriteLine(CreateTag("method", .DeclaringType.FullName & "." & .Name)) + End With + 'Thread data + MyBase.WriteLine(CreateTag("thread", Thread.CurrentThread.Name)) + 'Finish log entry + MyBase.WriteLine("") + End Sub + + Protected Function CreateTag(ByVal TagName As String, ByVal TagContents As String) As String + 'Return an XML tag + Return "<" & TagName & ">" & TagContents & "" + End Function + + Public Overrides Sub Flush() + 'Flush any remaining information to file + If Not (msbBuffer Is Nothing) Then + EmitMessage(msbBuffer.ToString) + msbBuffer = Nothing + End If + 'Don’t forget to chain to MyBase + MyBase.Flush() + End Sub + + Public Overrides Sub Close() + 'Finish tracing performance data + MyBase.WriteLine("") + Me.Flush() + 'Don’t forget to chain to MyBase + MyBase.Close() + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter06/CustomTraceListener/bin/Performance.xml b/Source/VisualStudio2002/Chapter06/CustomTraceListener/bin/Performance.xml new file mode 100644 index 0000000..8742f16 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/CustomTraceListener/bin/Performance.xml @@ -0,0 +1,14 @@ + + + +Entering procedure +CustomTraceListener.Test.Main + + + + +Leaving procedure +CustomTraceListener.Test.Main + + + diff --git a/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/AssemblyInfo.vb new file mode 100644 index 0000000..a4facbb --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln new file mode 100644 index 0000000..619bb4e --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RemoveDefaultTrace", "RemoveDefaultTrace.vbproj", "{831BA6C7-D44A-4C54-B62F-C12A3D3831C6}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Debug.ActiveCfg = Debug|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Debug.Build.0 = Debug|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Release.ActiveCfg = Release|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.suo b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.suo new file mode 100644 index 0000000..65d48b1 Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.suo differ diff --git a/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj new file mode 100644 index 0000000..2a74eb1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj.user b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/Test.vb b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/Test.vb new file mode 100644 index 0000000..9a76b38 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/RemoveDefaultTrace/Test.vb @@ -0,0 +1,12 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + 'Remove the default trace listener from the listeners collection + 'This method takes either a string containing the listener name + 'or the listener object + Trace.Listeners.Remove("DefaultTraceListener") + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter06/TraceAssert/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/TraceAssert/AssemblyInfo.vb new file mode 100644 index 0000000..3223915 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceAssert/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/TraceAssert/Test.vb b/Source/VisualStudio2002/Chapter06/TraceAssert/Test.vb new file mode 100644 index 0000000..86f8991 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceAssert/Test.vb @@ -0,0 +1,21 @@ +Option Strict On + +Module Test + + Sub Main() + Dim VbClassic As Int16, VbNet As Int16 + 'Does TRUE have the same value when using + 'VB.Classic functions and VB .NET functions? + VbClassic = CInt(True) + VbNet = Convert.ToInt16(True) + 'This overload just shows the call stack leading to the assertion failure + Trace.Assert(VbClassic = VbNet) + 'This overload adds an brief explanation of the assertion failure + Trace.Assert(VbClassic = VbNet, "Assertion failed: VbClassic(True) <> VbNet(True)") + 'This overload adds a more detailed explanation of the assertion failure + Trace.Assert(VbClassic = VbNet, "Assertion failed: VbClassic(True) <> VbNet(True)", _ + "CInt(True)=" & VbClassic.ToString & _ + " : Convert.ToInt16(True)=" & VbNet.ToString) + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.sln b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.sln new file mode 100644 index 0000000..cef6116 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceAssert", "TraceAssert.vbproj", "{DB28045D-F29C-46C5-88B1-1B5A786DC862}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Debug.ActiveCfg = Debug|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Debug.Build.0 = Debug|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Release.ActiveCfg = Release|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.suo b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.suo new file mode 100644 index 0000000..6a244d7 Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.suo differ diff --git a/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.vbproj b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.vbproj new file mode 100644 index 0000000..f86a59a --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.vbproj.user b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceAssert/TraceAssert.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceSwitchTest/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/AssemblyInfo.vb new file mode 100644 index 0000000..bbded1f --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/TraceSwitchTest/Test.vb b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/Test.vb new file mode 100644 index 0000000..3d9c0af --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/Test.vb @@ -0,0 +1,28 @@ +Option Strict On + +Module Test + + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + Private tswTraceControl As New Diagnostics.TraceSwitch("SwitchTrace", "Test trace switch") + + Public Sub Main() + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + tswTraceControl.Level = TraceLevel.Warning + Test() + End Sub + + Public Sub Test() + 'Either check the TraceError, TraceWarning, TraceInfo + 'or TraceVerbose properties + If tswTraceControl.TraceError Then + Trace.WriteLine("Trace only shows if traceswitch is set to show errors") + End If + 'Or check the Level property against the TraceLevel enumeration + If tswTraceControl.Level = TraceLevel.Warning Then + Trace.WriteLine("Trace shows if traceswitch is set to show warnings or errors") + End If + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.sln b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.sln new file mode 100644 index 0000000..fb5873a --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceSwitchTest", "TraceSwitchTest.vbproj", "{CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Debug.ActiveCfg = Debug|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Debug.Build.0 = Debug|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Release.ActiveCfg = Release|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.suo b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.suo new file mode 100644 index 0000000..fc4e42a Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.suo differ diff --git a/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj new file mode 100644 index 0000000..caa3796 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj.user b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToConsole/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/TraceToConsole/AssemblyInfo.vb new file mode 100644 index 0000000..5dac7a1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToConsole/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToConsole/Test.vb b/Source/VisualStudio2002/Chapter06/TraceToConsole/Test.vb new file mode 100644 index 0000000..38175fe --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToConsole/Test.vb @@ -0,0 +1,23 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + 'Create a trace listener that writes trace information to the console + Dim objTraceToConsole As New TextWriterTraceListener(System.Console.Out) + 'Add the new trace listener to the collection of listeners + Trace.Listeners.Add(objTraceToConsole) + 'Write trace information to all listeners, including the console + Trace.WriteLine("This trace information is for all listeners") + 'Write trace information to just the console listener + objTraceToConsole.WriteLine _ + ("This trace information is just for the console listener") + 'Pause application to see console output + Console.ReadLine() + 'Finish and clean up our console listener + objTraceToConsole.Flush() + objTraceToConsole.Close() + objTraceToConsole.Dispose() + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.sln b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.sln new file mode 100644 index 0000000..111c80f --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToConsole", "TraceToConsole.vbproj", "{10886B1B-5C6A-4023-ADAC-D32412E5B9AC}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Debug.ActiveCfg = Debug|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Debug.Build.0 = Debug|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Release.ActiveCfg = Release|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.suo b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.suo new file mode 100644 index 0000000..cb2b701 Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.suo differ diff --git a/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.vbproj b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.vbproj new file mode 100644 index 0000000..9e0ad47 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.vbproj.user b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToConsole/TraceToConsole.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToEventLog/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/TraceToEventLog/AssemblyInfo.vb new file mode 100644 index 0000000..aa32d4b --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToEventLog/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToEventLog/Test.vb b/Source/VisualStudio2002/Chapter06/TraceToEventLog/Test.vb new file mode 100644 index 0000000..a4d8324 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToEventLog/Test.vb @@ -0,0 +1,29 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + + 'Create an event log trace listener, give it a name, and configure it + Dim objTraceToAppLog As New EventLogTraceListener("LogTraceListener") + With objTraceToAppLog + 'Write to the Application event log + .EventLog.Log = "Application" + 'Specify source of tracing information + .EventLog.Source = "AppName." & .Name + End With + 'Add the new trace listener to the collection of listeners + Trace.Listeners.Add(objTraceToAppLog) + 'Write trace information to all listeners, + 'including the Application event log + Trace.WriteLine("This trace information is for all listeners") + 'Finish and clean up our console listener + With objTraceToAppLog + .Flush() + .Close() + .Dispose() + End With + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.sln b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.sln new file mode 100644 index 0000000..da1a871 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToEventLog", "TraceToEventLog.vbproj", "{DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Debug.ActiveCfg = Debug|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Debug.Build.0 = Debug|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Release.ActiveCfg = Release|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.suo b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.suo new file mode 100644 index 0000000..d91541d Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.suo differ diff --git a/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.vbproj b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.vbproj new file mode 100644 index 0000000..77d226a --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.vbproj.user b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToEventLog/TraceToEventLog.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter06/TraceToText/AssemblyInfo.vb new file mode 100644 index 0000000..307f6ec --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToText/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/Test.vb b/Source/VisualStudio2002/Chapter06/TraceToText/Test.vb new file mode 100644 index 0000000..464ca21 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToText/Test.vb @@ -0,0 +1,22 @@ +Option Strict On +Imports System.IO + +Class Test + + Public Shared Sub Main() + + 'Create a trace listener that writes trace information to a text file + Dim objTextFile As Stream = File.Create("TraceListener.txt") + Dim objTraceToText As New TextWriterTraceListener(objTextFile) + 'Add the new trace listener to the collection of listeners + Trace.Listeners.Add(objTraceToText) + 'Write trace information to all listeners, including the text file + Trace.WriteLine("This trace information is for all listeners") + 'Finish and clean up our console listener + objTraceToText.Flush() + objTraceToText.Close() + objTraceToText.Dispose() + + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.sln b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.sln new file mode 100644 index 0000000..c600440 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToText", "TraceToText.vbproj", "{32485B72-9BD6-46CE-BA3D-A685907A58D2}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Debug.ActiveCfg = Debug|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Debug.Build.0 = Debug|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Release.ActiveCfg = Release|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.suo b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.suo new file mode 100644 index 0000000..44c57af Binary files /dev/null and b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.suo differ diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.vbproj b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.vbproj new file mode 100644 index 0000000..8222980 --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.vbproj.user b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToText/TraceToText.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter06/TraceToText/bin/TraceListener.txt b/Source/VisualStudio2002/Chapter06/TraceToText/bin/TraceListener.txt new file mode 100644 index 0000000..913e28a --- /dev/null +++ b/Source/VisualStudio2002/Chapter06/TraceToText/bin/TraceListener.txt @@ -0,0 +1 @@ +This trace information is for all listeners diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter07/DebugAddIn/AssemblyInfo.vb new file mode 100644 index 0000000..65078ef --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/AssemblyInfo.vb @@ -0,0 +1,36 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +'TODO: Review the values of the assembly attributes + + + + + + + + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Revision +' Build Number +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + + + + + + +' Note: A strong name key has been generated. If you wish to use it, uncomment the following line: +' diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/Connect.vb b/Source/VisualStudio2002/Chapter07/DebugAddIn/Connect.vb new file mode 100644 index 0000000..fc4c4e6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/Connect.vb @@ -0,0 +1,83 @@ +Imports Microsoft.Office.Core +imports Extensibility +imports System.Runtime.InteropServices +Imports EnvDTE + +#Region " Read me for Add-in installation and setup information. " +' When run, the Add-in wizard prepared the registry for the Add-in. +' At a later time, if the Add-in becomes unavailable for reasons such as: +' 1) You moved this project to a computer other than which is was originally created on. +' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. +' 3) Registry corruption. +' you will need to re-register the Add-in by building the DebugAddInSetup project +' by right clicking the project in the Solution Explorer, then choosing install. +#End Region + + _ +Public Class Connect + + Implements Extensibility.IDTExtensibility2 + Implements IDTCommandTarget + + Dim applicationObject As EnvDTE.DTE + Dim addInInstance as EnvDTE.AddIn + + Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown + End Sub + + Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate + End Sub + + Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete + End Sub + + Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection + End Sub + + Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection + + applicationObject = CType(application, EnvDTE.DTE) + addInInstance = CType(addInInst, EnvDTE.AddIn) + If connectMode = Extensibility.ext_ConnectMode.ext_cm_UISetup Then + Dim objAddIn As AddIn = CType(addInInst, AddIn) + Dim CommandObj As Command + + ' When run, the Add-in wizard prepared the registry for the Add-in. + ' At a later time, the Add-in or its commands may become unavailable for reasons such as: + ' 1) You moved this project to a computer other than which is was originally created on. + ' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. + ' 3) You add new commands or modify commands already defined. + ' You will need to re-register the Add-in by building the DebugAddInSetup project, + ' right-clicking the project in the Solution Explorer, and then choosing install. + ' Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in + ' the project directory, or run 'devenv /setup' from a command prompt. + Try + CommandObj = applicationObject.Commands.AddNamedCommand(objAddIn, "DebugAddIn", "DebugAddIn", "Executes the command for DebugAddIn", True, 59, Nothing, 1 + 2) '1+2 == vsCommandStatusSupported+vsCommandStatusEnabled + CommandObj.AddControl(applicationObject.CommandBars.Item("Tools")) + Catch e as System.Exception + End Try + End If + End Sub + + Public Sub Exec(ByVal cmdName As String, ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object, ByRef handled As Boolean) Implements IDTCommandTarget.Exec + handled = False + If (executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault) Then + If cmdName = "DebugAddIn.Connect.DebugAddIn" Then + 'Here is the active code + MsgBox("The add-in debugging demo is born", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "Welcome") + handled = True + Exit Sub + End If + End If + End Sub + + Public Sub QueryStatus(ByVal cmdName As String, ByVal neededText As vsCommandStatusTextWanted, ByRef statusOption As vsCommandStatus, ByRef commandText As Object) Implements IDTCommandTarget.QueryStatus + If neededText = EnvDTE.vsCommandStatusTextWanted.vsCommandStatusTextWantedNone Then + If cmdName = "DebugAddIn.Connect.DebugAddIn" Then + statusOption = CType(vsCommandStatus.vsCommandStatusEnabled + vsCommandStatus.vsCommandStatusSupported, vsCommandStatus) + Else + statusOption = vsCommandStatus.vsCommandStatusUnsupported + End If + End If + End Sub +End Class diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.sln b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.sln new file mode 100644 index 0000000..79a3573 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugAddIn", "DebugAddIn.vbproj", "{535259D0-3BAD-4EA0-8E16-9FC33E98294F}" +EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DebugAddInSetup", "DebugAddInSetup\DebugAddInSetup.vdproj", "{456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Debug.ActiveCfg = Debug|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Debug.Build.0 = Debug|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Release.ActiveCfg = Release|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Release.Build.0 = Release|.NET + {456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}.Debug.ActiveCfg = Debug + {456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}.Release.ActiveCfg = Release + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.suo b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.suo new file mode 100644 index 0000000..959ddb2 Binary files /dev/null and b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.suo differ diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.vbproj b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.vbproj new file mode 100644 index 0000000..a218e6f --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.vbproj @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.vbproj.user b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.vbproj.user new file mode 100644 index 0000000..802dbed --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddIn.vbproj.user @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddInSetup/DebugAddInSetup.vdproj b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddInSetup/DebugAddInSetup.vdproj new file mode 100644 index 0000000..171587b --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/DebugAddInSetup/DebugAddInSetup.vdproj @@ -0,0 +1,1108 @@ +"DeployProject" +{ +"VSVersion" = "3:700" +"ProjectType" = "8:{5443560c-dbb4-11d2-8724-00a0c9a8b90c}" +"IsWebType" = "8:FALSE" +"ProjectName" = "8:DebugAddInSetup" +"LanguageId" = "3:1033" +"CodePage" = "3:1252" +"UILanguageId" = "3:1033" +"SccProjectName" = "8:" +"SccLocalPath" = "8:" +"SccAuxPath" = "8:" +"SccProvider" = "8:" + "Hierarchy" + { + "Entry" + { + "MsmKey" = "8:_0D33446DB35ABE39380F913BAE2C5E18" + "OwnerKey" = "8:_BCD80AE2D938269E96F87AF8A272F370" + "MsmSig" = "8:office_736ce26e3972ad23e1298f97ce43db19" + } + "Entry" + { + "MsmKey" = "8:_0D33446DB35ABE39380F913BAE2C5E18" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:office_736ce26e3972ad23e1298f97ce43db19" + } + "Entry" + { + "MsmKey" = "8:_558FE741FD1E46CE401F7BA1D72B6167" + "OwnerKey" = "8:_BCD80AE2D938269E96F87AF8A272F370" + "MsmSig" = "8:C:\\PROGRAM FILES\\COMMON FILES\\MICROSOFT SHARED\\MSENV\\DTE.OLB" + } + "Entry" + { + "MsmKey" = "8:_678125EF90053A6ECC714C2E5364CE99" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:extensibility_8c9c6e3362c636948ff73615c81d6576" + } + "Entry" + { + "MsmKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:C:\\DOCUMENTS AND SETTINGS\\ADMINISTRATOR\\MY DOCUMENTS\\VISUAL STUDIO PROJECTS\\DEBUGADDIN\\OBJ\\DEBUG\\DEBUGADDIN.DLL" + } + "Entry" + { + "MsmKey" = "8:_BCD80AE2D938269E96F87AF8A272F370" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:envdte_d890e65cda365bb06db21a11aabba008" + } + "Entry" + { + "MsmKey" = "8:_F293FC85A07EACA34FA466B4955CB861" + "OwnerKey" = "8:_BCD80AE2D938269E96F87AF8A272F370" + "MsmSig" = "8:stdole_c209afdbbe385f6128d9c8ea2a9f992d" + } + "Entry" + { + "MsmKey" = "8:_F293FC85A07EACA34FA466B4955CB861" + "OwnerKey" = "8:_0D33446DB35ABE39380F913BAE2C5E18" + "MsmSig" = "8:stdole_c209afdbbe385f6128d9c8ea2a9f992d" + } + "Entry" + { + "MsmKey" = "8:_FD15B18949EE432D83E8F0BE5E724F4B" + "OwnerKey" = "8:_678125EF90053A6ECC714C2E5364CE99" + "MsmSig" = "8:mondo.E4183BB4_18A8_11D5_A549_0090278A1BB8" + } + "Entry" + { + "MsmKey" = "8:_FD15B18949EE432D83E8F0BE5E724F4B" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:mondo.E4183BB4_18A8_11D5_A549_0090278A1BB8" + } + "Entry" + { + "MsmKey" = "8:_FD15B18949EE432D83E8F0BE5E724F4B" + "OwnerKey" = "8:_0D33446DB35ABE39380F913BAE2C5E18" + "MsmSig" = "8:mondo.E4183BB4_18A8_11D5_A549_0090278A1BB8" + } + "Entry" + { + "MsmKey" = "8:_FD15B18949EE432D83E8F0BE5E724F4B" + "OwnerKey" = "8:_BCD80AE2D938269E96F87AF8A272F370" + "MsmSig" = "8:mondo.E4183BB4_18A8_11D5_A549_0090278A1BB8" + } + "Entry" + { + "MsmKey" = "8:_FD15B18949EE432D83E8F0BE5E724F4B" + "OwnerKey" = "8:_F293FC85A07EACA34FA466B4955CB861" + "MsmSig" = "8:mondo.E4183BB4_18A8_11D5_A549_0090278A1BB8" + } + } + "Configurations" + { + "Debug" + { + "DisplayName" = "8:Debug" + "IsDebugOnly" = "11:TRUE" + "IsReleaseOnly" = "11:FALSE" + "OutputFilename" = "8:Debug\\DebugAddInSetup.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + "Release" + { + "DisplayName" = "8:Release" + "IsDebugOnly" = "11:FALSE" + "IsReleaseOnly" = "11:TRUE" + "OutputFilename" = "8:Release\\DebugAddInSetup.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + } + "Deployable" + { + "CustomAction" + { + } + "DefaultFeature" + { + "Name" = "8:DefaultFeature" + "Title" = "8:" + "Description" = "8:" + } + "Feature" + { + } + "File" + { + "{C7BF5952-4B9D-11D3-8E24-00C04F6837D0}:_0D33446DB35ABE39380F913BAE2C5E18" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Office, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_0D33446DB35ABE39380F913BAE2C5E18" + { + "Name" = "8:Office.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Office.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{54DA9790-1474-11D3-8E00-00C04F6837D0}:_558FE741FD1E46CE401F7BA1D72B6167" + { + "Signature" = "8:20000000002ea1978b95c101909bd683af14c201002ea1978b95c1010000000000e0050000000000000000006400740065002e006f006c006200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + "SourcePath" = "8:dte.olb" + "TargetName" = "8:dte.olb" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{C7BF5952-4B9D-11D3-8E24-00C04F6837D0}:_678125EF90053A6ECC714C2E5364CE99" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Extensibility, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_678125EF90053A6ECC714C2E5364CE99" + { + "Name" = "8:Extensibility.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Extensibility.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{C7BF5952-4B9D-11D3-8E24-00C04F6837D0}:_BCD80AE2D938269E96F87AF8A272F370" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_BCD80AE2D938269E96F87AF8A272F370" + { + "Name" = "8:EnvDTE.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:EnvDTE.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{C7BF5952-4B9D-11D3-8E24-00C04F6837D0}:_F293FC85A07EACA34FA466B4955CB861" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:TRUE" + "AssemblyAsmDisplayName" = "8:stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_F293FC85A07EACA34FA466B4955CB861" + { + "Name" = "8:stdole.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:stdole.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + } + "FileType" + { + } + "Folder" + { + "{777C097F-0ED8-11D3-8D6C-00A0C9CFCEE6}:_752873E334AC42F28BA930688B96759E" + { + "Name" = "8:#1919" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:ProgramMenuFolder" + "Folders" + { + } + } + "{777C097F-0ED8-11D3-8D6C-00A0C9CFCEE6}:_B77B8CC82F544E14958EA25C687EBC48" + { + "Name" = "8:#1916" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:DesktopFolder" + "Folders" + { + } + } + "{EE62640D-12F2-11D3-8D6C-00A0C9CFCEE6}:_CDE300ED3B194097AE33ECB71ECE9B7F" + { + "DefaultLocation" = "8:[ProgramFilesFolder][Manufacturer]\\[ProductName]" + "Name" = "8:#1925" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:TARGETDIR" + "Folders" + { + } + } + } + "LaunchCondition" + { + "{B26CFB94-18E3-45BF-8D42-933BDAF5E76C}:_0DEF9CE8DF624E3593347BAA24F85D79" + { + "Name" = "8:MsiNetAssemblySupport" + "Condition" = "8:MsiNetAssemblySupport" + "Message" = "8:[VSDNETMSG]" + } + } + "Locator" + { + } + "Shortcut" + { + } + "Sequences" + { + } + "Registry" + { + "HKLM" + { + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_D8629588BB434B99AFF1B48A49CB55F6" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_69989357966443E881ABD5623DDA1BE3" + { + "Name" = "8:Microsoft" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_09A6D1EA72204C8F95507099738A41DE" + { + "Name" = "8:VSA" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_273AAC7056794D72975B80AA8D6C91D0" + { + "Name" = "8:7.0" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_F83464988848477BAF60E13BD25C51A0" + { + "Name" = "8:AddIns" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_760A9241284549849D704A7092BB9869" + { + "Name" = "8:DebugAddIn.Connect" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_11947A1EA185469590A77AF750773B0E" + { + "Name" = "8:Description" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Demonstrate add-in debugging" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_3E878CE40D6141BC8DA290F9FB5D7D60" + { + "Name" = "8:LoadBehavior" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_7A2F3F5E81E24C36BBD71FA51E9462B8" + { + "Name" = "8:AboutBoxIcon" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:4" + "Value" = "8:0000010002002020100000000000E8020000260000001010100000000000280100000E0300002800000020000000400000000100040000000000800200000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ABA00000000000000000000000000000BAB00000000000000000000000000000ABA00000000000000000000000F00000BAB00000000000008888888888F0ABABABABABA0000000008F77777777F0BABABABABAB0000000008F77777777F0ABABABABABA0000000008F77777777F00000BAB00000000000008F77777777FFFFF0ABA00000008880008F777777777777F0BAB00000887788008F777777777777F0ABA000008FF770778F777777777777F0000000008FFF78088F777777777777FFFFFF000008FF70008F7777777777777777800000008880008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008FFFFFFFFFFFFFFFFF800000000000008888888888888888888000000000000000000870000008700000000000000000000008F0000008F000000000000000000000008000000080000000000000000000000808000008080000000000000000000877788008777880000000000000000008FF778008FF7780000000000000000008FFF78008FFF7800000000000000000008FF700008FF7000000000000000000000777000007770000000000000000000000000000000000000000FFFFFFFFFFFFFE0FFFFFFE0FFFFFFE0FFFFFFE0FFF000000FF000000FF000000FF000000FF000000C700000F8300000F0000000F0000000F0000000F8300000FC700000FFF00000FFF00000FFF00000FFF00000FFF00000FFFF8F8FFFFF8F8FFFFF8F8FFFFF0707FFFE0203FFFE0203FFFE0203FFFF0707FFFF8F8FFFFFFFFFF2800000010000000200000000100040000000000C00000000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000000000000000000000000000A000000000000000B00000000000F0ABABA000008F88F000B00000008F77FFF0A00070708F7777F000000F008F7777FFFF0070708F777777800000008FFFFFFF800000008888888880000000000000000000000000070700000000000000F00000000000000707000000FFFF0000FFE30000FFE30000FF800000F0000000F0000000F0030000100300000003000010030000F0030000F0030000FF7F0000FE3F0000FE3F0000FE3F0000" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_8FEFF79061BA49B08795EDCEF0FAD25C" + { + "Name" = "8:CommandLineSafe" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:0" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_A7C4E07C9B3049C28FB2C27A063E04F1" + { + "Name" = "8:FriendlyName" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Debug AddIn" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_AE28F0AFA43741458B1449FB88335D41" + { + "Name" = "8:CommandPreload" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_DC92F045E0DD4F048CC51E5AEB57B049" + { + "Name" = "8:AboutBoxDetails" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:This Visual Studio .NET add-in is a debugging demonstration" + } + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_EFB6A2CFDF204BFF845AFADBF144FB32" + { + "Name" = "8:VisualStudio" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_5D224508FB724B778F87AE714E8EB555" + { + "Name" = "8:7.0" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_0D86E33CA23741F8BBD2C390AC4ED8B6" + { + "Name" = "8:AddIns" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_F9CE86043D2B48369CE7E86AA726972E" + { + "Name" = "8:DebugAddIn.Connect" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_058E8ADEBEBC4DA5BFA240CF913CD84C" + { + "Name" = "8:AboutBoxIcon" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:4" + "Value" = "8:0000010002002020100000000000E8020000260000001010100000000000280100000E0300002800000020000000400000000100040000000000800200000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ABA00000000000000000000000000000BAB00000000000000000000000000000ABA00000000000000000000000F00000BAB00000000000008888888888F0ABABABABABA0000000008F77777777F0BABABABABAB0000000008F77777777F0ABABABABABA0000000008F77777777F00000BAB00000000000008F77777777FFFFF0ABA00000008880008F777777777777F0BAB00000887788008F777777777777F0ABA000008FF770778F777777777777F0000000008FFF78088F777777777777FFFFFF000008FF70008F7777777777777777800000008880008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008FFFFFFFFFFFFFFFFF800000000000008888888888888888888000000000000000000870000008700000000000000000000008F0000008F000000000000000000000008000000080000000000000000000000808000008080000000000000000000877788008777880000000000000000008FF778008FF7780000000000000000008FFF78008FFF7800000000000000000008FF700008FF7000000000000000000000777000007770000000000000000000000000000000000000000FFFFFFFFFFFFFE0FFFFFFE0FFFFFFE0FFFFFFE0FFF000000FF000000FF000000FF000000FF000000C700000F8300000F0000000F0000000F0000000F8300000FC700000FFF00000FFF00000FFF00000FFF00000FFF00000FFFF8F8FFFFF8F8FFFFF8F8FFFFF0707FFFE0203FFFE0203FFFE0203FFFF0707FFFF8F8FFFFFFFFFF2800000010000000200000000100040000000000C00000000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000000000000000000000000000A000000000000000B00000000000F0ABABA000008F88F000B00000008F77FFF0A00070708F7777F000000F008F7777FFFF0070708F777777800000008FFFFFFF800000008888888880000000000000000000000000070700000000000000F00000000000000707000000FFFF0000FFE30000FFE30000FF800000F0000000F0000000F0030000100300000003000010030000F0030000F0030000FF7F0000FE3F0000FE3F0000FE3F0000" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_66BFFC4A036F475F8630545DE4F7F84E" + { + "Name" = "8:AboutBoxDetails" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:This Visual Studio .NET add-in is a debugging demonstration" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_94963B340CE84207BF19AA8403B83E9B" + { + "Name" = "8:CommandLineSafe" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:0" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_B6F46FA7092B4CB19031659BD70DB93C" + { + "Name" = "8:Description" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Demonstrate add-in debugging" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_BDFB3C729CE84D42AECADBDAA31673F4" + { + "Name" = "8:LoadBehavior" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_D50A998B828C4589BFABB1E3E4BD6D56" + { + "Name" = "8:CommandPreload" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{B73D4F5A-FF29-11D2-8D6B-00A0C9CFCEE6}:_F5DE8AC508494456A4773705B4A1C6FD" + { + "Name" = "8:FriendlyName" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Debug AddIn" + } + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCU" + { + "Keys" + { + "{7DF0CD0A-FF27-11D2-8D6B-00A0C9CFCEE6}:_6B40E74C6A3648E19EC5C00FD7DA0A53" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + } + "HKCR" + { + "Keys" + { + } + } + "HKU" + { + "Keys" + { + } + } + "HKPU" + { + "Keys" + { + } + } + } + "ProjectOutput" + { + "{B1E2BB22-187D-11D3-8E02-00C04F6837D0}:_A18D22CB7CF548E99EF4F3A51C564401" + { + "SourcePath" = "8:..\\obj\\Debug\\DebugAddIn.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + "ProjectOutputGroupRegister" = "3:2" + "OutputConfiguration" = "8:" + "OutputGroupCanonicalName" = "8:Built" + "OutputProjectCanonicalName" = "8:DebugAddIn.vbproj" + "OutputProjectGuid" = "8:{535259D0-3BAD-4EA0-8E16-9FC33E98294F}" + "ShowKeyOutput" = "11:TRUE" + "ExcludeFilters" + { + } + } + } + "Product" + { + "Name" = "8:Microsoft Visual Studio" + "ProductName" = "8:DebugAddInSetup" + "ProductCode" = "8:{3D050B02-F6BD-4803-BCF5-8FE325A4F971}" + "PackageCode" = "8:{7E2C78B2-2B27-4375-BD94-1DCCD3675BAC}" + "UpgradeCode" = "8:{6FB60611-7F9C-44AB-8E9B-799CE6399B7D}" + "RestartWWWService" = "11:FALSE" + "RemovePreviousVersions" = "11:FALSE" + "DetectNewerInstalledVersion" = "11:TRUE" + "ProductVersion" = "8:1.0.0" + "Manufacturer" = "8:Sleek Software Ltd" + "ARPHELPTELEPHONE" = "8:" + "ARPHELPLINK" = "8:" + "Title" = "8:DebugAddInSetup" + "Subject" = "8:" + "ARPCONTACT" = "8:Sleek Software Ltd" + "Keywords" = "8:" + "ARPCOMMENTS" = "8:" + "ARPURLINFOABOUT" = "8:" + "ARPPRODUCTICON" = "8:" + "ARPIconIndex" = "3:0" + "SearchPath" = "8:" + "UseSystemSearchPath" = "11:TRUE" + } + "MsiBootstrapper" + { + "LangId" = "3:1033" + } + "MergeModule" + { + "{AC8774A4-3E09-11D3-8E14-00C04F6837D0}:_FD15B18949EE432D83E8F0BE5E724F4B" + { + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:TRUE" + "SourcePath" = "8:dotnetfxredist_x86_enu.msm" + "ModuleSignature" = "8:mondo.E4183BB4_18A8_11D5_A549_0090278A1BB8" + "Properties" + { + } + "LanguageId" = "3:1033" + "Exclude" = "11:TRUE" + "Folder" = "8:" + "Feature" = "8:" + "IsolateTo" = "8:" + } + } + "UserInterface" + { + "{E4ECAB26-4AB7-11D3-8D78-00A0C9CFCEE6}:_6218B88E89FE478E8B64EE267D46CFB2" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdUserInterface.wim" + "ModuleSignature" = "8:VsdUserInterface.524F4245_5254_5341_4C45_534153783400" + } + "{7DFFC192-4ABE-11D3-8D78-00A0C9CFCEE6}:_6C6A2019794A428AAC594CF1F4D0D8D0" + { + "Name" = "8:#1901" + "Sequence" = "3:2" + "Attributes" = "3:2" + "Dialogs" + { + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_3DDA4B78A4D44F9EA0C350450DFFBB62" + { + "Sequence" = "3:100" + "DisplayName" = "8:Progress" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminProgressDlg.wid" + "ModuleSignature" = "8:VsdDialogs.EE9A1AFA_41DD_4514_B727_DF0ACA1D7389" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{7DFFC192-4ABE-11D3-8D78-00A0C9CFCEE6}:_7B0B0E38D1C04BFAB059184A451012ED" + { + "Name" = "8:#1902" + "Sequence" = "3:2" + "Attributes" = "3:3" + "Dialogs" + { + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_032AE689439C4F52B1646CEC625D44BA" + { + "Sequence" = "3:100" + "DisplayName" = "8:Finished" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFinishedDlg.wid" + "ModuleSignature" = "8:VsdDialogs.83D22742_1B79_46f6_9A99_DF0F2BD4C077" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{7DFFC192-4ABE-11D3-8D78-00A0C9CFCEE6}:_9A854B9E75D447AC8A77C302D70B2349" + { + "Name" = "8:#1902" + "Sequence" = "3:1" + "Attributes" = "3:3" + "Dialogs" + { + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_182877F5792B4153B0623805DCD78B2E" + { + "Sequence" = "3:100" + "DisplayName" = "8:Finished" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFinishedDlg.wid" + "ModuleSignature" = "8:VsdDialogs.1DB77F5A_BA5C_4470_89B6_0B0EC07E3A10" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{7DFFC192-4ABE-11D3-8D78-00A0C9CFCEE6}:_B0D7A8425A044AC494921E9159923DDA" + { + "Name" = "8:#1900" + "Sequence" = "3:2" + "Attributes" = "3:1" + "Dialogs" + { + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_3419C658202E4141A292F8097FA90D51" + { + "Sequence" = "3:200" + "DisplayName" = "8:Installation Folder" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFolderDlg.wid" + "ModuleSignature" = "8:VsdDialogs.2DED2424_5429_4616_A1AD_4D62837C2ADA" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_3D47C35321644641B44D8910FFCD10AC" + { + "Sequence" = "3:100" + "DisplayName" = "8:Welcome" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminWelcomeDlg.wid" + "ModuleSignature" = "8:VsdDialogs.E35A0E2C_F131_4B57_B946_59A1A2A8F45F" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_50A57E1AB4AB486AA7FE6F9D752B8383" + { + "Sequence" = "3:300" + "DisplayName" = "8:Confirm Installation" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminConfirmDlg.wid" + "ModuleSignature" = "8:VsdDialogs.FA58E60A_A1E8_4876_95FC_2AC3B5AAA5F8" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{7DFFC192-4ABE-11D3-8D78-00A0C9CFCEE6}:_B866188749924DE390D758D413B13E1D" + { + "Name" = "8:#1901" + "Sequence" = "3:1" + "Attributes" = "3:2" + "Dialogs" + { + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_9FF09CF32AA4497DAA0CF1AD1051F8EF" + { + "Sequence" = "3:100" + "DisplayName" = "8:Progress" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdProgressDlg.wid" + "ModuleSignature" = "8:VsdDialogs.4FB12620_0D15_42D0_8677_2766FFA6923F" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{E4ECAB26-4AB7-11D3-8D78-00A0C9CFCEE6}:_C354EEFC52134F47A537732481755B06" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdBasicDialogs.wim" + "ModuleSignature" = "8:VsdDialogs.CE4B864F_F1C1_4B85_98D4_2A2BF5FFB12B" + } + "{7DFFC192-4ABE-11D3-8D78-00A0C9CFCEE6}:_CE2DB2EACD34479992CADC4C0326386E" + { + "Name" = "8:#1900" + "Sequence" = "3:1" + "Attributes" = "3:1" + "Dialogs" + { + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_4EEE0209AC304F7981534B738F1E4D14" + { + "Sequence" = "3:100" + "DisplayName" = "8:Welcome" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdWelcomeDlg.wid" + "ModuleSignature" = "8:VsdDialogs.68F69290_BB7C_474E_A153_6679845F3DDF" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_51687977F6BE4225ADB22755AA7A8AF8" + { + "Sequence" = "3:200" + "DisplayName" = "8:Installation Folder" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFolderDlg.wid" + "ModuleSignature" = "8:VsdDialogs.C113BC36_2532_4D45_8099_4818B1133B2F" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{E4ECAB24-4AB7-11D3-8D78-00A0C9CFCEE6}:_917F1F1053AC478B9AB035F9D81BB6F9" + { + "Sequence" = "3:300" + "DisplayName" = "8:Confirm Installation" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdConfirmDlg.wid" + "ModuleSignature" = "8:VsdDialogs.6DBC9783_3677_4D68_8BF5_D749558A0AC1" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + } + } +} diff --git a/Source/VisualStudio2002/Chapter07/DebugAddIn/ReCreateCommands.reg b/Source/VisualStudio2002/Chapter07/DebugAddIn/ReCreateCommands.reg new file mode 100644 index 0000000..1b4cb3f --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/DebugAddIn/ReCreateCommands.reg @@ -0,0 +1,5 @@ +REGEDIT4 +[HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSA\7.0\PreloadAddinState] +"DebugAddIn.Connect"=dword:1 +[HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\7.0\PreloadAddinState] +"DebugAddIn.Connect"=dword:1 diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter07/NumericTextBox/AssemblyInfo.vb new file mode 100644 index 0000000..8741dfc --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/ControlContainer.resx b/Source/VisualStudio2002/Chapter07/NumericTextBox/ControlContainer.resx new file mode 100644 index 0000000..d10f386 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/ControlContainer.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + ControlContainer + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/ControlContainer.vb b/Source/VisualStudio2002/Chapter07/NumericTextBox/ControlContainer.vb new file mode 100644 index 0000000..bb29be2 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/ControlContainer.vb @@ -0,0 +1,66 @@ +Option Strict On + +Public Class ControlContainer + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Switch on control debugging + Me.CustomControl.DebugMode = True + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents CustomControl As DebugDemo.NumericTextBox + Private Sub InitializeComponent() + Me.CustomControl = New DebugDemo.NumericTextBox() + Me.SuspendLayout() + ' + 'CustomControl + ' + Me.CustomControl.DebugMode = False + Me.CustomControl.Location = New System.Drawing.Point(80, 112) + Me.CustomControl.Name = "CustomControl" + Me.CustomControl.TabIndex = 0 + Me.CustomControl.Text = "" + ' + 'ControlContainer + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.CustomControl}) + Me.Name = "ControlContainer" + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub ShowDebugMessage(ByVal DebugMethod As String, ByVal DebugComment As String) Handles CustomControl.DebugMessage + 'Show the debug message whenever user types non-numeric character + MsgBox(DebugComment, MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, DebugMethod) + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBox.resx b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBox.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBox.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBox.vb b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBox.vb new file mode 100644 index 0000000..3a73386 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBox.vb @@ -0,0 +1,11 @@ +Imports System.Windows.Forms + +Public Class NumericTextBox : Inherits TextBox + + Private Sub NumericTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress + If e.KeyChar < "0"c Or e.KeyChar > "9"c Then + e.Handled = True + End If + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.sln b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.sln new file mode 100644 index 0000000..9ee862d --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NumericTextBoxTest", "NumericTextBoxTest.vbproj", "{8A595660-BB97-4824-AD3F-43500C201AB4}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8A595660-BB97-4824-AD3F-43500C201AB4}.Debug.ActiveCfg = Debug|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Debug.Build.0 = Debug|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Release.ActiveCfg = Release|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(SolutionItems) = postSolution + Item:1 = ..\DebugDemoControl\NumericTextBox.vb + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.suo b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.suo new file mode 100644 index 0000000..88a0ad1 Binary files /dev/null and b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.suo differ diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj new file mode 100644 index 0000000..fd5cf7e --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj.user b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj.user new file mode 100644 index 0000000..7d7a099 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/NumericTextBox/obj/Debug/WindowsApplication10.ControlContainer.resources b/Source/VisualStudio2002/Chapter07/NumericTextBox/obj/Debug/WindowsApplication10.ControlContainer.resources new file mode 100644 index 0000000..7d2717a Binary files /dev/null and b/Source/VisualStudio2002/Chapter07/NumericTextBox/obj/Debug/WindowsApplication10.ControlContainer.resources differ diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter07/SortingDebug/AssemblyInfo.vb new file mode 100644 index 0000000..e68a407 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemo.sln b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemo.sln new file mode 100644 index 0000000..b71c4dc --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemo.sln @@ -0,0 +1,33 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoLogic", "SortingDll\DebugDemoLogic.vbproj", "{057FA2D6-5280-4393-BE33-C6631BA07451}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoForm", "DebugDemoForm.vbproj", "{1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + ConfigName.2 = ReleaseCustom + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.0 = {057FA2D6-5280-4393-BE33-C6631BA07451} + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.ActiveCfg = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.Build.0 = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.ActiveCfg = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.Build.0 = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.ActiveCfg = ReleaseCustom|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.Build.0 = ReleaseCustom|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.ActiveCfg = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.Build.0 = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.Build.0 = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemo.suo b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemo.suo new file mode 100644 index 0000000..f2fedcf Binary files /dev/null and b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemo.suo differ diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemoForm.vbproj b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemoForm.vbproj new file mode 100644 index 0000000..1eff798 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemoForm.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemoForm.vbproj.user b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemoForm.vbproj.user new file mode 100644 index 0000000..7d7a099 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/DebugDemoForm.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/DemoForm.resx b/Source/VisualStudio2002/Chapter07/SortingDebug/DemoForm.resx new file mode 100644 index 0000000..363456d --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/DemoForm.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + Assembly + + + True + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + DebugDemo + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/DemoForm.vb b/Source/VisualStudio2002/Chapter07/SortingDebug/DemoForm.vb new file mode 100644 index 0000000..cf4ee1a --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/DemoForm.vb @@ -0,0 +1,207 @@ +Public Class DebugDemo + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents lblTwo As System.Windows.Forms.Label + Friend WithEvents lblOne As System.Windows.Forms.Label + Friend WithEvents boxSort As System.Windows.Forms.GroupBox + Friend WithEvents Timing As System.Windows.Forms.Label + Friend WithEvents StartSort As System.Windows.Forms.Button + Friend WithEvents MaxValue As System.Windows.Forms.TextBox + Friend WithEvents NumberItems As System.Windows.Forms.TextBox + Friend WithEvents SortCounting As System.Windows.Forms.RadioButton + Friend WithEvents SortQuick As System.Windows.Forms.RadioButton + Friend WithEvents SortSelection As System.Windows.Forms.RadioButton + Friend WithEvents SortBubble As System.Windows.Forms.RadioButton + Private Sub InitializeComponent() + Me.lblTwo = New System.Windows.Forms.Label() + Me.lblOne = New System.Windows.Forms.Label() + Me.StartSort = New System.Windows.Forms.Button() + Me.MaxValue = New System.Windows.Forms.TextBox() + Me.NumberItems = New System.Windows.Forms.TextBox() + Me.boxSort = New System.Windows.Forms.GroupBox() + Me.SortCounting = New System.Windows.Forms.RadioButton() + Me.SortQuick = New System.Windows.Forms.RadioButton() + Me.SortSelection = New System.Windows.Forms.RadioButton() + Me.SortBubble = New System.Windows.Forms.RadioButton() + Me.Timing = New System.Windows.Forms.Label() + Me.boxSort.SuspendLayout() + Me.SuspendLayout() + ' + 'lblTwo + ' + Me.lblTwo.Location = New System.Drawing.Point(32, 96) + Me.lblTwo.Name = "lblTwo" + Me.lblTwo.Size = New System.Drawing.Size(112, 30) + Me.lblTwo.TabIndex = 14 + Me.lblTwo.Text = "Max item value" + ' + 'lblOne + ' + Me.lblOne.Location = New System.Drawing.Point(32, 40) + Me.lblOne.Name = "lblOne" + Me.lblOne.Size = New System.Drawing.Size(112, 30) + Me.lblOne.TabIndex = 12 + Me.lblOne.Text = "Number of items" + ' + 'StartSort + ' + Me.StartSort.Location = New System.Drawing.Point(280, 285) + Me.StartSort.Name = "StartSort" + Me.StartSort.Size = New System.Drawing.Size(92, 39) + Me.StartSort.TabIndex = 10 + Me.StartSort.Text = "Start sort" + ' + 'MaxValue + ' + Me.MaxValue.Location = New System.Drawing.Point(160, 96) + Me.MaxValue.Name = "MaxValue" + Me.MaxValue.Size = New System.Drawing.Size(72, 22) + Me.MaxValue.TabIndex = 13 + Me.MaxValue.Text = "10000" + ' + 'NumberItems + ' + Me.NumberItems.Location = New System.Drawing.Point(160, 40) + Me.NumberItems.Name = "NumberItems" + Me.NumberItems.Size = New System.Drawing.Size(72, 22) + Me.NumberItems.TabIndex = 11 + Me.NumberItems.Text = "1000" + ' + 'boxSort + ' + Me.boxSort.Controls.AddRange(New System.Windows.Forms.Control() {Me.SortCounting, Me.SortQuick, Me.SortSelection, Me.SortBubble}) + Me.boxSort.Location = New System.Drawing.Point(280, 16) + Me.boxSort.Name = "boxSort" + Me.boxSort.Size = New System.Drawing.Size(232, 247) + Me.boxSort.TabIndex = 9 + Me.boxSort.TabStop = False + Me.boxSort.Text = "Sort algorithm" + ' + 'SortCounting + ' + Me.SortCounting.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortCounting.Location = New System.Drawing.Point(41, 178) + Me.SortCounting.Name = "SortCounting" + Me.SortCounting.Size = New System.Drawing.Size(164, 29) + Me.SortCounting.TabIndex = 3 + Me.SortCounting.Text = "Counting sort" + ' + 'SortQuick + ' + Me.SortQuick.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortQuick.Location = New System.Drawing.Point(41, 128) + Me.SortQuick.Name = "SortQuick" + Me.SortQuick.Size = New System.Drawing.Size(164, 30) + Me.SortQuick.TabIndex = 2 + Me.SortQuick.Text = "Quick sort" + ' + 'SortSelection + ' + Me.SortSelection.Location = New System.Drawing.Point(41, 79) + Me.SortSelection.Name = "SortSelection" + Me.SortSelection.Size = New System.Drawing.Size(164, 30) + Me.SortSelection.TabIndex = 1 + Me.SortSelection.Text = "Selection sort" + ' + 'SortBubble + ' + Me.SortBubble.Checked = True + Me.SortBubble.Location = New System.Drawing.Point(41, 30) + Me.SortBubble.Name = "SortBubble" + Me.SortBubble.Size = New System.Drawing.Size(164, 29) + Me.SortBubble.TabIndex = 0 + Me.SortBubble.TabStop = True + Me.SortBubble.Text = "Bubble sort" + ' + 'Timing + ' + Me.Timing.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.Timing.Location = New System.Drawing.Point(400, 288) + Me.Timing.Name = "Timing" + Me.Timing.Size = New System.Drawing.Size(112, 32) + Me.Timing.TabIndex = 15 + ' + 'DebugDemo + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(544, 348) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Timing, Me.lblTwo, Me.lblOne, Me.StartSort, Me.MaxValue, Me.NumberItems, Me.boxSort}) + Me.Name = "DebugDemo" + Me.Text = "Debug demo" + Me.boxSort.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private m_SortType As DemoSort.SortType = DemoSort.SortType.BubbleSort + + Private Sub StartSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartSort.Click + Dim SortObject As New DemoSort() + + 'Show that we're busy + Cursor.Current = Cursors.WaitCursor + Me.StartSort.Enabled = False + + 'Build a list to sort + Me.Timing.Text = "Building list to sort..." + Me.Timing.Refresh() + SortObject.ListBuild(Convert.ToInt32(Me.NumberItems.Text), 1, Convert.ToInt32(Me.MaxValue.Text)) + + 'Do the sort and report timing + Me.Timing.Text = "Performing sort..." + Me.Timing.Refresh() + Me.Timing.Text = SortObject.DoSort(m_SortType).ToString & " seconds" + + 'Show that we've finished + Me.StartSort.Enabled = True + Cursor.Current = Cursors.Default + + End Sub + + Private Sub SortBubble_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortBubble.CheckedChanged + m_SortType = DemoSort.SortType.BubbleSort + End Sub + + Private Sub SortSelection_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortSelection.CheckedChanged + m_SortType = DemoSort.SortType.SelectionSort + End Sub + + Private Sub SortQuick_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortQuick.CheckedChanged + m_SortType = DemoSort.SortType.QuickSort + End Sub + + Private Sub SortCounting_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortCounting.CheckedChanged + m_SortType = DemoSort.SortType.CountingSort + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/AssemblyInfo.vb new file mode 100644 index 0000000..240f036 --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/AssemblyInfo.vb @@ -0,0 +1,30 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj new file mode 100644 index 0000000..498d34a --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj.user b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj.user new file mode 100644 index 0000000..ff746ab --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj.user @@ -0,0 +1,64 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DemoSort.vb b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DemoSort.vb new file mode 100644 index 0000000..038eb8a --- /dev/null +++ b/Source/VisualStudio2002/Chapter07/SortingDebug/SortingDll/DemoSort.vb @@ -0,0 +1,265 @@ +Option Strict On + +Public Class DemoSort + + 'These are the sorting lists + Private ListUnsorted() As Int32 + Private ListBeingSorted() As Int32 + 'These are max and minimum sort settings + Private ListLengthMin As Int32 + Private ListLengthMax As Int32 + Private ListValueMin As Int32 + Private ListValueMax As Int32 + + Public Enum SortType As Integer + BubbleSort = 1 + SelectionSort = 2 + QuickSort = 3 + CountingSort = 4 + End Enum + + Public Sub ListBuild(ByVal ListLength As Int32, ByVal ValueMin As Int32, ByVal ValueMax As Int32) + Dim ArrayItem As Int32, objRandom As New System.Random(1) + + 'If parameters haven't changed, just use previous list + 'This enables multiple timing checks on an identical array + If ListLength = ListLengthMax And ValueMin = ListValueMin And ValueMax = ListValueMax Then + Exit Sub + End If + + 'Build a new list with given parameters + ReDim ListUnsorted(ListLength) + For ArrayItem = 1 To ListLength + ListUnsorted(ArrayItem) = objRandom.Next(ValueMin, ValueMax) + Next ArrayItem + + 'Set length of sorted list to match + ReDim ListBeingSorted(ListLength) + + 'Store min and max list items and values + ListLengthMin = 1 + ListLengthMax = ListLength + ListValueMin = ValueMin + ListValueMax = ValueMax + + End Sub + + Public Function DoSort(ByVal Sort As SortType) As Double + Dim TimeStart As Int32, TimeFinish As Int32, ArrayItem As Int32 + + 'Copy to array that will contain newly-sorted list + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ArrayItem) = ListUnsorted(ArrayItem) + Next + + 'Start the clock so we can report how long the sorting took + TimeStart = System.Environment.TickCount() + + 'Do the sort + Select Case Sort + Case SortType.BubbleSort + SortBubble(ListLengthMin, ListLengthMax) + Case SortType.QuickSort + SortQuick(ListLengthMin, ListLengthMax) + Case SortType.SelectionSort + SortSelection() + Case SortType.CountingSort + SortCounting() + Case Else + Trace.Fail(CStr(Sort) & " is an invalid sort type") + End Select + + 'Stop the clock and report how long the sorting took + TimeFinish = System.Environment.TickCount() + 'Check sort + SortCheck() + 'Convert elapsed time into seconds + Return (TimeFinish - TimeStart) / 1000 + + End Function + + Private Sub SortBubble(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim intLastSwap As Int32, intLoop1 As Int32, intLoop2 As Int32 + Dim intDrop As Int32 + + 'Repeat until we are done + Do While ItemLow < ItemHigh + + 'First bubble upwards + intLastSwap = ItemLow - 1 + intLoop1 = ItemLow + 1 + + Do While intLoop1 <= ItemHigh + 'Find a bubble + If ListBeingSorted(intLoop1 - 1) > ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 - 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) < intDrop + ListBeingSorted(intLoop2 - 1) = ListBeingSorted(intLoop2) + intLoop2 += 1 + If intLoop2 > ItemHigh Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 - 1) = intDrop + intLastSwap = intLoop2 - 1 + intLoop1 = intLoop2 + 1 + Else + intLoop1 += 1 + End If + Loop + + 'Update maximum value + ItemHigh = intLastSwap - 1 + + 'Next bubble downwards + intLastSwap = ItemHigh + 1 + intLoop1 = ItemHigh - 1 + + Do While intLoop1 >= ItemLow + 'Find a bubble + If ListBeingSorted(intLoop1 + 1) < ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 + 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) > intDrop + ListBeingSorted(intLoop2 + 1) = ListBeingSorted(intLoop2) + intLoop2 -= 1 + If intLoop2 < ItemLow Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 + 1) = intDrop + intLastSwap = intLoop2 + 1 + intLoop1 = intLoop2 - 1 + Else + intLoop1 -= 1 + End If + Loop + + 'Update minimum value + ItemLow = intLastSwap + 1 + + Loop + + End Sub + + Private Sub SortSelection() + Dim LoopOuter As Int32, LoopInner As Int32, BestValue As Int32, BestInnerIndex As Int32 + + For LoopOuter = ListLengthMin To ListLengthMax - 1 + + 'Init lowest-value search + BestValue = ListBeingSorted(LoopOuter) + BestInnerIndex = LoopOuter + + 'Find lowest value that hasn't already been sorted + For LoopInner = LoopOuter + 1 To ListLengthMax + If ListBeingSorted(LoopInner) < BestValue Then + BestValue = ListBeingSorted(LoopInner) + 1 + BestInnerIndex = LoopInner + End If + Next LoopInner + + 'Swap lowest value into proper position + ListBeingSorted(BestInnerIndex) = ListBeingSorted(LoopOuter) + ListBeingSorted(LoopOuter) = BestValue + + Next LoopOuter + + End Sub + + Private Sub SortQuick(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim IntermediateValue As Int32, Position As Int32 + Dim objRandom As New System.Random() + Dim intLow As Int32, intHigh As Int32 + + 'If the list has only 1 element, it's already sorted + If ItemLow >= ItemHigh Then Exit Sub + + 'Pick a dividing item + Position = objRandom.Next(ItemLow, ItemHigh) + IntermediateValue = ListBeingSorted(Position) + + 'Swap it to the front so we can find it easily + ListBeingSorted(Position) = ListBeingSorted(ItemLow) + + 'Move the items smaller than this into the left + 'half of the list. Move the others into the right. + intLow = ItemLow + intHigh = ItemHigh + Do + 'Look down from low item for a value < IntermediateValue + Do While ListBeingSorted(intHigh) >= IntermediateValue + intHigh -= 1 + If intHigh <= intLow Then Exit Do + Loop + If intHigh <= intLow Then + ListBeingSorted(intLow) = IntermediateValue + Exit Do + End If + + 'Swap the low and high values + ListBeingSorted(intLow) = ListBeingSorted(intHigh) + + 'Look up from ItemLow for a value >= IntermediateValue + intLow += 1 + Do While ListBeingSorted(intLow) < IntermediateValue + intLow += 1 + If intLow >= intHigh Then Exit Do + Loop + If intLow >= intHigh Then + intLow = intHigh + ListBeingSorted(intHigh) = IntermediateValue + Exit Do + End If + + 'Swap the low and high items + ListBeingSorted(intHigh) = ListBeingSorted(intLow) + Loop + + 'Sort the two sublists recursively + SortQuick(ItemLow, intLow - 1) + SortQuick(intHigh + 1, ItemHigh) + + End Sub + + Private Sub SortCounting() + Dim ListCounts(ListValueMax) As Int32 + Dim ArrayItem As Int32, ThisCount As Int32, NextOffset As Int32 + + 'Count the items + For ArrayItem = ListLengthMin To ListLengthMax + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + 'Convert the ListCounts into offsets + NextOffset = ListLengthMin + For ArrayItem = ListValueMin To ListValueMax + ThisCount = ListCounts(ArrayItem) + ListCounts(ArrayItem) = NextOffset + NextOffset += ThisCount + Next ArrayItem + + 'Place the items in the sorted array + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ListCounts(ListUnsorted(ArrayItem))) = ListUnsorted(ArrayItem) + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + End Sub + + Private Function SortCheck() As Boolean + Dim ArrayItem As Int32 + + For ArrayItem = 2 To ListLengthMax + If ListBeingSorted(ArrayItem - 1) > ListBeingSorted(ArrayItem) Then + Trace.Fail("Item " & (ArrayItem - 1).ToString & " is larger than item " & ArrayItem.ToString) + Exit For + End If + Next ArrayItem + + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter07/SortingDebug/obj/Debug/DebugDemo.DebugDemo.resources b/Source/VisualStudio2002/Chapter07/SortingDebug/obj/Debug/DebugDemo.DebugDemo.resources new file mode 100644 index 0000000..24379ba Binary files /dev/null and b/Source/VisualStudio2002/Chapter07/SortingDebug/obj/Debug/DebugDemo.DebugDemo.resources differ diff --git a/Source/VisualStudio2002/Chapter08/ReadMe.txt b/Source/VisualStudio2002/Chapter08/ReadMe.txt new file mode 100644 index 0000000..638ecfa --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/ReadMe.txt @@ -0,0 +1,13 @@ +To setup the TimeService web service on your IIS web server, +use IIS to create a IIS virtual directory called TimeServer_2002, +pointing at the real folder C:\Inetpub\wwwroot\TimeServer_2002. +This real folder should have been created when you un-zipped +the zip file containing the source code. + +Then in Visual Studio 2002, load the TimeServer solution and set +a web reference to the TimeService web service (using the +Project...Add web reference menu item). The web service can be +found at the ISS virtual directory that you've just created. + + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServer.sln b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServer.sln new file mode 100644 index 0000000..6a41a06 --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServer.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServer", "http://localhost/TimeServer_2002/TimeServer.vbproj", "{1BB5B66C-C66B-474D-BE43-03E212F5DF3F}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServerClient", "TimeServerClient\TimeServerClient.vbproj", "{B2064CD5-D49D-4BF7-B31E-57025D69727C}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.ActiveCfg = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.Build.0 = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.ActiveCfg = Release|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.Build.0 = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.ActiveCfg = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.Build.0 = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.ActiveCfg = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServer.suo b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServer.suo new file mode 100644 index 0000000..ebbd2f9 Binary files /dev/null and b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServer.suo differ diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/AssemblyInfo.vb new file mode 100644 index 0000000..30e9959 --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.resx b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.resx new file mode 100644 index 0000000..323365d --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + ClientForm + + + 80 + + + True + + + Assembly + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.vb b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.vb new file mode 100644 index 0000000..3a537ca --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.vb @@ -0,0 +1,206 @@ +Option Strict On +Imports System.Windows.Forms + +Public Class ClientForm : Inherits System.Windows.Forms.Form + + Private m_TimeTest As localhost.TimeService + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents GetTime As System.Windows.Forms.Button + Friend WithEvents ShowTime As System.Windows.Forms.Label + Friend WithEvents ProxyDebugDemo As System.Windows.Forms.Button + Friend WithEvents TriggerRawException As System.Windows.Forms.Button + Friend WithEvents TriggerCustomException As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.GetTime = New System.Windows.Forms.Button + Me.ShowTime = New System.Windows.Forms.Label + Me.ProxyDebugDemo = New System.Windows.Forms.Button + Me.TriggerRawException = New System.Windows.Forms.Button + Me.TriggerCustomException = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'GetTime + ' + Me.GetTime.Location = New System.Drawing.Point(40, 40) + Me.GetTime.Name = "GetTime" + Me.GetTime.Size = New System.Drawing.Size(160, 56) + Me.GetTime.TabIndex = 0 + Me.GetTime.Text = "Test time retrieval" + ' + 'ShowTime + ' + Me.ShowTime.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.ShowTime.Location = New System.Drawing.Point(240, 48) + Me.ShowTime.Name = "ShowTime" + Me.ShowTime.Size = New System.Drawing.Size(128, 48) + Me.ShowTime.TabIndex = 1 + ' + 'ProxyDebugDemo + ' + Me.ProxyDebugDemo.Location = New System.Drawing.Point(40, 120) + Me.ProxyDebugDemo.Name = "ProxyDebugDemo" + Me.ProxyDebugDemo.Size = New System.Drawing.Size(160, 56) + Me.ProxyDebugDemo.TabIndex = 2 + Me.ProxyDebugDemo.Text = "Demo proxy debugging" + ' + 'TriggerRawException + ' + Me.TriggerRawException.Location = New System.Drawing.Point(40, 200) + Me.TriggerRawException.Name = "TriggerRawException" + Me.TriggerRawException.Size = New System.Drawing.Size(160, 56) + Me.TriggerRawException.TabIndex = 4 + Me.TriggerRawException.Text = "Trigger raw exception" + ' + 'TriggerCustomException + ' + Me.TriggerCustomException.Location = New System.Drawing.Point(40, 280) + Me.TriggerCustomException.Name = "TriggerCustomException" + Me.TriggerCustomException.Size = New System.Drawing.Size(160, 56) + Me.TriggerCustomException.TabIndex = 5 + Me.TriggerCustomException.Text = "Trigger custom exception" + ' + 'ClientForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(432, 396) + Me.Controls.Add(Me.TriggerCustomException) + Me.Controls.Add(Me.TriggerRawException) + Me.Controls.Add(Me.ProxyDebugDemo) + Me.Controls.Add(Me.ShowTime) + Me.Controls.Add(Me.GetTime) + Me.Name = "ClientForm" + Me.Text = "TimeServer client" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub ClientForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Create web service instance (via proxy) and + 'ensure timeout never happens during debugging + m_TimeTest = New localhost.TimeService +#If DEBUG Then + m_TimeTest.Timeout = -1 +#End If + + End Sub + + Private Sub GetTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetTime.Click + 'Get time details + Me.ShowTime.Text = m_TimeTest.CurrentTime + + End Sub + + Private Sub ProxyDebugDemo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyDebugDemo.Click + 'Trigger exception without catching it + 'Ensure proxy has DebuggerStepthroughAttribute removed + 'This exception will then break into the debugger + m_TimeTest.ThrowExceptionRaw() + + End Sub + + Private Sub TriggerRawException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerRawException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger raw exception and show it + Try + m_TimeTest.ThrowExceptionRaw() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage += "RECEIVED EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .GetType.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .StackTrace + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + End With + + MessageBox.Show(ExceptionMessage, "Web service raw exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub TriggerCustomException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerCustomException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger custom exception and show it + Try + m_TimeTest.ThrowExceptionCustom() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage = "ORIGINAL EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionType").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionMessage").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionTrace").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Raw SOAP message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + End With + + MessageBox.Show(ExceptionMessage, "Web service custom exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub ClientForm_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed + 'Close web service instance + m_TimeTest.Dispose() + m_TimeTest = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj new file mode 100644 index 0000000..d3dd6af --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj.user b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj.user new file mode 100644 index 0000000..d5f4c7b --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources new file mode 100644 index 0000000..50edb59 Binary files /dev/null and b/Source/VisualStudio2002/Chapter08/TimeServerBrowserClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources differ diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServer.sln b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServer.sln new file mode 100644 index 0000000..6a41a06 --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServer.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServer", "http://localhost/TimeServer_2002/TimeServer.vbproj", "{1BB5B66C-C66B-474D-BE43-03E212F5DF3F}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServerClient", "TimeServerClient\TimeServerClient.vbproj", "{B2064CD5-D49D-4BF7-B31E-57025D69727C}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.ActiveCfg = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.Build.0 = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.ActiveCfg = Release|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.Build.0 = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.ActiveCfg = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.Build.0 = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.ActiveCfg = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServer.suo b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServer.suo new file mode 100644 index 0000000..a702a51 Binary files /dev/null and b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServer.suo differ diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/AssemblyInfo.vb new file mode 100644 index 0000000..30e9959 --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.resx b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.resx new file mode 100644 index 0000000..323365d --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + ClientForm + + + 80 + + + True + + + Assembly + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.vb b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.vb new file mode 100644 index 0000000..3a537ca --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.vb @@ -0,0 +1,206 @@ +Option Strict On +Imports System.Windows.Forms + +Public Class ClientForm : Inherits System.Windows.Forms.Form + + Private m_TimeTest As localhost.TimeService + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents GetTime As System.Windows.Forms.Button + Friend WithEvents ShowTime As System.Windows.Forms.Label + Friend WithEvents ProxyDebugDemo As System.Windows.Forms.Button + Friend WithEvents TriggerRawException As System.Windows.Forms.Button + Friend WithEvents TriggerCustomException As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.GetTime = New System.Windows.Forms.Button + Me.ShowTime = New System.Windows.Forms.Label + Me.ProxyDebugDemo = New System.Windows.Forms.Button + Me.TriggerRawException = New System.Windows.Forms.Button + Me.TriggerCustomException = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'GetTime + ' + Me.GetTime.Location = New System.Drawing.Point(40, 40) + Me.GetTime.Name = "GetTime" + Me.GetTime.Size = New System.Drawing.Size(160, 56) + Me.GetTime.TabIndex = 0 + Me.GetTime.Text = "Test time retrieval" + ' + 'ShowTime + ' + Me.ShowTime.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.ShowTime.Location = New System.Drawing.Point(240, 48) + Me.ShowTime.Name = "ShowTime" + Me.ShowTime.Size = New System.Drawing.Size(128, 48) + Me.ShowTime.TabIndex = 1 + ' + 'ProxyDebugDemo + ' + Me.ProxyDebugDemo.Location = New System.Drawing.Point(40, 120) + Me.ProxyDebugDemo.Name = "ProxyDebugDemo" + Me.ProxyDebugDemo.Size = New System.Drawing.Size(160, 56) + Me.ProxyDebugDemo.TabIndex = 2 + Me.ProxyDebugDemo.Text = "Demo proxy debugging" + ' + 'TriggerRawException + ' + Me.TriggerRawException.Location = New System.Drawing.Point(40, 200) + Me.TriggerRawException.Name = "TriggerRawException" + Me.TriggerRawException.Size = New System.Drawing.Size(160, 56) + Me.TriggerRawException.TabIndex = 4 + Me.TriggerRawException.Text = "Trigger raw exception" + ' + 'TriggerCustomException + ' + Me.TriggerCustomException.Location = New System.Drawing.Point(40, 280) + Me.TriggerCustomException.Name = "TriggerCustomException" + Me.TriggerCustomException.Size = New System.Drawing.Size(160, 56) + Me.TriggerCustomException.TabIndex = 5 + Me.TriggerCustomException.Text = "Trigger custom exception" + ' + 'ClientForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(432, 396) + Me.Controls.Add(Me.TriggerCustomException) + Me.Controls.Add(Me.TriggerRawException) + Me.Controls.Add(Me.ProxyDebugDemo) + Me.Controls.Add(Me.ShowTime) + Me.Controls.Add(Me.GetTime) + Me.Name = "ClientForm" + Me.Text = "TimeServer client" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub ClientForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Create web service instance (via proxy) and + 'ensure timeout never happens during debugging + m_TimeTest = New localhost.TimeService +#If DEBUG Then + m_TimeTest.Timeout = -1 +#End If + + End Sub + + Private Sub GetTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetTime.Click + 'Get time details + Me.ShowTime.Text = m_TimeTest.CurrentTime + + End Sub + + Private Sub ProxyDebugDemo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyDebugDemo.Click + 'Trigger exception without catching it + 'Ensure proxy has DebuggerStepthroughAttribute removed + 'This exception will then break into the debugger + m_TimeTest.ThrowExceptionRaw() + + End Sub + + Private Sub TriggerRawException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerRawException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger raw exception and show it + Try + m_TimeTest.ThrowExceptionRaw() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage += "RECEIVED EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .GetType.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .StackTrace + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + End With + + MessageBox.Show(ExceptionMessage, "Web service raw exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub TriggerCustomException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerCustomException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger custom exception and show it + Try + m_TimeTest.ThrowExceptionCustom() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage = "ORIGINAL EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionType").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionMessage").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionTrace").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Raw SOAP message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + End With + + MessageBox.Show(ExceptionMessage, "Web service custom exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub ClientForm_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed + 'Close web service instance + m_TimeTest.Dispose() + m_TimeTest = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj new file mode 100644 index 0000000..d3dd6af --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj.user b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj.user new file mode 100644 index 0000000..d5f4c7b --- /dev/null +++ b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources new file mode 100644 index 0000000..50edb59 Binary files /dev/null and b/Source/VisualStudio2002/Chapter08/TimeServerSoapClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources differ diff --git a/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/AspNetDebugDemo.sln b/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/AspNetDebugDemo.sln new file mode 100644 index 0000000..b35ada2 --- /dev/null +++ b/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/AspNetDebugDemo.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AspNetDebugDemo", "http://localhost/AspNetDebugDemo_2002/AspNetDebugDemo.vbproj", "{135C30F3-6B37-4B7D-BC76-0EEF97726826}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Debug.ActiveCfg = Debug|.NET + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Debug.Build.0 = Debug|.NET + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Release.ActiveCfg = Release|.NET + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/AspNetDebugDemo.suo b/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/AspNetDebugDemo.suo new file mode 100644 index 0000000..9f59522 Binary files /dev/null and b/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/AspNetDebugDemo.suo differ diff --git a/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/ReadMe.txt b/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/ReadMe.txt new file mode 100644 index 0000000..defb21a --- /dev/null +++ b/Source/VisualStudio2002/Chapter09/AspNetDebugDemo/ReadMe.txt @@ -0,0 +1,7 @@ +To setup the AspNetDebugDemo application on your IIS web server, use +IIS to create a IIS virtual directory called AspNetDebugDemo_2002, +pointing at the real folder C:\Inetpub\wwwroot\AspNetDebugDemo_2002. +This real folder should have been created when you un-zipped +the zip file containing the source code. + +Then in Visual Studio 2002, load the AspNetDebugDemo solution. diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter10/DebugOnStart/AssemblyInfo.vb new file mode 100644 index 0000000..64988a1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/Client.vb b/Source/VisualStudio2002/Chapter10/DebugOnStart/Client.vb new file mode 100644 index 0000000..601e85c --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/Client.vb @@ -0,0 +1,130 @@ +Option Strict On + +Imports System.Net +Imports System.Text +Imports System.Threading +Imports System +Imports System.IO +Imports System.ServiceProcess + +Public Class Client + + Private ThisClient As Sockets.Socket = Nothing + Private ReadBuffer(16384) As Byte + Private PageBuffer(16384) As Byte + Private EmptyBuffer() As Byte = Encoding.ASCII.GetBytes(Space$(1024)) + + Public Sub New(ByVal NewClient As Sockets.Socket) + + Me.ThisClient = NewClient + + End Sub + + Public Sub Start() + Dim HtmlStream As StreamReader, PageRequest As String, PageText As String + + Try + Me.ThisClient.Receive(Me.ReadBuffer, Me.ReadBuffer.Length, Sockets.SocketFlags.None) + PageRequest = ReturnPage(Encoding.ASCII.GetString(Me.ReadBuffer)) + 'Open requested page + HtmlStream = New StreamReader(PageRequest) + PageText = HtmlStream.ReadToEnd() + HtmlStream.Close() + 'If status page, display services + PageText = PageText.Replace("#1#", Environment.MachineName & " (" & Me.ThisClient.LocalEndPoint.ToString & ")") + PageText = PageText.Replace("#2#", Me.DisplayServices) + 'Display requested page + Trace.WriteLine("Sending page " & PageRequest) + Me.PageBuffer = Encoding.ASCII.GetBytes(PageText) + Me.ThisClient.Send(Me.PageBuffer, Me.PageBuffer.Length, Sockets.SocketFlags.None) + Me.Close() + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + Close() + + End Try + + End Sub + + Private Function ReturnPage(ByVal PageRequest As String) As String + Dim HtmlPage As String, IndexStart As Int32, IndexEnd As Int32 + + 'Extract page + IndexStart = InStr(PageRequest, "/") + 1 + IndexEnd = InStr(IndexStart, PageRequest, " ") + HtmlPage = Mid$(PageRequest, IndexStart, IndexEnd - IndexStart) + 'add suffix if necessary + If Right$(HtmlPage, 5) <> ".html" Then + HtmlPage += ".html" + End If + 'Add local path + HtmlPage = Me.ReturnPath & HtmlPage + 'Check page exists + If File.Exists(HtmlPage) = False Then + HtmlPage = Me.ReturnPath & "error.html" + End If + 'Return page + Trace.WriteLine("Page requested: " & HtmlPage) + Return HtmlPage + + End Function + + Private Function ReturnPath() As String + + If Right$(AppDomain.CurrentDomain.BaseDirectory, 1) = "\" Then + Return AppDomain.CurrentDomain.BaseDirectory + Else + Return AppDomain.CurrentDomain.BaseDirectory & "\" + End If + + End Function + + Private Function DisplayServices() As String + Dim ThisService As ServiceController, TempPage As String + + For Each ThisService In ServiceController.GetServices + TempPage += "" & Environment.NewLine + 'Add service name + TempPage += "
" + TempPage += ThisService.ServiceName & "
" & Environment.NewLine + 'Add service friendly name + TempPage += "
" + TempPage += ThisService.DisplayName & "
" & Environment.NewLine + 'Add service status + TempPage += "
" + TempPage += ThisService.Status.ToString & "
" & Environment.NewLine + TempPage += "" & Environment.NewLine + 'Finished with this service + ThisService.Dispose() + Next + + Return TempPage + + End Function + + Public Function IsConnected() As Boolean + + If Me.ThisClient Is Nothing Then + Return False + Else + Return Me.ThisClient.Connected + End If + + End Function + + Public Sub Close() + + If Not (Me.ThisClient Is Nothing) Then + Trace.WriteLine("Closing client socket") + Me.ThisClient.Shutdown(Sockets.SocketShutdown.Both) + Me.ThisClient.Close() + Me.ThisClient = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/DummyService.resx b/Source/VisualStudio2002/Chapter10/DebugOnStart/DummyService.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/DummyService.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/DummyService.vb b/Source/VisualStudio2002/Chapter10/DebugOnStart/DummyService.vb new file mode 100644 index 0000000..6d34e4f --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/DummyService.vb @@ -0,0 +1,50 @@ +Option Strict On +Imports System.ServiceProcess +Imports System.Threading + +Public Class DummyService : Inherits System.ServiceProcess.ServiceBase + + +#Region " Component Designer generated code " + + Public Sub New() + MyBase.New() + + ' This call is required by the Component Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call + + End Sub + + 'UserService overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' The main entry point for the process + _ + Shared Sub Main() + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + Me.ServiceName = "DummyService" + End Sub + +#End Region + + +End Class diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ProjectInstaller.resx b/Source/VisualStudio2002/Chapter10/DebugOnStart/ProjectInstaller.resx new file mode 100644 index 0000000..142cb5c --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/ProjectInstaller.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Assembly + + + 17, 17 + + + Assembly + + + Assembly + + + 211, 17 + + + Assembly + + + Assembly + + + 360, 17 + + + ProjectInstaller + + + Assembly + + + False + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ProjectInstaller.vb b/Source/VisualStudio2002/Chapter10/DebugOnStart/ProjectInstaller.vb new file mode 100644 index 0000000..98ed79d --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/ProjectInstaller.vb @@ -0,0 +1,89 @@ +Imports System.ComponentModel +Imports System.Configuration.Install +Imports Microsoft.Win32 + + Public Class ProjectInstaller + Inherits System.Configuration.Install.Installer + +#Region " Component Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Installer overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller + Friend WithEvents ServiceInstaller2 As System.ServiceProcess.ServiceInstaller + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller + Me.ServiceInstaller2 = New System.ServiceProcess.ServiceInstaller + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.ServiceName = "ServiceAdmin" + ' + 'ServiceInstaller2 + ' + Me.ServiceInstaller2.ServiceName = "DummyService" + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1, Me.ServiceInstaller2}) + + End Sub + +#End Region + + Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) + + 'First do the install + MyBase.Install(stateSaver) + + 'System.Diagnostics.Debugger.Launch() + + Dim SystemKey As RegistryKey = Registry.LocalMachine.OpenSubKey("System") + Dim ControlSetKey As RegistryKey = SystemKey.OpenSubKey("CurrentControlSet") + Dim ServicesKey As RegistryKey = ControlSetKey.OpenSubKey("Services") + Dim ServiceKey As RegistryKey = ServicesKey.OpenSubKey(Me.ServiceInstaller1.ServiceName, True) + + 'Set the service description + ServiceKey.SetValue("Description", "Allows remote service administration") + + 'Cleanup + ServiceKey.Close() + ServicesKey.Close() + ControlSetKey.Close() + SystemKey.Close() + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/Service.resx b/Source/VisualStudio2002/Chapter10/DebugOnStart/Service.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/Service.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/Service.vb b/Source/VisualStudio2002/Chapter10/DebugOnStart/Service.vb new file mode 100644 index 0000000..5c3fc82 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/Service.vb @@ -0,0 +1,82 @@ +Option Strict On +Imports System.ServiceProcess + +Public Class ServiceAdmin : Inherits System.ServiceProcess.ServiceBase + +#Region " Component Designer generated code " + + Private Listener As ServiceListener = Nothing + + Public Sub New() + MyBase.New() + + ' This call is required by the Component Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call + + End Sub + + 'UserService overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' The main entry point for the process + _ + Shared Sub Main() + +#If DEBUG Then + Dim DebugService As New ServiceAdmin + DebugService.OnStart(Nothing) +#Else + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + 'The following line instantiates just your service + 'ServicesToRun = New ServiceBase() {New ServiceAdmin()} + + 'The following line (instead of the previous line) additionally instantiates a dummy service within the same + 'process as your real service. Starting the dummy service allows you to attach to the service process - then + 'you can debug your service's OnStart method by setting a breakpoint before starting your service. + ServicesToRun = New ServiceBase() {New ServiceAdmin, New DummyService} + + 'Start the service + ServiceBase.Run(ServicesToRun) +#End If + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container + Me.ServiceName = "ServiceAdmin" + End Sub + +#End Region + + Protected Overrides Sub OnStart(ByVal args() As String) + + Me.Listener = New ServiceListener + Me.Listener.Start() + + End Sub + + Protected Overrides Sub OnStop() + + If Not (Me.Listener Is Nothing) Then + Me.Listener.Close() + Me.Listener = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.sln b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.sln new file mode 100644 index 0000000..39f1c59 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ServiceAdmin", "ServiceAdmin.vbproj", "{A7151D9F-543D-46BF-B098-49E2616B8F05}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.ActiveCfg = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.Build.0 = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.ActiveCfg = Release|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.suo b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.suo new file mode 100644 index 0000000..271cb5f Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.suo differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.vbproj b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.vbproj new file mode 100644 index 0000000..cb50583 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.vbproj @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.vbproj.user b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.vbproj.user new file mode 100644 index 0000000..5c92159 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceAdmin.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceListener.vb b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceListener.vb new file mode 100644 index 0000000..2dcaa2e --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/ServiceListener.vb @@ -0,0 +1,92 @@ +Option Strict On + +Imports System.Threading +Imports System.Net + +Public Class ServiceListener + + Private ListenThread As Thread = Nothing + Private ThreadExit As Boolean = False + Private Clients As ArrayList = New ArrayList + + Public Sub New() + + End Sub + + Public Sub Start() + + If Me.ListenThread Is Nothing Then + Me.ThreadExit = False + Me.ListenThread = New Thread(New ThreadStart(AddressOf ListeningThread)) + Me.ListenThread.Start() + Else + Throw New InvalidOperationException("Listener thread already started") + End If + + End Sub + + Private Sub ListeningThread() + Dim MyTcpListener As Sockets.TcpListener = Nothing + Dim LocalAddress As Net.IPAddress = IPAddress.Any + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Try + MyTcpListener = New Sockets.TcpListener(LocalAddress, 5005) + MyTcpListener.Start() + Trace.WriteLine("Listening thread starting on " & MyTcpListener.LocalEndpoint.ToString) + + While Me.ThreadExit = False + Thread.Sleep(500) + If MyTcpListener.Pending = True Then + Trace.WriteLine(Environment.NewLine & "Connecting new client") + ThisClient = New Client(MyTcpListener.AcceptSocket()) + Clients.Add(ThisClient) + ThisClient.Start() + Else + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + If ThisClient.IsConnected = False Then + Trace.WriteLine("Performing client cleanup") + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + End If + Next + End If + End While + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + + Finally + Trace.WriteLine("Listen thread ending...") + If Not (MyTcpListener Is Nothing) Then + MyTcpListener.Stop() + End If + Trace.WriteLine("Listen thread ended") + + End Try + + End Sub + + Public Sub Close() + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Me.ThreadExit = True + 'Pause to process pending requests and do cleanup + Thread.Sleep(1000) + 'Time to die + If Me.ListenThread.IsAlive Then + Me.ListenThread.Abort() + Me.ListenThread = Nothing + End If + 'Dump any client still connected! + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + Next + Me.Clients = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/bin/error.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/bin/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/bin/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/bin/status.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/bin/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/bin/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/error.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.DummyService.resources b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.DummyService.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.DummyService.resources differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ProjectInstaller.resources b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ProjectInstaller.resources new file mode 100644 index 0000000..9414ab0 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ProjectInstaller.resources differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ServiceAdmin.resources b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ServiceAdmin.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ServiceAdmin.resources differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/error.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/status.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Debug/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.DummyService.resources b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.DummyService.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.DummyService.resources differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ProjectInstaller.resources b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ProjectInstaller.resources new file mode 100644 index 0000000..9414ab0 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ProjectInstaller.resources differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ServiceAdmin.resources b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ServiceAdmin.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ServiceAdmin.resources differ diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/error.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/status.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/obj/Release/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2002/Chapter10/DebugOnStart/status.html b/Source/VisualStudio2002/Chapter10/DebugOnStart/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/DebugOnStart/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter10/ServiceAdmin/AssemblyInfo.vb new file mode 100644 index 0000000..64988a1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/Client.vb b/Source/VisualStudio2002/Chapter10/ServiceAdmin/Client.vb new file mode 100644 index 0000000..601e85c --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/Client.vb @@ -0,0 +1,130 @@ +Option Strict On + +Imports System.Net +Imports System.Text +Imports System.Threading +Imports System +Imports System.IO +Imports System.ServiceProcess + +Public Class Client + + Private ThisClient As Sockets.Socket = Nothing + Private ReadBuffer(16384) As Byte + Private PageBuffer(16384) As Byte + Private EmptyBuffer() As Byte = Encoding.ASCII.GetBytes(Space$(1024)) + + Public Sub New(ByVal NewClient As Sockets.Socket) + + Me.ThisClient = NewClient + + End Sub + + Public Sub Start() + Dim HtmlStream As StreamReader, PageRequest As String, PageText As String + + Try + Me.ThisClient.Receive(Me.ReadBuffer, Me.ReadBuffer.Length, Sockets.SocketFlags.None) + PageRequest = ReturnPage(Encoding.ASCII.GetString(Me.ReadBuffer)) + 'Open requested page + HtmlStream = New StreamReader(PageRequest) + PageText = HtmlStream.ReadToEnd() + HtmlStream.Close() + 'If status page, display services + PageText = PageText.Replace("#1#", Environment.MachineName & " (" & Me.ThisClient.LocalEndPoint.ToString & ")") + PageText = PageText.Replace("#2#", Me.DisplayServices) + 'Display requested page + Trace.WriteLine("Sending page " & PageRequest) + Me.PageBuffer = Encoding.ASCII.GetBytes(PageText) + Me.ThisClient.Send(Me.PageBuffer, Me.PageBuffer.Length, Sockets.SocketFlags.None) + Me.Close() + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + Close() + + End Try + + End Sub + + Private Function ReturnPage(ByVal PageRequest As String) As String + Dim HtmlPage As String, IndexStart As Int32, IndexEnd As Int32 + + 'Extract page + IndexStart = InStr(PageRequest, "/") + 1 + IndexEnd = InStr(IndexStart, PageRequest, " ") + HtmlPage = Mid$(PageRequest, IndexStart, IndexEnd - IndexStart) + 'add suffix if necessary + If Right$(HtmlPage, 5) <> ".html" Then + HtmlPage += ".html" + End If + 'Add local path + HtmlPage = Me.ReturnPath & HtmlPage + 'Check page exists + If File.Exists(HtmlPage) = False Then + HtmlPage = Me.ReturnPath & "error.html" + End If + 'Return page + Trace.WriteLine("Page requested: " & HtmlPage) + Return HtmlPage + + End Function + + Private Function ReturnPath() As String + + If Right$(AppDomain.CurrentDomain.BaseDirectory, 1) = "\" Then + Return AppDomain.CurrentDomain.BaseDirectory + Else + Return AppDomain.CurrentDomain.BaseDirectory & "\" + End If + + End Function + + Private Function DisplayServices() As String + Dim ThisService As ServiceController, TempPage As String + + For Each ThisService In ServiceController.GetServices + TempPage += "" & Environment.NewLine + 'Add service name + TempPage += "
" + TempPage += ThisService.ServiceName & "
" & Environment.NewLine + 'Add service friendly name + TempPage += "
" + TempPage += ThisService.DisplayName & "
" & Environment.NewLine + 'Add service status + TempPage += "
" + TempPage += ThisService.Status.ToString & "
" & Environment.NewLine + TempPage += "" & Environment.NewLine + 'Finished with this service + ThisService.Dispose() + Next + + Return TempPage + + End Function + + Public Function IsConnected() As Boolean + + If Me.ThisClient Is Nothing Then + Return False + Else + Return Me.ThisClient.Connected + End If + + End Function + + Public Sub Close() + + If Not (Me.ThisClient Is Nothing) Then + Trace.WriteLine("Closing client socket") + Me.ThisClient.Shutdown(Sockets.SocketShutdown.Both) + Me.ThisClient.Close() + Me.ThisClient = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ProjectInstaller.resx b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ProjectInstaller.resx new file mode 100644 index 0000000..482e83e --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ProjectInstaller.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Assembly + + + 17, 17 + + + Assembly + + + Assembly + + + 211, 17 + + + ProjectInstaller + + + Assembly + + + False + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ProjectInstaller.vb b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ProjectInstaller.vb new file mode 100644 index 0000000..4c0d513 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ProjectInstaller.vb @@ -0,0 +1,83 @@ +Imports System.ComponentModel +Imports System.Configuration.Install +Imports Microsoft.Win32 + + Public Class ProjectInstaller + Inherits System.Configuration.Install.Installer + +#Region " Component Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Installer overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.ServiceName = "ServiceAdmin" + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) + + End Sub + +#End Region + + Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) + + 'First do the install + MyBase.Install(stateSaver) + + 'System.Diagnostics.Debugger.Launch() + + Dim SystemKey As RegistryKey = Registry.LocalMachine.OpenSubKey("System") + Dim ControlSetKey As RegistryKey = SystemKey.OpenSubKey("CurrentControlSet") + Dim ServicesKey As RegistryKey = ControlSetKey.OpenSubKey("Services") + Dim ServiceKey As RegistryKey = ServicesKey.OpenSubKey(Me.ServiceInstaller1.ServiceName, True) + + 'Set the service description + ServiceKey.SetValue("Description", "Allows remote service administration") + + 'Cleanup + ServiceKey.Close() + ServicesKey.Close() + ControlSetKey.Close() + SystemKey.Close() + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/Service.resx b/Source/VisualStudio2002/Chapter10/ServiceAdmin/Service.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/Service.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/Service.vb b/Source/VisualStudio2002/Chapter10/ServiceAdmin/Service.vb new file mode 100644 index 0000000..caf9754 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/Service.vb @@ -0,0 +1,82 @@ +Option Strict On +Imports System.ServiceProcess + +Public Class ServiceAdmin : Inherits System.ServiceProcess.ServiceBase + +#Region " Component Designer generated code " + + Private Listener As ServiceListener = Nothing + + Public Sub New() + MyBase.New() + + ' This call is required by the Component Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call + + End Sub + + 'UserService overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' The main entry point for the process + _ + Shared Sub Main() + +#If DEBUG Then + Dim DebugService As New ServiceAdmin + DebugService.OnStart(Nothing) +#Else + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + 'The following line instantiates just your service + ServicesToRun = New ServiceBase() {New ServiceAdmin()} + + 'The following line (instead of the previous line) additionally instantiates a dummy service within the same + 'process as your real service. Starting the dummy service allows you to attach to the service process - then + 'you can debug your service's OnStart method by setting a breakpoint before starting your service. + 'ServicesToRun = New ServiceBase() {New ServiceAdmin(), New DummyService()} + + 'Start the service + ServiceBase.Run(ServicesToRun) +#End If + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container + Me.ServiceName = "ServiceAdmin" + End Sub + +#End Region + + Protected Overrides Sub OnStart(ByVal args() As String) + + Me.Listener = New ServiceListener + Me.Listener.Start() + + End Sub + + Protected Overrides Sub OnStop() + + If Not (Me.Listener Is Nothing) Then + Me.Listener.Close() + Me.Listener = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.sln b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.sln new file mode 100644 index 0000000..39f1c59 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ServiceAdmin", "ServiceAdmin.vbproj", "{A7151D9F-543D-46BF-B098-49E2616B8F05}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.ActiveCfg = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.Build.0 = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.ActiveCfg = Release|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.suo b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.suo new file mode 100644 index 0000000..482ba30 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.suo differ diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.vbproj b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.vbproj new file mode 100644 index 0000000..028f86e --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.vbproj @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.vbproj.user b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceAdmin.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceListener.vb b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceListener.vb new file mode 100644 index 0000000..2dcaa2e --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/ServiceListener.vb @@ -0,0 +1,92 @@ +Option Strict On + +Imports System.Threading +Imports System.Net + +Public Class ServiceListener + + Private ListenThread As Thread = Nothing + Private ThreadExit As Boolean = False + Private Clients As ArrayList = New ArrayList + + Public Sub New() + + End Sub + + Public Sub Start() + + If Me.ListenThread Is Nothing Then + Me.ThreadExit = False + Me.ListenThread = New Thread(New ThreadStart(AddressOf ListeningThread)) + Me.ListenThread.Start() + Else + Throw New InvalidOperationException("Listener thread already started") + End If + + End Sub + + Private Sub ListeningThread() + Dim MyTcpListener As Sockets.TcpListener = Nothing + Dim LocalAddress As Net.IPAddress = IPAddress.Any + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Try + MyTcpListener = New Sockets.TcpListener(LocalAddress, 5005) + MyTcpListener.Start() + Trace.WriteLine("Listening thread starting on " & MyTcpListener.LocalEndpoint.ToString) + + While Me.ThreadExit = False + Thread.Sleep(500) + If MyTcpListener.Pending = True Then + Trace.WriteLine(Environment.NewLine & "Connecting new client") + ThisClient = New Client(MyTcpListener.AcceptSocket()) + Clients.Add(ThisClient) + ThisClient.Start() + Else + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + If ThisClient.IsConnected = False Then + Trace.WriteLine("Performing client cleanup") + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + End If + Next + End If + End While + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + + Finally + Trace.WriteLine("Listen thread ending...") + If Not (MyTcpListener Is Nothing) Then + MyTcpListener.Stop() + End If + Trace.WriteLine("Listen thread ended") + + End Try + + End Sub + + Public Sub Close() + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Me.ThreadExit = True + 'Pause to process pending requests and do cleanup + Thread.Sleep(1000) + 'Time to die + If Me.ListenThread.IsAlive Then + Me.ListenThread.Abort() + Me.ListenThread = Nothing + End If + 'Dump any client still connected! + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + Next + Me.Clients = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/error.html b/Source/VisualStudio2002/Chapter10/ServiceAdmin/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/obj/Debug/ServiceAdmin.ProjectInstaller.resources b/Source/VisualStudio2002/Chapter10/ServiceAdmin/obj/Debug/ServiceAdmin.ProjectInstaller.resources new file mode 100644 index 0000000..cdee8ee Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/ServiceAdmin/obj/Debug/ServiceAdmin.ProjectInstaller.resources differ diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/obj/Debug/ServiceAdmin.ServiceAdmin.resources b/Source/VisualStudio2002/Chapter10/ServiceAdmin/obj/Debug/ServiceAdmin.ServiceAdmin.resources new file mode 100644 index 0000000..4e892e6 Binary files /dev/null and b/Source/VisualStudio2002/Chapter10/ServiceAdmin/obj/Debug/ServiceAdmin.ServiceAdmin.resources differ diff --git a/Source/VisualStudio2002/Chapter10/ServiceAdmin/status.html b/Source/VisualStudio2002/Chapter10/ServiceAdmin/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2002/Chapter10/ServiceAdmin/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/FormInterop.frm b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/FormInterop.frm new file mode 100644 index 0000000..1d2038e --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/FormInterop.frm @@ -0,0 +1,42 @@ +VERSION 5.00 +Begin VB.Form FormInterop + Caption = "Interop debugging" + ClientHeight = 2544 + ClientLeft = 48 + ClientTop = 288 + ClientWidth = 3744 + LinkTopic = "Form1" + ScaleHeight = 2544 + ScaleWidth = 3744 + StartUpPosition = 2 'CenterScreen + Begin VB.CommandButton DebugTest + Caption = "Test debug of VB6 app calling VB .NET component" + Height = 1092 + Left = 720 + TabIndex = 0 + Top = 720 + Width = 2172 + End +End +Attribute VB_Name = "FormInterop" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Option Explicit + +Private Sub DebugTest_Click() +Dim InteropTest As InteropDemo.MathClass +Set InteropTest = New InteropDemo.MathClass + +Me.DebugTest.Caption = "Result = " & CStr(InteropTest.AddTwoNumbers(1.1, 2.2)) + +Set InteropTest = Nothing + +End Sub + +Private Sub Form_Load() + +Me.Caption = "Test interop debugging" + +End Sub diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/AssemblyInfo.vb new file mode 100644 index 0000000..b8889fb --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropClass.vb b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropClass.vb new file mode 100644 index 0000000..510e7b9 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropClass.vb @@ -0,0 +1,20 @@ +Option Strict On +Imports System.Runtime.InteropServices + +Public Interface IMathClass + Function AddTwoNumbers(ByVal FirstNumber As Double, _ + ByVal SecondNumber As Double) As Double +End Interface + + _ +Public Class MathClass : Implements IMathClass + + Public Sub New() + End Sub + + Public Function AddTwoNumbers(ByVal FirstNumber As Double, ByVal SecondNumber As Double) As Double Implements IMathClass.AddTwoNumbers + 'Return the result to VB6 + Return FirstNumber + SecondNumber + End Function + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln new file mode 100644 index 0000000..41538ff --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDemoBetter", "InteropDemoBetter.vbproj", "{5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.ActiveCfg = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.Build.0 = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.ActiveCfg = Release|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.suo b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.suo new file mode 100644 index 0000000..f91b8a3 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.suo differ diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj new file mode 100644 index 0000000..e648caa --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj.user b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj.user new file mode 100644 index 0000000..18fcf12 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj.user @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.exe b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.exe new file mode 100644 index 0000000..5f251c4 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.exe differ diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.pdb b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.pdb new file mode 100644 index 0000000..747fe6e Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.pdb differ diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.vbp b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.vbp new file mode 100644 index 0000000..181c660 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.vbp @@ -0,0 +1,36 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\WINNT\System32\stdole2.tlb#OLE Automation +Form=FormInterop.frm +IconForm="FormInterop" +Startup="FormInterop" +HelpFile="" +Title="InteropDebug" +ExeName32="InteropDebug.exe" +Command32="" +Name="InteropDebug" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="Sleek Software Ltd" +CompilationType=0 +OptimizationType=2 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=-1 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.vbw b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.vbw new file mode 100644 index 0000000..7ce665e --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDebug.vbw @@ -0,0 +1 @@ +FormInterop = 138, 138, 915, 786, Z, 92, 92, 869, 740, C diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/AssemblyInfo.vb new file mode 100644 index 0000000..b8889fb --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropClass.vb b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropClass.vb new file mode 100644 index 0000000..8468909 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropClass.vb @@ -0,0 +1,17 @@ +Option Strict On +Imports System.Runtime.InteropServices + + _ +Public Class MathClass + + Public Sub New() + End Sub + + Public Function AddTwoNumbers(ByVal FirstNumber As Double, ByVal SecondNumber As Double) As Double + + 'Return the result to VB6 + Return FirstNumber + SecondNumber + + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln new file mode 100644 index 0000000..5188e56 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDemo", "InteropDemo.vbproj", "{5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.ActiveCfg = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.Build.0 = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.ActiveCfg = Release|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.suo b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.suo new file mode 100644 index 0000000..38d21d6 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.suo differ diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj new file mode 100644 index 0000000..e648caa --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj.user b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj.user new file mode 100644 index 0000000..18fcf12 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj.user @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/AssemblyInfo.vb new file mode 100644 index 0000000..b160da1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.dll b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.dll new file mode 100644 index 0000000..fc98996 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.dll differ diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.pdb b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.pdb new file mode 100644 index 0000000..1707568 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.pdb differ diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbp b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbp new file mode 100644 index 0000000..dff22ba --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbp @@ -0,0 +1,39 @@ +Type=OleDll +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINNT\System32\stdole2.tlb#OLE Automation +Class=ComPrinting; ComPrinting.cls +Startup="(None)" +HelpFile="" +Title="ComPrintUtils" +ExeName32="ComPrintUtils.dll" +Command32="" +Name="ComPrintUtils" +HelpContextID="0" +CompatibleMode="2" +CompatibleEXE32="Compatibility\ComPrintUtils.dll" +VersionCompatible32="1" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="Sleek Software Ltd" +CompilationType=0 +OptimizationType=2 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=-1 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=1 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +ThreadingModel=1 +DebugStartupOption=0 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbw b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbw new file mode 100644 index 0000000..a6718a9 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbw @@ -0,0 +1 @@ +ComPrinting = 23, 23, 800, 671, Z diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrinting.cls b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrinting.cls new file mode 100644 index 0000000..1321832 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrinting.cls @@ -0,0 +1,259 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "ComPrinting" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +Option Explicit +Option Base 0 + +Private Type PALETTEENTRY + peRed As Byte + peGreen As Byte + peBlue As Byte + peFlags As Byte +End Type + +Private Type LOGPALETTE + palVersion As Integer + palNumEntries As Integer + palPalEntry(255) As PALETTEENTRY ' Enough for 256 colors. +End Type + +Private Type GUID + Data1 As Long + Data2 As Integer + Data3 As Integer + Data4(7) As Byte +End Type + +Private Const RASTERCAPS As Long = 38 +Private Const RC_PALETTE As Long = &H100 +Private Const SIZEPALETTE As Long = 104 + +Private Type RECT + Left As Long + Top As Long + Right As Long + Bottom As Long +End Type + +Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Long) As Long +Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Long, _ + ByVal nWidth As Long, _ + ByVal nHeight As Long) As Long +Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal hDC As Long, ByVal iCapability As Long) As Long +Private Declare Function GetSystemPaletteEntries Lib "GDI32" (ByVal hDC As Long, _ + ByVal wStartIndex As Long, ByVal wNumEntries As Long, _ + lpPaletteEntries As PALETTEENTRY) As Long +Private Declare Function CreatePalette Lib "GDI32" (lpLogPalette As LOGPALETTE) As Long +Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Long, ByVal hObject As Long) As Long +Private Declare Function BitBlt Lib "GDI32" (ByVal hDCDest As Long, ByVal XDest As Long, _ + ByVal YDest As Long, ByVal nWidth As Long, _ + ByVal nHeight As Long, ByVal hDCSrc As Long, _ + ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long +Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Long) As Long +Private Declare Function GetForegroundWindow Lib "USER32" () As Long +Private Declare Function SelectPalette Lib "GDI32" (ByVal hDC As Long, ByVal hPalette As Long, _ + ByVal bForceBackground As Long) As Long +Private Declare Function RealizePalette Lib "GDI32" (ByVal hDC As Long) As Long +Private Declare Function GetWindowDC Lib "USER32" (ByVal hWnd As Long) As Long +Private Declare Function GetDC Lib "USER32" (ByVal hWnd As Long) As Long +Private Declare Function GetWindowRect Lib "USER32" (ByVal hWnd As Long, lpRect As RECT) As Long +Private Declare Function ReleaseDC Lib "USER32" (ByVal hWnd As Long, ByVal hDC As Long) As Long +Private Declare Function GetDesktopWindow Lib "USER32" () As Long + +Private Type PicBmp + Size As Long + Type As Long + hBmp As Long + hPal As Long + Reserved As Long +End Type + +Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" _ + (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, _ + IPic As IPicture) As Long + +Public Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture +'Creates a bitmap type picture object from a bitmap and palette. +Dim r As Long, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID + +'Fill in with IDispatch Interface ID. +With IID_IDispatch + .Data1 = &H20400 + .Data4(0) = &HC0 + .Data4(7) = &H46 +End With + +'Fill Pic with necessary parts. +With Pic + .Size = Len(Pic) ' Length of structure. + .Type = vbPicTypeBitmap ' Type of Picture (bitmap). + .hBmp = hBmp ' Handle to bitmap. + .hPal = hPal ' Handle to palette (may be null). +End With + +'Create picture object. +r = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic) + +'Return the new Picture object. +Set CreateBitmapPicture = IPic + +End Function + +Public Function CaptureWindow(ByVal hWndSrc As Long, ByVal Client As Boolean, _ + ByVal LeftSrc As Long, ByVal TopSrc As Long, _ + ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture +'Captures any portion of a window. +Dim hDCMemory As Long, hBmp As Long, hBmpPrev As Long, r As Long +Dim hDCSrc As Long, hPal As Long, hPalPrev As Long, RasterCapsScrn As Long +Dim HasPaletteScrn As Long, PaletteSizeScrn As Long, LogPal As LOGPALETTE + +'Depending on the value of Client, get the proper device context. +If Client Then + hDCSrc = GetDC(hWndSrc) 'Get device context for client area. +Else + hDCSrc = GetWindowDC(hWndSrc) 'Get device context for entire window. +End If + +'Create a memory device context for the copy process. +hDCMemory = CreateCompatibleDC(hDCSrc) +'Create a bitmap and place it in the memory DC. +hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc) +hBmpPrev = SelectObject(hDCMemory, hBmp) + +'Get screen properties. +RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS) 'Raster capabilities. +HasPaletteScrn = RasterCapsScrn And RC_PALETTE 'Palette support. +PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE) 'Size of palette. + +'If the screen has a palette make a copy and realize it. +If HasPaletteScrn And (PaletteSizeScrn = 256) Then + 'Create a copy of the system palette. + LogPal.palVersion = &H300 + LogPal.palNumEntries = 256 + r = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0)) + hPal = CreatePalette(LogPal) + ' Select the new palette into the memory DC and realize it. + hPalPrev = SelectPalette(hDCMemory, hPal, 0) + r = RealizePalette(hDCMemory) +End If + +'Copy the on-screen image into the memory DC. +r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy) + +'Remove the new copy of the on-screen image. +hBmp = SelectObject(hDCMemory, hBmpPrev) + +'If the screen has a palette get back the palette that was selected in previously. +If HasPaletteScrn And (PaletteSizeScrn = 256) Then + hPal = SelectPalette(hDCMemory, hPalPrev, 0) +End If + +'Release the device context resources back to the system. +r = DeleteDC(hDCMemory) +r = ReleaseDC(hWndSrc, hDCSrc) + +'Call CreateBitmapPicture to create a picture object from the +'bitmap and palette handles. Then return the resulting picture object. +Set CaptureWindow = CreateBitmapPicture(hBmp, hPal) + +End Function + +Public Function CaptureScreen() As Picture +'Captures the entire screen. +Dim hWndScreen As Long + +' Get a handle to the desktop window. +hWndScreen = GetDesktopWindow() + +' Call CaptureWindow to capture the entire desktop give the handle +' and return the resulting Picture object. + +Set CaptureScreen = CaptureWindow(hWndScreen, False, 0, 0, _ + Screen.Width \ Screen.TwipsPerPixelX, _ + Screen.Height \ Screen.TwipsPerPixelY) + +End Function + +Public Function CaptureForm(ByVal WindowHandle As Long) As Picture +'Captures an entire form including title bar and border. +Dim r As Long, RectActive As RECT + +'Get the dimensions of the window. +r = GetWindowRect(WindowHandle, RectActive) + +'Call CaptureWindow to capture the active window given its +'handle and return the Resulting Picture object. +Set CaptureForm = CaptureWindow(WindowHandle, False, 0, 0, _ + RectActive.Right - RectActive.Left, _ + RectActive.Bottom - RectActive.Top) + +End Function + +Public Function CaptureActiveWindow() As Picture +'Captures the currently active window on the screen. +Dim hWndActive As Long, r As Long, RectActive As RECT + +'Get a handle to the active/foreground window. +hWndActive = GetForegroundWindow() + +'Get the dimensions of the window. +r = GetWindowRect(hWndActive, RectActive) + +'Call CaptureWindow to capture the active window given its +'handle and return the Resulting Picture object. +Set CaptureActiveWindow = CaptureWindow(hWndActive, False, 0, 0, _ + RectActive.Right - RectActive.Left, _ + RectActive.Bottom - RectActive.Top) + +End Function + +Public Sub PrintPictureToFitPage(ByRef Pic As Picture) +'Prints a Picture object as big as possible. +Const vbHiMetric As Integer = 8 +Dim PicRatio As Double, PrnWidth As Double, PrnHeight As Double +Dim PrnRatio As Double, PrnPicWidth As Double, PrnPicHeight As Double + +'Determine if picture should be printed in landscape or portrait +'and set the orientation. +If Pic.Height >= Pic.Width Then + Printer.Orientation = vbPRORPortrait 'Taller than wide. +Else + Printer.Orientation = vbPRORLandscape 'Wider than tall. +End If + +'Calculate device independent Width-to-Height ratio for picture. +PicRatio = Pic.Width / Pic.Height + +'Calculate the dimentions of the printable area in HiMetric. +With Printer + + 'Calculate device independent Width to Height ratio for printer. + PrnWidth = .ScaleX(.ScaleWidth, .ScaleMode, vbHiMetric) + PrnHeight = .ScaleY(.ScaleHeight, .ScaleMode, vbHiMetric) + PrnRatio = PrnWidth / PrnHeight + + 'Scale the output to the printable area. + If PicRatio >= PrnRatio Then + PrnPicWidth = .ScaleX(PrnWidth, vbHiMetric, .ScaleMode) + PrnPicHeight = .ScaleY(PrnWidth / PicRatio, vbHiMetric, .ScaleMode) + Else + PrnPicHeight = .ScaleY(PrnHeight, vbHiMetric, .ScaleMode) + PrnPicWidth = .ScaleX(PrnHeight * PicRatio, vbHiMetric, .ScaleMode) + End If + +End With + +'Print the picture using the PaintPicture method. +Printer.PaintPicture Pic, 0, 0, PrnPicWidth, PrnPicHeight + +End Sub diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/Compatibility/ComPrintUtils.dll b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/Compatibility/ComPrintUtils.dll new file mode 100644 index 0000000..82452cc Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/ComPrinting/Compatibility/ComPrintUtils.dll differ diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/FormInterop.resx b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/FormInterop.resx new file mode 100644 index 0000000..0a2c16a --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/FormInterop.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Form1 + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/FormInterop.vb b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/FormInterop.vb new file mode 100644 index 0000000..99f4c07 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/FormInterop.vb @@ -0,0 +1,67 @@ +Option Strict On + +Public Class Form1 + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents cmdTest As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.cmdTest = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'cmdTest + ' + Me.cmdTest.Location = New System.Drawing.Point(64, 104) + Me.cmdTest.Name = "cmdTest" + Me.cmdTest.Size = New System.Drawing.Size(152, 80) + Me.cmdTest.TabIndex = 0 + Me.cmdTest.Text = "Test debug of VB .NET app calling VB6 component" + ' + 'Form1 + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdTest}) + Me.Name = "Form1" + Me.Text = "Interop debugging" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click + Dim DebugTest As New ComPrintUtils.ComPrinting() + DebugTest.PrintPictureToFitPage(DebugTest.CaptureForm(Me.Handle.ToInt32)) + System.Runtime.InteropServices.Marshal.ReleaseComObject(DebugTest) + DebugTest = Nothing + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.sln b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.sln new file mode 100644 index 0000000..27f661e --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDebug", "InteropDebug.vbproj", "{BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Debug.ActiveCfg = Debug|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Debug.Build.0 = Debug|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Release.ActiveCfg = Release|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.suo b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.suo new file mode 100644 index 0000000..ad580a2 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.suo differ diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj new file mode 100644 index 0000000..bbba058 --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj.user b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj.user new file mode 100644 index 0000000..c27d4ac --- /dev/null +++ b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/obj/Debug/InteropDebug.Form1.resources b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/obj/Debug/InteropDebug.Form1.resources new file mode 100644 index 0000000..0c0f382 Binary files /dev/null and b/Source/VisualStudio2002/Chapter11/Vb7UsingVb6Component/obj/Debug/InteropDebug.Form1.resources differ diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter12/SqlDebug/AssemblyInfo.vb new file mode 100644 index 0000000..d837e52 --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlDebug/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.resx b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.resx new file mode 100644 index 0000000..7923464 --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.resx @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Assembly + + + Assembly + + + Assembly + + + SqlDebug + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.sln b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.sln new file mode 100644 index 0000000..22ed41b --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SqlDebug", "SqlDebug.vbproj", "{25E00B17-05B1-4234-AC07-5C21C167C48C}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Debug.ActiveCfg = Debug|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Debug.Build.0 = Debug|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Release.ActiveCfg = Release|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.suo b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.suo new file mode 100644 index 0000000..9bd0b95 Binary files /dev/null and b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.suo differ diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vb b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vb new file mode 100644 index 0000000..a145ff1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vb @@ -0,0 +1,147 @@ +Option Strict On +Imports System.Data.SqlClient + +Public Class SqlDebug + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents ConnectionQuery As System.Windows.Forms.Button + Friend WithEvents ConnectionDestroy As System.Windows.Forms.Button + Friend WithEvents ConnectionCreate As System.Windows.Forms.Button + Friend WithEvents ValueToInsert As System.Windows.Forms.TextBox + Private Sub InitializeComponent() + Me.ConnectionQuery = New System.Windows.Forms.Button() + Me.ConnectionDestroy = New System.Windows.Forms.Button() + Me.ConnectionCreate = New System.Windows.Forms.Button() + Me.ValueToInsert = New System.Windows.Forms.TextBox() + Me.SuspendLayout() + ' + 'ConnectionQuery + ' + Me.ConnectionQuery.Location = New System.Drawing.Point(16, 96) + Me.ConnectionQuery.Name = "ConnectionQuery" + Me.ConnectionQuery.Size = New System.Drawing.Size(152, 40) + Me.ConnectionQuery.TabIndex = 0 + Me.ConnectionQuery.Text = "Insert new row" + ' + 'ConnectionDestroy + ' + Me.ConnectionDestroy.Location = New System.Drawing.Point(16, 168) + Me.ConnectionDestroy.Name = "ConnectionDestroy" + Me.ConnectionDestroy.Size = New System.Drawing.Size(152, 40) + Me.ConnectionDestroy.TabIndex = 1 + Me.ConnectionDestroy.Text = "Destroy connection" + ' + 'ConnectionCreate + ' + Me.ConnectionCreate.Location = New System.Drawing.Point(16, 24) + Me.ConnectionCreate.Name = "ConnectionCreate" + Me.ConnectionCreate.Size = New System.Drawing.Size(152, 40) + Me.ConnectionCreate.TabIndex = 2 + Me.ConnectionCreate.Text = "Create connection" + ' + 'ValueToInsert + ' + Me.ValueToInsert.Location = New System.Drawing.Point(184, 104) + Me.ValueToInsert.Name = "ValueToInsert" + Me.ValueToInsert.Size = New System.Drawing.Size(80, 22) + Me.ValueToInsert.TabIndex = 3 + Me.ValueToInsert.Text = "" + ' + 'SqlDebug + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ValueToInsert, Me.ConnectionCreate, Me.ConnectionDestroy, Me.ConnectionQuery}) + Me.Name = "SqlDebug" + Me.Text = "SQL Debugging" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private m_DatabaseConnection As SqlConnection + + Private Sub ConnectionCreation(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionCreate.Click + Dim ConnectionString As String, ConnectStatus As String + + 'Setup database connection + ConnectionString = "Initial Catalog = pubs;" + ConnectionString += "Data Source = CHEETAH;" + ConnectionString += "Integrated Security = SSPI;" + ConnectionString += "Pooling = 'false'" + + 'Attempt database connection + Try + m_DatabaseConnection = New SqlConnection(ConnectionString) + ConnectStatus = "Connected" + Catch objException As Exception + ConnectStatus = "Not connected: " & objException.ToString + m_DatabaseConnection.Close() + m_DatabaseConnection.Dispose() + Finally + Me.Text = ConnectStatus + End Try + + End Sub + + Private Sub ConnectionTest(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionQuery.Click + Dim QuerySql As String, QueryResult As New DataSet() + Dim QueryTest As New SqlDataAdapter() + + 'Check that we have a valid number + If Len(Trim$(Me.ValueToInsert.Text)) = 0 Then + MsgBox("You should enter a number before adding new row", MsgBoxStyle.Information Or MsgBoxStyle.OKOnly, "Ooops") + Me.ValueToInsert.Focus() + Exit Sub + End If + + 'Setup and perform database query + QuerySql = "EXEC sp_DebugExample " & Me.ValueToInsert.Text + Try + QueryTest.SelectCommand = New SqlCommand(QuerySql, m_DatabaseConnection) + QueryTest.Fill(QueryResult) + Catch objException As Exception + MsgBox(objException.ToString) + Finally + QueryTest.Dispose() + End Try + End Sub + + Private Sub ConnectionDestruction(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionDestroy.Click + + m_DatabaseConnection.Close() + m_DatabaseConnection.Dispose() + Me.Text = "Not connected" + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vbproj b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vbproj new file mode 100644 index 0000000..1e9482f --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vbproj @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vbproj.user b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vbproj.user new file mode 100644 index 0000000..7ef2f9d --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.zip b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.zip new file mode 100644 index 0000000..32072d0 Binary files /dev/null and b/Source/VisualStudio2002/Chapter12/SqlDebug/SqlDebug.zip differ diff --git a/Source/VisualStudio2002/Chapter12/SqlScripts/Corrected sp_DebugExample.sql b/Source/VisualStudio2002/Chapter12/SqlScripts/Corrected sp_DebugExample.sql new file mode 100644 index 0000000..8143012 --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlScripts/Corrected sp_DebugExample.sql @@ -0,0 +1,23 @@ +USE PUBS +GO + +/* Create corrected example stored procedure */ +ALTER PROCEDURE sp_DebugExample + @KeyColumn int +AS + +DECLARE @rowcount int, + @error int + +INSERT DebugTest VALUES(@KeyColumn) +SELECT @error = @@error, + @rowcount = @@rowcount + +IF @error <> 0 +BEGIN + INSERT DebugError + (RowsInserted, ErrorNumber, ProblemValue) + VALUES (@rowcount, @error, @Keycolumn) +END +GO + diff --git a/Source/VisualStudio2002/Chapter12/SqlScripts/Original sp_DebugExample.sql b/Source/VisualStudio2002/Chapter12/SqlScripts/Original sp_DebugExample.sql new file mode 100644 index 0000000..1470a43 --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlScripts/Original sp_DebugExample.sql @@ -0,0 +1,17 @@ +USE PUBS +GO + +/* Create original example stored procedure */ +CREATE PROCEDURE sp_DebugExample + @KeyColumn int +AS + +INSERT DebugTest VALUES(@KeyColumn) + +IF @@error <> 0 +BEGIN + INSERT DebugError + (RowsInserted, ErrorNumber, ProblemValue) + VALUES (@@rowcount, @@error, @Keycolumn) +END +GO diff --git a/Source/VisualStudio2002/Chapter12/SqlScripts/tb_DebugTest.sql b/Source/VisualStudio2002/Chapter12/SqlScripts/tb_DebugTest.sql new file mode 100644 index 0000000..940a9c3 --- /dev/null +++ b/Source/VisualStudio2002/Chapter12/SqlScripts/tb_DebugTest.sql @@ -0,0 +1,20 @@ +USE pubs +GO + +/* Build the first table */ +CREATE TABLE DebugTest +( +Id int NOT NULL IDENTITY (1,1), +KeyPrimary int NOT NULL PRIMARY KEY CHECK (KeyPrimary > 0) +) +GO + +/* Build the second table */ +CREATE TABLE DebugError +( +Id int NOT NULL IDENTITY (1,1), +RowsInserted int NOT NULL, +ErrorNumber int NOT NULL, +ProblemValue int NOT NULL +) +GO diff --git a/Source/VisualStudio2002/Chapter13/CustomException/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter13/CustomException/AssemblyInfo.vb new file mode 100644 index 0000000..04c890e --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/CustomException/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter13/CustomException/CustomException.sln b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.sln new file mode 100644 index 0000000..8af6a60 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomException", "CustomException.vbproj", "{97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Debug.ActiveCfg = Debug|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Debug.Build.0 = Debug|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Release.ActiveCfg = Release|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter13/CustomException/CustomException.suo b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.suo new file mode 100644 index 0000000..176f867 Binary files /dev/null and b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.suo differ diff --git a/Source/VisualStudio2002/Chapter13/CustomException/CustomException.vbproj b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.vbproj new file mode 100644 index 0000000..d6e5ef1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.vbproj @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/CustomException/CustomException.vbproj.user b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/CustomException/CustomException.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/CustomException/Test.vb b/Source/VisualStudio2002/Chapter13/CustomException/Test.vb new file mode 100644 index 0000000..4f60c1d --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/CustomException/Test.vb @@ -0,0 +1,40 @@ +Option Strict On + +Module Test + + Sub Main() + + Try + UserDetailsLoad("MarkPearce") + Catch Exc As UserLoadException + Console.WriteLine(Exc.Message) + Finally + Console.ReadLine() + End Try + + End Sub + + Function UserDetailsLoad(ByVal UserId As String) As Collection + Dim HelpfulMessage As String + Dim FileStream As System.IO.StreamReader + + 'First try to open the specified file + Try + FileStream = New System.IO.StreamReader(UserId & ".data") + + Catch Exc As System.IO.FileNotFoundException + 'The specified file didn't exist, but this exception won't mean + 'much to a caller who doesn't know how this method is implemented + UserDetailsLoad = Nothing + HelpfulMessage = "User details for '" & UserId & "' cannot be located" + Throw New UserLoadException(HelpfulMessage, Exc, UserId) + + Finally + + End Try + + 'Code goes here to load and return user details + + End Function + +End Module diff --git a/Source/VisualStudio2002/Chapter13/CustomException/UserLoadException.vb b/Source/VisualStudio2002/Chapter13/CustomException/UserLoadException.vb new file mode 100644 index 0000000..c7ab814 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/CustomException/UserLoadException.vb @@ -0,0 +1,56 @@ +Option Strict On +Imports System.Runtime.Serialization + + _ +Public Class UserLoadException : Inherits System.ApplicationException + + Private m_UserId As String = "" + + Public Sub New() + MyBase.New() + End Sub + + Public Sub New(ByVal message As String) + MyBase.New(message) + End Sub + + Public Sub New(ByVal message As String, ByVal UserId As String) + MyBase.New(message) + m_UserId = UserId + End Sub + + Public Sub New(ByVal message As String, ByVal innerException As Exception) + MyBase.New(message, innerException) + End Sub + + Public Sub New(ByVal message As String, ByVal innerException As Exception, ByVal UserId As String) + MyBase.New(message, innerException) + m_UserId = UserId + End Sub + + 'To re-materialize exception and custom property at the receiving end + Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) + MyBase.New(info, context) + m_UserId = info.GetString("UserId") + End Sub + + 'To de-materialize custom property at the sending end + Public Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) + MyBase.GetObjectData(info, context) + info.AddValue("UserId", m_UserId) + End Sub + + 'To add custom property to standard exception message + Public Overrides ReadOnly Property Message() As String + Get + Return MyBase.Message & Environment.NewLine & "User id: " & m_UserId & Environment.NewLine + End Get + End Property + + ReadOnly Property UserId() As String + Get + UserId = m_UserId + End Get + End Property + +End Class diff --git a/Source/VisualStudio2002/Chapter13/HidingDetail/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter13/HidingDetail/AssemblyInfo.vb new file mode 100644 index 0000000..1a0cfa0 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/HidingDetail/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.sln b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.sln new file mode 100644 index 0000000..1179386 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HidingDetail", "HidingDetail.vbproj", "{FA9CA985-D2C2-466D-8503-B447C738F116}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {FA9CA985-D2C2-466D-8503-B447C738F116}.Debug.ActiveCfg = Debug|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Debug.Build.0 = Debug|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Release.ActiveCfg = Release|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.suo b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.suo new file mode 100644 index 0000000..56bc9b3 Binary files /dev/null and b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.suo differ diff --git a/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.vbproj b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.vbproj new file mode 100644 index 0000000..4aa506e --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.vbproj.user b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/HidingDetail/HidingDetail.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/HidingDetail/Test.vb b/Source/VisualStudio2002/Chapter13/HidingDetail/Test.vb new file mode 100644 index 0000000..f1c2274 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/HidingDetail/Test.vb @@ -0,0 +1,40 @@ +Option Strict On + +Module Test + + Sub Main() + + Try + UserDetailsLoad("MarkPearce") + Catch Exc As Exception + Console.WriteLine(Exc.Message) + Finally + Console.ReadLine() + End Try + + End Sub + + Function UserDetailsLoad(ByVal UserId As String) As Collection + Dim HelpfulMessage As String + Dim FileStream As System.IO.StreamReader + + 'First try to open the specified file + Try + FileStream = New System.IO.StreamReader(UserId & ".data") + + Catch Exc As System.IO.FileNotFoundException + 'The specified file didn't exist, but this exception won't mean + 'much to a caller who doesn't know how this method is implemented + UserDetailsLoad = Nothing + HelpfulMessage = "User details for '" & UserId & "' cannot be located" + Throw New System.ArgumentException(HelpfulMessage, Exc) + + Finally + + End Try + + 'Code goes here to load and return user details + + End Function + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter13/MoveFileWrapper/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter13/MoveFileWrapper/AssemblyInfo.vb new file mode 100644 index 0000000..95fb311 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/MoveFileWrapper/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter13/MoveFileWrapper/ExceptionWrapper.vb b/Source/VisualStudio2002/Chapter13/MoveFileWrapper/ExceptionWrapper.vb new file mode 100644 index 0000000..3b8ddbb --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/MoveFileWrapper/ExceptionWrapper.vb @@ -0,0 +1,89 @@ +Option Strict On +Imports System.IO + +Module ExceptionWrapper + + Sub Main() + Dim WrapperNo As Boolean = False, WrapperYes As Boolean = True + + 'MOVE commands producing good exception information + TestMove("C:\Demo\Source.txt", "C:\Demo\Destination.txt", WrapperNo, "Destination is read-only") + TestMove("C:\Demo\Source.txt", "", WrapperNo, "Destination is empty") + TestMove("C:\Demo\Source.txt", Nothing, WrapperNo, "Destination is nothing") + TestMove("C:\Demo\Source.txt", "C:\Dem\Destination.txt", WrapperNo, "Wrong destination folder") + TestMove("C:\Demo\SourceX.txt", "C:\Demo\Destination.txt", WrapperNo, "Source doesn't exist") + + 'MOVE commands producing bad exception information + TestMove("C:\Demo\Source.txt", "C:\Demo\*.txt", WrapperNo, "Wildcard in destination") + TestMove("C:\Demo\Sou + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/MoveFileWrapper/MoveFileWrapper.vbproj.user b/Source/VisualStudio2002/Chapter13/MoveFileWrapper/MoveFileWrapper.vbproj.user new file mode 100644 index 0000000..c168d10 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/MoveFileWrapper/MoveFileWrapper.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/AssemblyInfo.vb new file mode 100644 index 0000000..257341e --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln new file mode 100644 index 0000000..1d226b2 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RealisticUnhandledExcFilter", "RealisticUnhandledExcFilter.vbproj", "{BB7379C0-225C-4404-8EF1-70A4A099FE5D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.ActiveCfg = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.Build.0 = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.ActiveCfg = Release|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.suo b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.suo new file mode 100644 index 0000000..3599c12 Binary files /dev/null and b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.suo differ diff --git a/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj new file mode 100644 index 0000000..b1f3e03 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj.user b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/Startup.vb b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/Startup.vb new file mode 100644 index 0000000..990f64b --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/RealisticUnhandledExcFilter/Startup.vb @@ -0,0 +1,70 @@ +Option Strict On +Imports System +Imports Microsoft.Win32 + +Module Startup + + Sub Main() + + 'Before running this program within the IDE, please use the Debug...Exceptions menu + 'item to ensure that the program continues in the face of an unhandled exception. + + 'Register the unhandled exception filter with the AppDomain. + 'This means that UnhandledExceptionFilter will be called whenever + 'a managed unhandled exception occurs. + AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionFilter + + 'Here's where the normal application code should appear. + 'In this case, deliberately create an exception so that + 'we can test the unhandled exception filter. + Dim objTest As Object + objTest.ToString() + + End Sub + + Private Sub UnhandledExceptionFilter(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) + 'This method will be called by any unhandled managed exception + Dim MessageFriendly As String, MessageDetail As String + + 'Log detailed exception message if no debugger is attached to this process + If Debugger.IsAttached = False Then + MessageDetail = "An unhandled exception occurred!" + Environment.NewLine + MessageDetail += e.ExceptionObject.ToString + Environment.NewLine + MessageDetail += "Application user was '" + Environment.UserName + "'." + Environment.NewLine + If e.IsTerminating = True Then + MessageDetail += "CLR will terminate this process (exception was on main thread)." + Else + MessageDetail += "CLR won't terminate this process (exception wasn't on main thread)." + End If + 'Write message to the Windows event Application log + Dim LogWriter As New EventLog("Application", ".", System.AppDomain.CurrentDomain.FriendlyName) + LogWriter.WriteEntry(MessageDetail, EventLogEntryType.Warning) + LogWriter.Close() + LogWriter.Dispose() + End If + +#If Debug = True Then + 'Launch the debugger if DEBUG build, no debugger already attached + 'and this is an interactive process (user is present) + If (Environment.UserInteractive = True) And (Debugger.IsAttached = False) Then + Debugger.Launch() + End If +#Else + 'If RELEASE build and this is an interactive process (user is present), + 'then show user either a warning or a critical message + If Environment.UserInteractive = True Then + MessageFriendly = "Unfortunately, this application hit an problem." + Environment.NewLine + If e.IsTerminating = True Then + MessageFriendly += "It will close now, but you can restart it." + Environment.NewLine + MessageFriendly += "Please contact application support and ask them to look in the event log." + MsgBox(MessageFriendly, MsgBoxStyle.Critical Or MsgBoxStyle.OKOnly, "Sorry for the inconvenience") + Else + MessageFriendly += "Please save your work asap before restarting the application." + MsgBox(MessageFriendly, MsgBoxStyle.Exclamation Or MsgBoxStyle.OKOnly, "Sorry for the inconvenience") + End If + End If +#End If + + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/AssemblyInfo.vb new file mode 100644 index 0000000..257341e --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/Startup.vb b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/Startup.vb new file mode 100644 index 0000000..491f61e --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/Startup.vb @@ -0,0 +1,86 @@ +Option Strict On +Imports System +Imports Microsoft.Win32 + +Module Startup + + Sub Main() + + 'Before running this program within the IDE, please use the Debug...Exceptions menu + 'item to ensure that the program continues in the face of an unhandled exception. + + 'Register the unhandled exception filter with the AppDomain. + 'This means that UnhandledExceptionFilter will be called whenever + 'a managed unhandled exception occurs. + AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionFilter + + 'Here's where the normal application code should appear. + 'In this case, deliberately create an exception so that + 'we can test the unhandled exception filter. + Dim objTest As Object + objTest.ToString() + + End Sub + + Sub UnhandledExceptionFilter(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) + 'This method will be called by any unhandled managed exception + 'Using DEBUG or RELEASE config + Dim JitDebugSetting As Object, RegKey As RegistryKey = Registry.LocalMachine + RegKey = RegKey.OpenSubKey("Software\Microsoft\.NetFramework") + JitDebugSetting = RegKey.GetValue("DbgJitDebugLaunchSetting") + RegKey.Close() + +#If Debug Then + Console.WriteLine("DEBUG configuration") + +#Else + Console.WriteLine("RELEASE configuration") +#End If + 'Who is user? + Console.WriteLine("User: " + Environment.UserName) + 'Is debugger attached? + Console.WriteLine("Debugger attached? " + Debugger.IsAttached.ToString) + 'Is there an end-user to show a message to? + Console.WriteLine("End-user present? " + Environment.UserInteractive.ToString) + 'Is this a CLS-compliant exception? + Console.WriteLine("CLS-compliant exception? " + ((TypeOf e.ExceptionObject Is Exception).ToString)) + 'What's the CLR going to do with the process? + If e.IsTerminating = True Then + Console.WriteLine("CLR will terminate this process") + Else + Console.WriteLine("CLR won't terminate this process") + End If + 'What's the CLR going to do about debugging? + If Debugger.IsAttached = True Then + Console.WriteLine("CLR didn't talk to user or spawn a debugger") + Else + 'If process is terminating, debugger checks registry for action. + 'Otherwise, CLR will deal with only the offending thread. + If e.IsTerminating = True Then + If JitDebugSetting Is Nothing Then + Console.WriteLine("No JIT debug setting in registry") + Else + Console.WriteLine("JIT debug setting: " + JitDebugSetting.ToString) + Select Case JitDebugSetting + Case 0 + Console.WriteLine("CLR asked user whether to spawn a debugger") + Case 1 + Console.WriteLine("CLR didn't talk to user or spawn a debugger") + Case 2 + Console.WriteLine("CLR spawned debugger and asked user about debugging") + Case Else + Console.WriteLine("JIT debug setting is invalid!") + End Select + End If + Else + Console.WriteLine("CLR didn't talk to user or spawn a debugger") + End If + End If + 'Write exception to console + Console.WriteLine(Environment.NewLine + "Exception text:") + Console.WriteLine(e.ExceptionObject.ToString) + Console.ReadLine() + + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln new file mode 100644 index 0000000..eb2eb9a --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnhandledExcFilter", "UnhandledExcFilter.vbproj", "{BB7379C0-225C-4404-8EF1-70A4A099FE5D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.ActiveCfg = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.Build.0 = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.ActiveCfg = Release|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.suo b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.suo new file mode 100644 index 0000000..c2349da Binary files /dev/null and b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.suo differ diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj new file mode 100644 index 0000000..b1f3e03 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj.user b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/AssemblyInfo.vb new file mode 100644 index 0000000..a28d0fc --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/TestForm.resx b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/TestForm.resx new file mode 100644 index 0000000..aa5dcd4 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/TestForm.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + TestForm + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/TestForm.vb b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/TestForm.vb new file mode 100644 index 0000000..7440978 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/TestForm.vb @@ -0,0 +1,63 @@ +Public Class TestForm + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents FireException As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.FireException = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'FireException + ' + Me.FireException.Location = New System.Drawing.Point(48, 136) + Me.FireException.Name = "FireException" + Me.FireException.Size = New System.Drawing.Size(184, 56) + Me.FireException.TabIndex = 0 + Me.FireException.Text = "&Fire exception" + ' + 'TestForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.FireException}) + Me.Name = "TestForm" + Me.Text = "WinForms exception demo" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub FireException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FireException.Click + Dim objTest As Object + objTest.GetType() + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptions.vb b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptions.vb new file mode 100644 index 0000000..2deab31 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptions.vb @@ -0,0 +1,41 @@ +Option Strict On +Imports System +Imports System.Windows.Forms + +Module UnhandledExceptions + + _ + Sub Main() + + 'First register the unhandled exception filter with the AppDomain. + 'This is useful to handle certain situations: + '1: An exception is thrown on a non-window thread or before first window launched. + '2: If a debugger is attached, unhandled exception will still reach here. + '3: If app config file specifies JIT debugging, unhandled exception still reaches here. + '4: Exceptions that are not CLS-compliant will still only be caught here. + AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionFilter + + 'In a Windows Form app, if a managed exception occurs and a debugger + 'isn't attached, the CLR will display an exception warning dialog. + 'If we want to override this dialog, we need to register a delegate + 'so that our method will be called instead. + AddHandler Application.ThreadException, AddressOf OverrideClrDialog + + 'Normal application code goes here + 'In this case, click on the form button to trigger an unhandled exception + Application.Run(New TestForm()) + + End Sub + + Private Sub UnhandledExceptionFilter(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) + 'This method deals with anything not handled by OverrideClrDialog + MsgBox(e.ExceptionObject.ToString, MsgBoxStyle.OKOnly, "UnhandledExceptionFilter: " + e.IsTerminating.ToString) + End Sub + + Private Sub OverrideClrDialog(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs) + 'This method will be called by any unhandled managed exception + 'assuming that a debugger isn't attached + MsgBox(e.Exception.ToString, MsgBoxStyle.OKOnly, "OverrideClrDialog") + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln new file mode 100644 index 0000000..f6e2f33 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnhandledExceptionsWinForms", "UnhandledExceptionsWinForms.vbproj", "{F2494349-133A-4CA8-A2E6-0F4422E9219F}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Debug.ActiveCfg = Debug|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Debug.Build.0 = Debug|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Release.ActiveCfg = Release|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.suo b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.suo new file mode 100644 index 0000000..d10a84d Binary files /dev/null and b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.suo differ diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj new file mode 100644 index 0000000..c3a564c --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj.user b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj.user new file mode 100644 index 0000000..5c92159 --- /dev/null +++ b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/obj/Debug/UnhandledExceptionsWinForms.TestForm.resources b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/obj/Debug/UnhandledExceptionsWinForms.TestForm.resources new file mode 100644 index 0000000..f15a353 Binary files /dev/null and b/Source/VisualStudio2002/Chapter13/UnhandledExceptionWinForms/obj/Debug/UnhandledExceptionsWinForms.TestForm.resources differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadDeadlock/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/AssemblyInfo.vb new file mode 100644 index 0000000..41e5ba2 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadDeadlock/DeadlockTest.vb b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/DeadlockTest.vb new file mode 100644 index 0000000..86abc9c --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/DeadlockTest.vb @@ -0,0 +1,130 @@ +Option Strict On +Imports System.Threading + +Module DeadlockTest + + Sub Main() + Dim TransferTest As New Bank(2, 10000) + 'Console.ReadLine() + End Sub + +End Module + +Class Bank + + Private m_AccountOne As New Account(1000000) + Private m_AccountTwo As New Account(1000000) + + Public Sub New(ByVal NumberOfCashiers As Integer, ByVal NumberOfTransfers As Integer) + Dim EachWorker As Integer, NewThread As Thread, Worker As Cashier + + 'Show starting conditions + Console.WriteLine("{0} cashiers are performing {1} transfers each.", _ + NumberOfCashiers.ToString, NumberOfTransfers.ToString) + + 'Start specified number of worker threads + For EachWorker = 1 To NumberOfCashiers + Worker = New Cashier(Me, NumberOfTransfers) + NewThread = New Thread(AddressOf Worker.TransferMoney) + NewThread.Name = "Cashier" & EachWorker.ToString + NewThread.Start() + Next EachWorker + + End Sub + + Public ReadOnly Property AccountOne() As Account + Get + AccountOne = m_AccountOne + End Get + End Property + + Public ReadOnly Property AccountTwo() As Account + Get + AccountTwo = m_AccountTwo + End Get + End Property + +End Class + +Class Cashier + Private m_Bank As Bank, m_WorkerId As Integer + Private m_NumberOfTransfers As Integer + + Public Sub New(ByVal AnyBank As Bank, ByVal NumberOfTransfers As Integer) + m_Bank = AnyBank + m_NumberOfTransfers = NumberOfTransfers + End Sub + + Public Sub TransferMoney() + Dim CurrentTransfer As Integer + + With m_Bank + + For CurrentTransfer = 1 To m_NumberOfTransfers + + If TrueOrFalse() = True Then + SyncLock (.AccountOne) + 'Thread.Sleep(0) + SyncLock (.AccountTwo) + .AccountOne.CreditBalance(100) + .AccountTwo.DebitBalance(100) + Console.WriteLine("{0}: Transfer {1}", _ + Thread.CurrentThread.Name, CurrentTransfer.ToString) + End SyncLock + End SyncLock + Else + SyncLock (.AccountTwo) + 'Thread.Sleep(0) + SyncLock (.AccountOne) + .AccountOne.DebitBalance(100) + .AccountTwo.CreditBalance(100) + Console.WriteLine("{0}: Transfer {1}", _ + Thread.CurrentThread.Name, CurrentTransfer.ToString) + End SyncLock + End SyncLock + End If + Next CurrentTransfer + + End With + + End Sub + + Private Function TrueOrFalse() As Boolean + Randomize() + Dim Test As Single = (Int((2 * Rnd()) + 1)) + Return CBool(Test = 1) + End Function + +End Class + +Class Account + + Private m_AccountBalance As Decimal = 0 + + Public Sub New(ByVal StartingBalance As Decimal) + m_AccountBalance = StartingBalance + End Sub + + Public ReadOnly Property AccountBalance() As Decimal + Get + AccountBalance = m_AccountBalance + End Get + End Property + + Public ReadOnly Property HasSufficientBalance(ByVal AmountToTransfer As Decimal) As Boolean + Get + HasSufficientBalance = CBool(m_AccountBalance >= AmountToTransfer) + End Get + End Property + + Public Function DebitBalance(ByVal AmountToDebit As Decimal) As Decimal + m_AccountBalance -= AmountToDebit + Return m_AccountBalance + End Function + + Public Function CreditBalance(ByVal AmountToCredit As Decimal) As Decimal + m_AccountBalance += AmountToCredit + Return m_AccountBalance + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.sln b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.sln new file mode 100644 index 0000000..d4d2893 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadDeadlock", "ThreadDeadlock.vbproj", "{7864B20A-722A-41F1-BE06-6DCD4C444FED}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Debug.ActiveCfg = Debug|.NET + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Debug.Build.0 = Debug|.NET + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Release.ActiveCfg = Release|.NET + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.suo b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.suo new file mode 100644 index 0000000..e07041d Binary files /dev/null and b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.suo differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj new file mode 100644 index 0000000..5ef8458 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj.user b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter14/ThreadGui/AssemblyInfo.vb new file mode 100644 index 0000000..55bb850 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/Calc.vb b/Source/VisualStudio2002/Chapter14/ThreadGui/Calc.vb new file mode 100644 index 0000000..d3f2f26 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/Calc.vb @@ -0,0 +1,46 @@ +Option Strict On + +Public Class Calc + + Private m_NumberToAccumulate As Int32 = 0 + Private m_NumberReached As Int32 = 0 + Private m_RunningTotal As Decimal = 0 + + Public Sub New(ByVal NumberToAccumulate As Int32) + m_NumberToAccumulate = NumberToAccumulate + End Sub + + Public Property NumberToAccumulate() As Int32 + Get + Return m_NumberToAccumulate + End Get + Set(ByVal NewValue As Int32) + m_NumberToAccumulate = NewValue + m_NumberReached = 0 + m_RunningTotal = 0 + End Set + End Property + + Public ReadOnly Property NumberReached() As Int32 + Get + Return m_NumberReached + End Get + End Property + + Public Function Accumulate(ByVal ShowProgressInterval As Int32) As Decimal + Dim LoopCounter As Int32 + + For LoopCounter = m_NumberReached To (m_NumberReached + ShowProgressInterval - 1) + If m_NumberReached <= m_NumberToAccumulate Then + m_RunningTotal += LoopCounter + m_NumberReached += 1 + Else + Exit For + End If + Next LoopCounter + + Return m_RunningTotal + + End Function + +End Class diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/MainForm.resx b/Source/VisualStudio2002/Chapter14/ThreadGui/MainForm.resx new file mode 100644 index 0000000..f073f91 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/MainForm.resx @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + Assembly + + + False + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + Assembly + + + False + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Assembly + + + MainForm + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/MainForm.vb b/Source/VisualStudio2002/Chapter14/ThreadGui/MainForm.vb new file mode 100644 index 0000000..c566e05 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/MainForm.vb @@ -0,0 +1,220 @@ +Option Strict On +Imports System.Threading +Imports System.Runtime.Remoting.Messaging + +Public Class MainForm : Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents cmdCalc As System.Windows.Forms.Button + Friend WithEvents lblResult As System.Windows.Forms.Label + Friend WithEvents txtNumber As System.Windows.Forms.TextBox + Friend WithEvents cmdCancel As System.Windows.Forms.Button + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents txtInterval As System.Windows.Forms.TextBox + Private Sub InitializeComponent() + Me.cmdCalc = New System.Windows.Forms.Button + Me.txtNumber = New System.Windows.Forms.TextBox + Me.lblResult = New System.Windows.Forms.Label + Me.cmdCancel = New System.Windows.Forms.Button + Me.Label1 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.txtInterval = New System.Windows.Forms.TextBox + Me.SuspendLayout() + ' + 'cmdCalc + ' + Me.cmdCalc.Location = New System.Drawing.Point(160, 8) + Me.cmdCalc.Name = "cmdCalc" + Me.cmdCalc.Size = New System.Drawing.Size(144, 40) + Me.cmdCalc.TabIndex = 0 + Me.cmdCalc.Text = "Accumulate" + ' + 'txtNumber + ' + Me.txtNumber.Location = New System.Drawing.Point(24, 24) + Me.txtNumber.Name = "txtNumber" + Me.txtNumber.Size = New System.Drawing.Size(112, 22) + Me.txtNumber.TabIndex = 1 + Me.txtNumber.Text = "10000" + ' + 'lblResult + ' + Me.lblResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.lblResult.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.lblResult.Location = New System.Drawing.Point(16, 128) + Me.lblResult.Name = "lblResult" + Me.lblResult.Size = New System.Drawing.Size(288, 40) + Me.lblResult.TabIndex = 2 + Me.lblResult.Text = "Result is shown here" + ' + 'cmdCancel + ' + Me.cmdCancel.Enabled = False + Me.cmdCancel.Location = New System.Drawing.Point(160, 64) + Me.cmdCancel.Name = "cmdCancel" + Me.cmdCancel.Size = New System.Drawing.Size(144, 40) + Me.cmdCancel.TabIndex = 3 + Me.cmdCancel.Text = "Cancel" + ' + 'Label1 + ' + Me.Label1.Location = New System.Drawing.Point(24, 8) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(88, 16) + Me.Label1.TabIndex = 4 + Me.Label1.Text = "Number" + ' + 'Label2 + ' + Me.Label2.Location = New System.Drawing.Point(24, 64) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(120, 16) + Me.Label2.TabIndex = 6 + Me.Label2.Text = "Display interval" + ' + 'txtInterval + ' + Me.txtInterval.Location = New System.Drawing.Point(24, 80) + Me.txtInterval.Name = "txtInterval" + Me.txtInterval.Size = New System.Drawing.Size(112, 22) + Me.txtInterval.TabIndex = 5 + Me.txtInterval.Text = "100" + ' + 'MainForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(320, 212) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.txtInterval) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.cmdCancel) + Me.Controls.Add(Me.lblResult) + Me.Controls.Add(Me.txtNumber) + Me.Controls.Add(Me.cmdCalc) + Me.Name = "MainForm" + Me.Text = "GUI multithreading" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Delegate Sub CalcDelegate(ByVal AnyNumber As Int32) + Private Delegate Sub ProgressDelegate(ByVal CurrentTotal As Decimal, ByVal NumberReached As Int32, ByRef CancelRequest As Boolean) + Private m_CancelRequested As Boolean = False + + Private Sub ButtonCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalc.Click + + 'Init calculation + Me.cmdCalc.Enabled = False + Me.cmdCancel.Enabled = True + m_CancelRequested = False + + 'Use asynch delegate to launch new thread from the thread pool + Dim CalcAccumulation As CalcDelegate = New CalcDelegate(AddressOf CalculateAccumulation) + CalcAccumulation.BeginInvoke(Convert.ToInt32(Me.txtNumber.Text), AddressOf CalcComplete, Nothing) + + End Sub + + Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click + + 'Request has been cancelled + m_CancelRequested = True + + End Sub + + Private Sub CalculateAccumulation(ByVal NumberToAccumulate As Int32) + Dim CalcObject As New Calc(NumberToAccumulate), CurrentTotal As Decimal = 0 + Dim CancelRequested As Boolean = False + + With CalcObject + + Do While .NumberReached <= NumberToAccumulate + CurrentTotal = .Accumulate(Convert.ToInt32(Me.txtInterval.Text)) + ShowProgress(CurrentTotal, .NumberReached, CancelRequested) + 'Throw New ApplicationException("Test exception") + If CancelRequested = True Then + Exit Do + End If + Loop + + End With + + End Sub + + Private Sub ShowProgress(ByVal CurrentAccumulation As Decimal, ByVal NumberReached As Int32, ByRef CancelRequest As Boolean) + + If Me.InvokeRequired = True Then + + 'Transfer to GUI thread to show progress + Dim CancelRequested As Object = False + Dim SP As ProgressDelegate = New ProgressDelegate(AddressOf ShowProgress) + Dim Arguments() As Object = New Object() {CurrentAccumulation, NumberReached, CancelRequested} + Me.Invoke(SP, Arguments) + CancelRequest = DirectCast(CancelRequested, Boolean) + + Else + + 'We're on the GUI thread, so just show progress + With Me.lblResult + .Text = "Number reached: " & NumberReached.ToString + .Text += Environment.NewLine + .Text += "Accumulated total: " & CurrentAccumulation.ToString + End With + + 'Pause for a short time to allow user to read display + Thread.CurrentThread.Sleep(100) + + 'Return any cancellation request + CancelRequest = m_CancelRequested + + End If + + End Sub + + Private Sub CalcComplete(ByVal CalcResult As System.IAsyncResult) + Dim Result As AsyncResult = CType(CalcResult, AsyncResult) + Dim OriginalDelegate As CalcDelegate = CType(Result.AsyncDelegate, CalcDelegate) + + 'Called when asynch thread completes + Me.cmdCalc.Enabled = True + Me.cmdCancel.Enabled = False + + Try + 'Find out if anything dodgy happened in the async thread + OriginalDelegate.EndInvoke(CalcResult) + Catch Exc As ApplicationException + MsgBox(Exc.Message, MsgBoxStyle.OKOnly, "Async thread exception") + End Try + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.sln b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.sln new file mode 100644 index 0000000..8360707 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadGui", "ThreadGui.vbproj", "{DFCF340A-17A9-4859-8638-D4BDED3F4BD0}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Debug.ActiveCfg = Debug|.NET + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Debug.Build.0 = Debug|.NET + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Release.ActiveCfg = Release|.NET + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.suo b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.suo new file mode 100644 index 0000000..817dcee Binary files /dev/null and b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.suo differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.vbproj b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.vbproj new file mode 100644 index 0000000..d324292 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.vbproj.user b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.vbproj.user new file mode 100644 index 0000000..eabb41d --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadGui/ThreadGui.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadGui/obj/Debug/ThreadGui.MainForm.resources b/Source/VisualStudio2002/Chapter14/ThreadGui/obj/Debug/ThreadGui.MainForm.resources new file mode 100644 index 0000000..90a56a3 Binary files /dev/null and b/Source/VisualStudio2002/Chapter14/ThreadGui/obj/Debug/ThreadGui.MainForm.resources differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter14/ThreadMonitor/AssemblyInfo.vb new file mode 100644 index 0000000..db9fc83 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/FactorialCalc.vb b/Source/VisualStudio2002/Chapter14/ThreadMonitor/FactorialCalc.vb new file mode 100644 index 0000000..0831a03 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/FactorialCalc.vb @@ -0,0 +1,18 @@ +Public Class FactorialCalc + + Public Event FactorialComplete(ByVal Factorial As Double, _ + ByVal TotalCalculations As Double) + + Public Shared Sub Factorial() + + Dim Working As Long = 1, FactorialResult As Double = 1 + Dim TotalCalcs As Long = 0 + Threading.Thread.Sleep(5000) + For Working = 1 To 20000000 + FactorialResult *= Working + TotalCalcs += 1 + Next Working + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/MainForm.resx b/Source/VisualStudio2002/Chapter14/ThreadMonitor/MainForm.resx new file mode 100644 index 0000000..c898ea7 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/MainForm.resx @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + Assembly + + + 17, 17 + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + MainForm + + + True + + + 80 + + + True + + + Assembly + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/MainForm.vb b/Source/VisualStudio2002/Chapter14/ThreadMonitor/MainForm.vb new file mode 100644 index 0000000..56ff97b --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/MainForm.vb @@ -0,0 +1,328 @@ +Option Strict On +Imports System.Threading +Imports System.Diagnostics + +Public Class MainForm : Inherits System.Windows.Forms.Form + + Private UserThreads As New Collection + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents ProcessList As System.Windows.Forms.ListBox + Friend WithEvents LabelThread As System.Windows.Forms.Label + Friend WithEvents LabelProcess As System.Windows.Forms.Label + Friend WithEvents ThreadList As System.Windows.Forms.ListView + Friend WithEvents LabelThreadName As System.Windows.Forms.Label + Friend WithEvents DisplayTimer As System.Windows.Forms.Timer + Friend WithEvents LaunchThread As System.Windows.Forms.Button + Friend WithEvents Splitter As System.Windows.Forms.Label + Friend WithEvents ManagedThreadList As System.Windows.Forms.ListView + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Me.ProcessList = New System.Windows.Forms.ListBox + Me.LabelThread = New System.Windows.Forms.Label + Me.LabelProcess = New System.Windows.Forms.Label + Me.ThreadList = New System.Windows.Forms.ListView + Me.LabelThreadName = New System.Windows.Forms.Label + Me.DisplayTimer = New System.Windows.Forms.Timer(Me.components) + Me.LaunchThread = New System.Windows.Forms.Button + Me.Splitter = New System.Windows.Forms.Label + Me.ManagedThreadList = New System.Windows.Forms.ListView + Me.SuspendLayout() + ' + 'ProcessList + ' + Me.ProcessList.ItemHeight = 16 + Me.ProcessList.Location = New System.Drawing.Point(16, 40) + Me.ProcessList.Name = "ProcessList" + Me.ProcessList.Size = New System.Drawing.Size(120, 292) + Me.ProcessList.Sorted = True + Me.ProcessList.TabIndex = 0 + ' + 'LabelThread + ' + Me.LabelThread.Location = New System.Drawing.Point(168, 8) + Me.LabelThread.Name = "LabelThread" + Me.LabelThread.Size = New System.Drawing.Size(168, 24) + Me.LabelThread.TabIndex = 2 + Me.LabelThread.Text = "Win32 threads in process:" + ' + 'LabelProcess + ' + Me.LabelProcess.Location = New System.Drawing.Point(16, 8) + Me.LabelProcess.Name = "LabelProcess" + Me.LabelProcess.Size = New System.Drawing.Size(96, 24) + Me.LabelProcess.TabIndex = 3 + Me.LabelProcess.Text = "Processes" + ' + 'ThreadList + ' + Me.ThreadList.Location = New System.Drawing.Point(176, 40) + Me.ThreadList.Name = "ThreadList" + Me.ThreadList.Size = New System.Drawing.Size(600, 296) + Me.ThreadList.TabIndex = 4 + Me.ThreadList.View = System.Windows.Forms.View.Details + ' + 'LabelThreadName + ' + Me.LabelThreadName.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.8!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.LabelThreadName.Location = New System.Drawing.Point(336, 8) + Me.LabelThreadName.Name = "LabelThreadName" + Me.LabelThreadName.Size = New System.Drawing.Size(128, 24) + Me.LabelThreadName.TabIndex = 5 + Me.LabelThreadName.Text = "Thread name" + ' + 'DisplayTimer + ' + Me.DisplayTimer.Interval = 1000 + ' + 'LaunchThread + ' + Me.LaunchThread.Location = New System.Drawing.Point(16, 384) + Me.LaunchThread.Name = "LaunchThread" + Me.LaunchThread.Size = New System.Drawing.Size(120, 40) + Me.LaunchThread.TabIndex = 6 + Me.LaunchThread.Text = "Launch thread" + ' + 'Splitter + ' + Me.Splitter.BackColor = System.Drawing.SystemColors.ControlDarkDark + Me.Splitter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.Splitter.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.8!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Splitter.Location = New System.Drawing.Point(16, 360) + Me.Splitter.Name = "Splitter" + Me.Splitter.Size = New System.Drawing.Size(760, 3) + Me.Splitter.TabIndex = 7 + ' + 'ManagedThreadList + ' + Me.ManagedThreadList.Location = New System.Drawing.Point(176, 384) + Me.ManagedThreadList.Name = "ManagedThreadList" + Me.ManagedThreadList.Size = New System.Drawing.Size(600, 296) + Me.ManagedThreadList.TabIndex = 8 + Me.ManagedThreadList.View = System.Windows.Forms.View.Details + ' + 'MainForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(800, 700) + Me.Controls.Add(Me.ManagedThreadList) + Me.Controls.Add(Me.Splitter) + Me.Controls.Add(Me.LaunchThread) + Me.Controls.Add(Me.LabelThreadName) + Me.Controls.Add(Me.ThreadList) + Me.Controls.Add(Me.LabelProcess) + Me.Controls.Add(Me.LabelThread) + Me.Controls.Add(Me.ProcessList) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Thread monitor" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + + 'Setup thread display + With Me.ThreadList + .Columns.Add("Id", 50, HorizontalAlignment.Right) + .Columns.Add("Priority", 100, HorizontalAlignment.Left) + .Columns.Add("State", 80, HorizontalAlignment.Left) + .Columns.Add("Wait reason", 120, HorizontalAlignment.Left) + .Columns.Add("Time in app", 100, HorizontalAlignment.Left) + .Columns.Add("Total time", 100, HorizontalAlignment.Left) + End With + + 'Setup managed thread display + With Me.ManagedThreadList + .Columns.Add("Id", 50, HorizontalAlignment.Right) + .Columns.Add("Name", 150, HorizontalAlignment.Left) + .Columns.Add("Priority", 100, HorizontalAlignment.Left) + .Columns.Add("State", 120, HorizontalAlignment.Left) + .Columns.Add("Background?", 100, HorizontalAlignment.Left) + .Columns.Add("Pooled?", 80, HorizontalAlignment.Left) + End With + + 'Show processes + UpdateProcessDisplay() + 'Show Win32 threads for first process + Me.ProcessList.SetSelected(0, True) + 'Set thread displays to update regularly + Me.DisplayTimer.Interval = 1000 + Me.DisplayTimer.Enabled = True + + End Sub + + Private Sub ProcessList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProcessList.SelectedIndexChanged + + 'Display threads for process chosen by end-user + UpdateWin32ThreadDisplay(DirectCast(ProcessList.SelectedItem, Process).Id) + + End Sub + + Private Sub LaunchThread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LaunchThread.Click + + Dim TempThread As New Thread(New ThreadStart(AddressOf FactorialCalc.Factorial)) + 'User wants new thread - launch and add to collection + With TempThread + .Name = "User thread " & UserThreads.Count.ToString + .Priority = ThreadPriority.BelowNormal + UserThreads.Add(TempThread, .GetHashCode.ToString) + .Start() + End With + + End Sub + + Private Sub DisplayTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayTimer.Tick + + 'Re-display threads for currently-selected process + UpdateUserThreadDisplay() + UpdateWin32ThreadDisplay(DirectCast(ProcessList.SelectedItem, Process).Id) + + End Sub + + Private Sub UpdateProcessDisplay() + Dim MachineProcesses() As Process + + 'Retrieve, store and display processes on this machine + MachineProcesses = Process.GetProcesses() + With Me.ProcessList + .DataSource = MachineProcesses + .DisplayMember = "ProcessName" + End With + + End Sub + + Private Sub UpdateWin32ThreadDisplay(ByVal SelectedProcessId As Integer) + Dim SelectedProcess As Process + Dim ThisThread As ProcessThread, LV_item As ListViewItem + + 'Get Win32 threads for this process and display them + SelectedProcess = Process.GetProcessById(SelectedProcessId) + LabelThreadName.Text = SelectedProcess.ProcessName + + With Me.ThreadList + .BeginUpdate() + .Items.Clear() + + 'Iterate through every Win32 thread in this process + For Each ThisThread In SelectedProcess.Threads + + Try + 'Add thread id + LV_item = New ListViewItem(ThisThread.Id.ToString) + 'Add thread details + With LV_item.SubItems + 'Thread priority + .Add(ThisThread.PriorityLevel.ToString) + 'Thread state + .Add(ThisThread.ThreadState.ToString) + 'Reason for thread wait + If ThisThread.ThreadState = Diagnostics.ThreadState.Wait Then + .Add(ThisThread.WaitReason.ToString) + Else + .Add(vbNullString) + End If + 'Thread time in app + .Add(ThisThread.UserProcessorTime.TotalMilliseconds.ToString) + 'Thread time in OS + .Add(ThisThread.TotalProcessorTime.TotalMilliseconds.ToString) + End With + 'Display the thread + .Items.Add(LV_item) + + Catch Exc As InvalidOperationException + 'Thread's disappeared - ignore + + End Try + + Next ThisThread + + .EndUpdate() + End With + + End Sub + + Private Sub UpdateUserThreadDisplay() + Dim ThisThread As Threading.Thread, LV_item As ListViewItem + + 'Iterate through managed threads for current process + With Me.ManagedThreadList + .BeginUpdate() + .Items.Clear() + + 'Iterate through every thread in this process + For Each ThisThread In UserThreads + + If ThisThread.IsAlive Then + + Try + 'Add thread id + LV_item = New ListViewItem(ThisThread.GetHashCode.ToString) + 'Add thread details + With LV_item.SubItems + 'Add thread name + .Add(ThisThread.Name) + 'Thread priority + .Add(ThisThread.Priority.ToString) + 'Thread state + .Add(ThisThread.ThreadState.ToString) + 'Thread is alive? + .Add(ThisThread.IsAlive.ToString) + 'Background thread? + .Add(ThisThread.IsBackground.ToString) + 'Threadpool thread? + .Add(ThisThread.IsThreadPoolThread.ToString) + End With + 'Display the thread + .Items.Add(LV_item) + + Catch Exc As Threading.ThreadStateException + 'Thread's disappeared - ignore + UserThreads.Remove(ThisThread.GetHashCode.ToString) + + End Try + + Else + + 'Thread's dead - remove from collection + UserThreads.Remove(ThisThread.GetHashCode.ToString) + + End If + + Next ThisThread + + .EndUpdate() + End With + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.sln b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.sln new file mode 100644 index 0000000..93c9273 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadMonitor", "ThreadMonitor.vbproj", "{D7CF35FF-B087-4604-8B22-67DB44DC7B50}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Debug.ActiveCfg = Debug|.NET + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Debug.Build.0 = Debug|.NET + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Release.ActiveCfg = Release|.NET + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.suo b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.suo new file mode 100644 index 0000000..9cbd229 Binary files /dev/null and b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.suo differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.vbproj b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.vbproj new file mode 100644 index 0000000..9867eac --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.vbproj.user b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.vbproj.user new file mode 100644 index 0000000..c168d10 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadMonitor/ThreadMonitor.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadMonitor/obj/Debug/ThreadMonitor.MainForm.resources b/Source/VisualStudio2002/Chapter14/ThreadMonitor/obj/Debug/ThreadMonitor.MainForm.resources new file mode 100644 index 0000000..8ecc987 Binary files /dev/null and b/Source/VisualStudio2002/Chapter14/ThreadMonitor/obj/Debug/ThreadMonitor.MainForm.resources differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadSynch/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter14/ThreadSynch/AssemblyInfo.vb new file mode 100644 index 0000000..3054d09 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadSynch/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadSynch/CountMonitor.vb b/Source/VisualStudio2002/Chapter14/ThreadSynch/CountMonitor.vb new file mode 100644 index 0000000..1ccdc72 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadSynch/CountMonitor.vb @@ -0,0 +1,86 @@ +Option Strict On +Imports System.Threading + +Module CountMonitor + + Sub Main() + Dim CountTest As New CountCoordinator(5) + Console.ReadLine() + End Sub + +End Module + +Class CountCoordinator + + Private Const MAX_COUNT As Integer = 99 + Private m_Counter As Integer = 0 + + Public Sub New(ByVal NumberOfCounters As Integer) + Dim EachWorker As Integer, NewThread As Thread, Worker As CountWorker + + 'Show starting conditions + Console.WriteLine("Count started at {0} with max value of {1}.", _ + CStr(Me.CurrentCount), CStr(Me.MaxCount)) + Console.WriteLine("{0} worker threads are doing the counting.", _ + CStr(NumberOfCounters)) + 'Start specified number of worker threads + For EachWorker = 1 To NumberOfCounters + Worker = New CountWorker(Me, EachWorker) + NewThread = New Thread(AddressOf Worker.IncrementCount) + NewThread.Start() + Next EachWorker + + End Sub + + Public Property CurrentCount() As Integer + Get + Return m_Counter + End Get + Set(ByVal Value As Integer) + m_Counter = Value + End Set + End Property + + Public ReadOnly Property MaxCount() As Integer + Get + Return MAX_COUNT + End Get + End Property + +End Class + +Class CountWorker + Private m_Coordinator As CountCoordinator + Private m_WorkerId As Integer + + Public Sub New(ByVal Coordinator As CountCoordinator, ByVal WorkerId As Integer) + m_Coordinator = Coordinator + m_WorkerId = WorkerId + End Sub + + Public Sub IncrementCount() + + 'Increment shared counter until equal to maximum allowed + With m_Coordinator + + Do While .CurrentCount < .MaxCount + 'SyncLock (m_Coordinator) + Select Case .CurrentCount + Case Is < (.MaxCount - 10) + Thread.Sleep(0) + .CurrentCount += 10 + Case Is < .MaxCount + Thread.Sleep(0) + .CurrentCount += 1 + Case Else + End Select + 'End SyncLock + Console.WriteLine("Worker {0} current count {1}", _ + CStr(m_WorkerId), CStr(.CurrentCount)) + Loop + + End With + + End Sub + +End Class diff --git a/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.sln b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.sln new file mode 100644 index 0000000..ad8255b --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadSynch", "ThreadSynch.vbproj", "{970BC01E-8AA4-445D-B714-C5C376206C09}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {970BC01E-8AA4-445D-B714-C5C376206C09}.Debug.ActiveCfg = Debug|.NET + {970BC01E-8AA4-445D-B714-C5C376206C09}.Debug.Build.0 = Debug|.NET + {970BC01E-8AA4-445D-B714-C5C376206C09}.Release.ActiveCfg = Release|.NET + {970BC01E-8AA4-445D-B714-C5C376206C09}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.suo b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.suo new file mode 100644 index 0000000..44e9559 Binary files /dev/null and b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.suo differ diff --git a/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.vbproj b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.vbproj new file mode 100644 index 0000000..a55daf6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.vbproj.user b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.vbproj.user new file mode 100644 index 0000000..a6e254a --- /dev/null +++ b/Source/VisualStudio2002/Chapter14/ThreadSynch/ThreadSynch.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/Heartbeat/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter15/Heartbeat/AssemblyInfo.vb new file mode 100644 index 0000000..83b7225 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/Heartbeat/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vb b/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vb new file mode 100644 index 0000000..f4660be --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vb @@ -0,0 +1,20 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting.Messaging + +Public Class Heartbeat : Inherits MarshalByRefObject + Public Event HeartbeatLocal(ByVal LocalComponent As String) + Public Event HeartbeatRemote(ByVal LocalMonitor As String, ByVal StatusReport As String) + + _ + Public Sub Heartbeat(ByVal LocalComponent As String) + RaiseEvent HeartbeatLocal(LocalComponent) + End Sub + + _ + Public Sub RemoteHeartbeat(ByVal LocalMonitor As String, ByVal StatusReport As String) + RaiseEvent HeartbeatRemote(LocalMonitor, StatusReport) + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vbproj b/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vbproj new file mode 100644 index 0000000..fd74a1f --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vbproj.user b/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vbproj.user new file mode 100644 index 0000000..447fdc6 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/Heartbeat/Heartbeat.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/HeartbeatClient/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter15/HeartbeatClient/AssemblyInfo.vb new file mode 100644 index 0000000..2c8b8da --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/HeartbeatClient/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vb b/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vb new file mode 100644 index 0000000..435b7d7 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vb @@ -0,0 +1,48 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting +Imports Monitoring +Imports System.Threading + +Module Client + Private Const MY_ID As String = "Client" + Private Delegate Sub HeartbeatThread(ByVal HeartbeatInterval As Int32) + Private m_StopHeartbeats As Boolean = False + + Sub Main() + + Console.WriteLine("Starting client") + Dim HT As New HeartbeatThread(AddressOf Heartbeats) + Dim ThreadResult As IAsyncResult = HT.BeginInvoke(2, Nothing, Nothing) + + Console.WriteLine("Press 'Enter' to terminate client...") + Console.ReadLine() + + Console.WriteLine("Terminating client") + m_StopHeartbeats = True + HT.EndInvoke(ThreadResult) + + End Sub + + Private Sub Heartbeats(ByVal HeartbeatInterval As Int32) + + 'Find local monitor + Console.WriteLine("Finding local monitor") + Dim Listener As New Heartbeat + Listener = CType(Activator.GetObject(GetType(Heartbeat), _ + "tcp://localhost:8080/Heartbeat.dll"), Heartbeat) + + 'Send regular heartbeats to local monitor + Do While m_StopHeartbeats = False + Listener.Heartbeat(MY_ID) + Console.WriteLine("Heartbeat sent to local monitor") + Thread.Sleep(HeartbeatInterval * 1000) + Loop + + 'Terminate heartbeat thread + Console.WriteLine("Stopping heartbeats") + + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vbproj b/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vbproj new file mode 100644 index 0000000..ee60720 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vbproj @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vbproj.user b/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vbproj.user new file mode 100644 index 0000000..86f0316 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/HeartbeatClient/HeartbeatClient.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/HeartbeatMonitor.sln b/Source/VisualStudio2002/Chapter15/HeartbeatMonitor.sln new file mode 100644 index 0000000..e14cf11 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/HeartbeatMonitor.sln @@ -0,0 +1,39 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LocalMonitor", "LocalMonitor\LocalMonitor.vbproj", "{0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Heartbeat", "Heartbeat\Heartbeat.vbproj", "{938247CE-2129-436B-9133-48AF121B1E0A}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HeartbeatClient", "HeartbeatClient\HeartbeatClient.vbproj", "{9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RemoteMonitor", "RemoteMonitor\RemoteMonitor.vbproj", "{1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Debug.ActiveCfg = Debug|.NET + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Debug.Build.0 = Debug|.NET + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Release.ActiveCfg = Release|.NET + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Release.Build.0 = Release|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Debug.ActiveCfg = Debug|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Debug.Build.0 = Debug|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Release.ActiveCfg = Release|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Release.Build.0 = Release|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Debug.ActiveCfg = Debug|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Debug.Build.0 = Debug|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Release.ActiveCfg = Release|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Release.Build.0 = Release|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Debug.ActiveCfg = Debug|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Debug.Build.0 = Debug|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Release.ActiveCfg = Release|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2002/Chapter15/HeartbeatMonitor.suo b/Source/VisualStudio2002/Chapter15/HeartbeatMonitor.suo new file mode 100644 index 0000000..9b03844 Binary files /dev/null and b/Source/VisualStudio2002/Chapter15/HeartbeatMonitor.suo differ diff --git a/Source/VisualStudio2002/Chapter15/LocalMonitor/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter15/LocalMonitor/AssemblyInfo.vb new file mode 100644 index 0000000..399c034 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/LocalMonitor/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.config b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.config new file mode 100644 index 0000000..690767d --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vb b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vb new file mode 100644 index 0000000..e57688c --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vb @@ -0,0 +1,65 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting +Imports System.Threading +Imports Monitoring + +Module Monitor + Private Const MY_ID As String = "LocalMonitor" + Private Delegate Sub HeartbeatThread(ByVal HeartbeatInterval As Int32) + Private m_StopHeartbeats As Boolean = False + Private m_StatusReport As String = "No heartbeats received" + Private WithEvents m_Listener As Heartbeat + + Sub Main() + + Console.WriteLine("Starting local monitor") + RemotingConfiguration.Configure("LocalMonitor.config") + + Console.WriteLine("Creating local listener") + m_Listener = New Heartbeat + RemotingServices.Marshal(m_Listener, "Heartbeat.dll") + + Dim HT As New HeartbeatThread(AddressOf Heartbeats) + Dim ThreadResult As IAsyncResult = HT.BeginInvoke(10, Nothing, Nothing) + + Console.WriteLine("Now listening - press 'Enter' to terminate local monitor...") + Console.ReadLine() + + Console.WriteLine("Local monitor terminating") + m_StopHeartbeats = True + HT.EndInvoke(ThreadResult) + + RemotingServices.Disconnect(m_Listener) + m_Listener = Nothing + + End Sub + + Private Sub Heartbeats(ByVal HeartbeatInterval As Int32) + + 'Find remote monitor + Console.WriteLine("Finding remote monitor") + Dim Listener As New Heartbeat + Listener = CType(Activator.GetObject(GetType(Heartbeat), _ + "tcp://localhost:8081/Heartbeat.dll"), Heartbeat) + + 'Send regular heartbeats to remote monitor + Do While m_StopHeartbeats = False + Listener.RemoteHeartbeat(MY_ID, m_StatusReport) + Console.WriteLine("Heartbeat sent to remote monitor") + Thread.Sleep(HeartbeatInterval * 1000) + Loop + + 'Terminate heartbeat thread + Console.WriteLine("Stopping heartbeats") + + End Sub + + Private Sub m_Listener_HeartbeatLocal(ByVal LocalComponent As String) Handles m_Listener.HeartbeatLocal + 'Listen for regular heartbeats from local component + Console.WriteLine("Heartbeat received from " & LocalComponent) + m_StatusReport = "Last heartbeat received from " & LocalComponent & " at " & Format$(Now, "hh:mm:ss") + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vbproj b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vbproj new file mode 100644 index 0000000..c3504c3 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vbproj @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vbproj.user b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vbproj.user new file mode 100644 index 0000000..6435010 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/LocalMonitor/LocalMonitor.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/LocalMonitor/bin/LocalMonitor.config b/Source/VisualStudio2002/Chapter15/LocalMonitor/bin/LocalMonitor.config new file mode 100644 index 0000000..690767d --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/LocalMonitor/bin/LocalMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/RemoteMonitor/AssemblyInfo.vb b/Source/VisualStudio2002/Chapter15/RemoteMonitor/AssemblyInfo.vb new file mode 100644 index 0000000..a1564e1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/RemoteMonitor/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.config b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.config new file mode 100644 index 0000000..b242261 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vb b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vb new file mode 100644 index 0000000..3669571 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vb @@ -0,0 +1,34 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting +Imports Monitoring + +Module RemoteMonitor + Private WithEvents m_Listener As Heartbeat + + Sub Main() + + Console.WriteLine("Starting remote monitor") + RemotingConfiguration.Configure("RemoteMonitor.config") + + Console.WriteLine("Creating remote listener") + m_Listener = New Heartbeat + RemotingServices.Marshal(m_Listener, "Heartbeat.dll") + + Console.WriteLine("Now listening - press 'Enter' to terminate remote monitor...") + Console.ReadLine() + + Console.WriteLine("Remote monitor terminating") + RemotingServices.Disconnect(m_Listener) + m_Listener = Nothing + + End Sub + + Private Sub m_Listener_HeartbeatRemote(ByVal LocalMonitor As String, ByVal StatusReport As String) Handles m_Listener.HeartbeatRemote + 'Listen for regular heartbeats from local monitor + Console.WriteLine("Status report received from " & LocalMonitor) + Console.WriteLine(StatusReport) + End Sub + +End Module diff --git a/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vbproj b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vbproj new file mode 100644 index 0000000..b11a815 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vbproj @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vbproj.user b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vbproj.user new file mode 100644 index 0000000..81551f1 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/RemoteMonitor/RemoteMonitor.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2002/Chapter15/RemoteMonitor/bin/RemoteMonitor.config b/Source/VisualStudio2002/Chapter15/RemoteMonitor/bin/RemoteMonitor.config new file mode 100644 index 0000000..b242261 --- /dev/null +++ b/Source/VisualStudio2002/Chapter15/RemoteMonitor/bin/RemoteMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-1/AssemblyInfo.vb new file mode 100644 index 0000000..a30ae2c --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-1/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.sln b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.sln new file mode 100644 index 0000000..bfcaa61 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-1", "Listing2-1.vbproj", "{31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Debug.ActiveCfg = Debug|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Debug.Build.0 = Debug|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Release.ActiveCfg = Release|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.sln.old new file mode 100644 index 0000000..050d62b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-1", "Listing2-1.vbproj", "{31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Debug.ActiveCfg = Debug|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Debug.Build.0 = Debug|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Release.ActiveCfg = Release|.NET + {31835C14-E9E6-4D1D-BCF5-6DACB521A7BF}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.suo b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.suo new file mode 100644 index 0000000..9a4ca4e Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.vbproj new file mode 100644 index 0000000..5d0bc34 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-1/Listing2-1.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-1/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-1/Test.vb new file mode 100644 index 0000000..4482e2a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-1/Test.vb @@ -0,0 +1,10 @@ +Option Strict On +Module Test + + Sub Main() + Console.WriteLine("CInt(True) = " + CInt(True).ToString) + Console.WriteLine("Convert(True) = " + Convert.ToInt16(True).ToString) + Console.ReadLine() + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-10/AssemblyInfo.vb new file mode 100644 index 0000000..e112cff --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-10/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.sln b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.sln new file mode 100644 index 0000000..3847e42 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-10", "Listing2-10.vbproj", "{EF22FDFF-8665-44CF-BADC-362A5663C0C1}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Debug.ActiveCfg = Debug|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Debug.Build.0 = Debug|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Release.ActiveCfg = Release|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.sln.old new file mode 100644 index 0000000..001af0f --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-10", "Listing2-10.vbproj", "{EF22FDFF-8665-44CF-BADC-362A5663C0C1}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Debug.ActiveCfg = Debug|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Debug.Build.0 = Debug|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Release.ActiveCfg = Release|.NET + {EF22FDFF-8665-44CF-BADC-362A5663C0C1}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.suo b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.suo new file mode 100644 index 0000000..58b9f6a Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.vbproj new file mode 100644 index 0000000..eb74a90 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-10/Listing2-10.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-10/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-10/Test.vb new file mode 100644 index 0000000..f8167fa --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-10/Test.vb @@ -0,0 +1,75 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Overrides Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + + 'This overload doesn't work for a subtle reason + ' Overloads Function Equals(ByVal AnyCat As Cat) As Boolean + ' Return True + ' End Function + + 'This overload works + Overloads Overrides Function Equals(ByVal Obj As Object) As Boolean + If Object.ReferenceEquals(Obj.GetType, New Cat().GetType) Then + Return True + Else + Return MyBase.Equals(Obj) + End If + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-11/AssemblyInfo.vb new file mode 100644 index 0000000..6b2d11e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-11/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.sln b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.sln new file mode 100644 index 0000000..2180440 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-11", "Listing2-11.vbproj", "{0A591B27-8004-4912-A3B5-30B98AB99CBD}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Debug.ActiveCfg = Debug|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Debug.Build.0 = Debug|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Release.ActiveCfg = Release|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.sln.old new file mode 100644 index 0000000..8172cdc --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-11", "Listing2-11.vbproj", "{0A591B27-8004-4912-A3B5-30B98AB99CBD}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Debug.ActiveCfg = Debug|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Debug.Build.0 = Debug|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Release.ActiveCfg = Release|.NET + {0A591B27-8004-4912-A3B5-30B98AB99CBD}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.suo b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.suo new file mode 100644 index 0000000..8ff43c7 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.vbproj new file mode 100644 index 0000000..7848aed --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-11/Listing2-11.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-11/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-11/Test.vb new file mode 100644 index 0000000..59ebfd6 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-11/Test.vb @@ -0,0 +1,46 @@ +Option Strict On + +Class Animal + + Public Shared Sub Main() + + Dim objMan As New Man() + Dim objFeline As New Feline(), objCat As New Cat() + + Console.WriteLine(objMan.ClassName("This Man")) + Console.WriteLine(objFeline.ClassName("This Feline")) + Console.WriteLine(objCat.ClassName("This Cat")) + + Console.ReadLine() + + End Sub + + Protected Overridable Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be an Animal" + End Function + +End Class + +Class Man : Inherits Animal + + Protected Overrides Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be a Man" + End Function + +End Class + +Class Feline : Inherits Animal + + Protected Overridable Shadows Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be a Feline" + End Function + +End Class + +Class Cat : Inherits Feline + + Protected Overrides Function ClassName(ByVal CallingType As String) As String + Return CallingType + " appears to be a Cat" + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-12/AssemblyInfo.vb new file mode 100644 index 0000000..0b31830 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.sln b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.sln new file mode 100644 index 0000000..1e00981 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-12", "Listing2-12.vbproj", "{F7816CB3-4B61-46D1-9241-1846A926DF73}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Debug.ActiveCfg = Debug|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Debug.Build.0 = Debug|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Release.ActiveCfg = Release|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.sln.old new file mode 100644 index 0000000..0e6cd83 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-12", "Listing2-12.vbproj", "{F7816CB3-4B61-46D1-9241-1846A926DF73}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Debug.ActiveCfg = Debug|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Debug.Build.0 = Debug|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Release.ActiveCfg = Release|.NET + {F7816CB3-4B61-46D1-9241-1846A926DF73}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.suo b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.suo new file mode 100644 index 0000000..4092270 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.vbproj new file mode 100644 index 0000000..12432a8 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12/Listing2-12.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-12/Test.vb new file mode 100644 index 0000000..900e2ae --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12/Test.vb @@ -0,0 +1,32 @@ +Option Strict On + +Class Test + + Shared Sub Main() + Dim objDerived As New Derived() + Console.WriteLine(objDerived.ClassName()) + Console.WriteLine(objDerived.BaseName()) + Console.ReadLine() + End Sub + +End Class + +Class Base + + Public Overridable Function ClassName() As String + Return MyClass.ToString + End Function + +End Class + +Class Derived : Inherits Base + + Public Overrides Function ClassName() As String + Return MyClass.ToString + End Function + + Public Function BaseName() As String + Return MyBase.ClassName() + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/AssemblyInfo.vb new file mode 100644 index 0000000..0dcf904 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln new file mode 100644 index 0000000..b500c2a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-12Stackframe", "Listing2-12Stackframe.vbproj", "{1CFE5D0F-986E-4E1C-A72A-A210B05D289F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Debug.ActiveCfg = Debug|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Debug.Build.0 = Debug|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Release.ActiveCfg = Release|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln.old new file mode 100644 index 0000000..1b14374 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-12Stackframe", "Listing2-12Stackframe.vbproj", "{1CFE5D0F-986E-4E1C-A72A-A210B05D289F}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Debug.ActiveCfg = Debug|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Debug.Build.0 = Debug|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Release.ActiveCfg = Release|.NET + {1CFE5D0F-986E-4E1C-A72A-A210B05D289F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.suo b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.suo new file mode 100644 index 0000000..bab59dc Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj new file mode 100644 index 0000000..cf16637 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Listing2-12Stackframe.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Test.vb new file mode 100644 index 0000000..3bc515a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-12Stackframe/Test.vb @@ -0,0 +1,37 @@ +Class Test + + Public Shared Sub Main() + Dim objDerived As New Derived(), objBase As New Base() + Console.WriteLine(objDerived.ClassName()) + Console.WriteLine(objDerived.BaseName()) + Console.ReadLine() + End Sub + + Public Shared Function ImmediateClassName() As String + Dim objStackFrame As New Diagnostics.StackFrame(1) + Return objStackFrame.GetMethod.DeclaringType.FullName + End Function + +End Class + +Class Base + + Public Overridable Function ClassName() As String + 'Return MyClass.ToString + Return Test.ImmediateClassName + End Function + +End Class + +Class Derived : Inherits Base + + Public Overrides Function ClassName() As String + 'Return MyClass.ToString + Return Test.ImmediateClassName + End Function + + Public Function BaseName() As String + Return MyBase.ClassName() + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-18/AssemblyInfo.vb new file mode 100644 index 0000000..7a043b5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-18/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.sln b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.sln new file mode 100644 index 0000000..955a3c3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-18", "Listing2-18.vbproj", "{4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Debug.ActiveCfg = Debug|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Debug.Build.0 = Debug|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Release.ActiveCfg = Release|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.sln.old new file mode 100644 index 0000000..8a6e7be --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-18", "Listing2-18.vbproj", "{4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Debug.ActiveCfg = Debug|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Debug.Build.0 = Debug|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Release.ActiveCfg = Release|.NET + {4EC7FFD5-79F6-41A4-88B1-D34DDDB520D5}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.suo b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.suo new file mode 100644 index 0000000..6efa9a4 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.vbproj new file mode 100644 index 0000000..90e16b6 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-18/Listing2-18.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-18/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-18/Test.vb new file mode 100644 index 0000000..b50b6ca --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-18/Test.vb @@ -0,0 +1,32 @@ +Option Strict Off + +Module Test + + Sub Main() + + Console.WriteLine("Developer sees: " & WhatDeveloperSees.ToString) + Console.WriteLine("Compiler says: " & WhatCompilerSees.ToString) + Console.ReadLine() + + End Sub + + Function WhatDeveloperWrites() As Integer + Dim A As Integer = 0, B As Integer = 1, C As Integer = 2 + A = B = C + Return A + End Function + + Function WhatDeveloperSees() As Integer + Dim A As Integer = 0, B As Integer = 1, C As Integer = 2 + B = C + A = B + Return A + End Function + + Function WhatCompilerSees() As Integer + Dim A As Integer = 0, B As Integer = 1, C As Integer = 2 + A = CInt(CBool(B = C)) + Return A + End Function + +End Module diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-2/AssemblyInfo.vb new file mode 100644 index 0000000..ed6a10b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-2/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.sln b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.sln new file mode 100644 index 0000000..a70f9d4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-2", "Listing2-2.vbproj", "{19A44278-676F-492D-8EB2-7C47C9EEDDDE}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Debug.ActiveCfg = Debug|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Debug.Build.0 = Debug|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Release.ActiveCfg = Release|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.sln.old new file mode 100644 index 0000000..d8a367b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-2", "Listing2-2.vbproj", "{19A44278-676F-492D-8EB2-7C47C9EEDDDE}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Debug.ActiveCfg = Debug|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Debug.Build.0 = Debug|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Release.ActiveCfg = Release|.NET + {19A44278-676F-492D-8EB2-7C47C9EEDDDE}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.suo b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.suo new file mode 100644 index 0000000..d8e403b Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.vbproj new file mode 100644 index 0000000..1c3fe7e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-2/Listing2-2.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-2/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-2/Test.vb new file mode 100644 index 0000000..642f4fb --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-2/Test.vb @@ -0,0 +1,35 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + Dim objMyTest As New Derived() + With objMyTest + .WriteLine(10) + .WriteLine(10.5) + .WriteLine("11") + End With + Console.ReadLine() + End Sub + +End Class + +Class Base + + Public Sub WriteLine(ByVal AnyString As String) + Console.WriteLine(AnyString + " called Base:String") + End Sub + + Public Sub WriteLine(ByVal AnyInteger As Integer) + Console.WriteLine(AnyInteger.ToString + " called Base:Integer") + End Sub + +End Class + +Class Derived : Inherits Base + + Public Overloads Sub WriteLine(ByVal AnyDouble As Double) + Console.WriteLine(AnyDouble.ToString + " called Derived:Double") + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/App.ico b/Source/VisualStudio2003/Chapter02/Listing2-21/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-21/App.ico differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/AssemblyInfo.cs b/Source/VisualStudio2003/Chapter02/Listing2-21/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-21/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.csproj b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.csproj new file mode 100644 index 0000000..c32a65b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.csproj @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.csproj.user b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.csproj.user new file mode 100644 index 0000000..cddade4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.sln b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.sln new file mode 100644 index 0000000..8508a4e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-21", "Listing2-21.csproj", "{4A3E4205-AC32-4528-BAA8-9A29F869DB90}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Debug.ActiveCfg = Debug|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Debug.Build.0 = Debug|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Release.ActiveCfg = Release|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.sln.old new file mode 100644 index 0000000..3f6c9f3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-21", "Listing2-21.csproj", "{4A3E4205-AC32-4528-BAA8-9A29F869DB90}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Debug.ActiveCfg = Debug|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Debug.Build.0 = Debug|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Release.ActiveCfg = Release|.NET + {4A3E4205-AC32-4528-BAA8-9A29F869DB90}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.suo b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.suo new file mode 100644 index 0000000..83095e3 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-21/Listing2-21.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/Test.cs b/Source/VisualStudio2003/Chapter02/Listing2-21/Test.cs new file mode 100644 index 0000000..59f688d --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-21/Test.cs @@ -0,0 +1,10 @@ +class Test + { + public static void Main() + { + int A = 0; int B = 1; int C = 2; + A = B = C; + System.Console.WriteLine("Developer and compiler both see: " + A); + System.Console.ReadLine(); + } + } diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/obj/Debug/Listing2-21.exe.incr b/Source/VisualStudio2003/Chapter02/Listing2-21/obj/Debug/Listing2-21.exe.incr new file mode 100644 index 0000000..5e28457 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-21/obj/Debug/Listing2-21.exe.incr differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-21/obj/Debug/Listing2-21.projdata b/Source/VisualStudio2003/Chapter02/Listing2-21/obj/Debug/Listing2-21.projdata new file mode 100644 index 0000000..fd77273 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-21/obj/Debug/Listing2-21.projdata differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-23/AssemblyInfo.vb new file mode 100644 index 0000000..92cb0fe --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-23/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.sln b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.sln new file mode 100644 index 0000000..642ce4d --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-23", "Listing2-23.vbproj", "{A32A373F-CB08-48F6-80B2-5C6C0671BB58}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Debug.ActiveCfg = Debug|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Debug.Build.0 = Debug|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Release.ActiveCfg = Release|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.sln.old new file mode 100644 index 0000000..8da8d1a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-23", "Listing2-23.vbproj", "{A32A373F-CB08-48F6-80B2-5C6C0671BB58}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Debug.ActiveCfg = Debug|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Debug.Build.0 = Debug|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Release.ActiveCfg = Release|.NET + {A32A373F-CB08-48F6-80B2-5C6C0671BB58}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.suo b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.suo new file mode 100644 index 0000000..13146f2 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.vbproj new file mode 100644 index 0000000..10f8d03 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-23/Listing2-23.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-23/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-23/Test.vb new file mode 100644 index 0000000..cb46568 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-23/Test.vb @@ -0,0 +1,23 @@ +Option Strict On + +Module BoxingTest + + Sub Main() + Dim MyBoolean As Boolean = False + Dim MyObject As Object = False + + SwitchBoolean(CType(MyBoolean, Boolean)) + Console.WriteLine("MyBoolean = " & MyBoolean.ToString) + + SwitchBoolean(MyObject) + Console.WriteLine("MyObject = " & MyObject.ToString) + + Console.ReadLine() + + End Sub + + Private Sub SwitchBoolean(ByRef TestBoolean As Object) + TestBoolean = True + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-24/AssemblyInfo.vb new file mode 100644 index 0000000..c10371f --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-24/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.sln b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.sln new file mode 100644 index 0000000..7a633d7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-24", "Listing2-24.vbproj", "{9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Debug.ActiveCfg = Debug|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Debug.Build.0 = Debug|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Release.ActiveCfg = Release|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.sln.old new file mode 100644 index 0000000..cfcc213 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-24", "Listing2-24.vbproj", "{9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Debug.ActiveCfg = Debug|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Debug.Build.0 = Debug|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Release.ActiveCfg = Release|.NET + {9EB9FD3F-D64A-4AA0-86E3-91D55050FCAB}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.suo b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.suo new file mode 100644 index 0000000..08b20d2 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.vbproj new file mode 100644 index 0000000..c4d421a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-24/Listing2-24.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-24/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-24/Test.vb new file mode 100644 index 0000000..ed87459 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-24/Test.vb @@ -0,0 +1,107 @@ +Option Strict On + +Module Test + + Sub Main() + Dim intTest As Integer, dblTest As Double + Dim intZero As Integer = 0, blnExceptionThrown As Boolean = False + + 'First test + Console.WriteLine("Integer division by zero assigned to integer:") + blnExceptionThrown = False + Try + intTest = 5 \ intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + intTest.ToString) + End If + Console.WriteLine() + End Try + + 'Second test + Console.WriteLine("Integer division by zero assigned to double:") + blnExceptionThrown = False + Try + dblTest = 5 \ intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + dblTest.ToString) + End If + Console.WriteLine() + End Try + + 'Third test + Console.WriteLine("Float division by zero assigned to integer:") + blnExceptionThrown = False + Try + intTest = CInt(5 / intZero) + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + intTest.ToString) + End If + Console.WriteLine() + End Try + + 'Fourth test + Console.WriteLine("Float division by zero assigned to double:") + blnExceptionThrown = False + Try + dblTest = 5 / intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + dblTest.ToString) + Console.WriteLine("Is infinity: " + CStr(Double.IsInfinity(dblTest))) + Console.WriteLine("Is not a number: " + CStr(Double.IsNaN(dblTest))) + End If + Console.WriteLine() + End Try + + 'Fifth test + Console.WriteLine("Float division of zero by zero assigned to double:") + blnExceptionThrown = False + Try + dblTest = intZero / intZero + Catch objException As Exception + Console.WriteLine(objException.Message) + blnExceptionThrown = True + Finally + If blnExceptionThrown = True Then + Console.WriteLine("Result: not available") + Else + Console.WriteLine("No exception was thrown") + Console.WriteLine("Result: " + dblTest.ToString) + Console.WriteLine("Is infinity: " + CStr(Double.IsInfinity(dblTest))) + Console.WriteLine("Is not a number: " + CStr(Double.IsNaN(dblTest))) + End If + Console.WriteLine() + End Try + + Console.ReadLine() + + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-25/AssemblyInfo.vb new file mode 100644 index 0000000..84c17c4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-25/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.sln b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.sln new file mode 100644 index 0000000..efd663e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-25", "Listing2-25.vbproj", "{A67EAD24-F695-4109-A756-A2E90EAA7FC8}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Debug.ActiveCfg = Debug|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Debug.Build.0 = Debug|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Release.ActiveCfg = Release|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.sln.old new file mode 100644 index 0000000..82d6b70 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-25", "Listing2-25.vbproj", "{A67EAD24-F695-4109-A756-A2E90EAA7FC8}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Debug.ActiveCfg = Debug|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Debug.Build.0 = Debug|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Release.ActiveCfg = Release|.NET + {A67EAD24-F695-4109-A756-A2E90EAA7FC8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.suo b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.suo new file mode 100644 index 0000000..eb9fac3 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.vbproj new file mode 100644 index 0000000..2b9ad7e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-25/Listing2-25.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-25/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-25/Test.vb new file mode 100644 index 0000000..17f8202 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-25/Test.vb @@ -0,0 +1,19 @@ +Option Strict On + +Module Test + + Sub Main() + + Console.WriteLine(Single.NaN = Single.NaN) + Console.WriteLine((Single.NaN - Single.NaN) = 0) + + Console.WriteLine(Single.PositiveInfinity = Single.PositiveInfinity) + Console.WriteLine((Single.PositiveInfinity - Single.PositiveInfinity) = 0) + + Console.WriteLine(1.0 < Single.NaN) + Console.WriteLine(1.0 >= Single.NaN) + Console.ReadLine() + + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-26/AssemblyInfo.vb new file mode 100644 index 0000000..001c7ee --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-26/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.sln b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.sln new file mode 100644 index 0000000..944cb7e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-26", "Listing2-26.vbproj", "{DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Debug.ActiveCfg = Debug|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Debug.Build.0 = Debug|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Release.ActiveCfg = Release|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.sln.old new file mode 100644 index 0000000..d11ea21 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-26", "Listing2-26.vbproj", "{DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Debug.ActiveCfg = Debug|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Debug.Build.0 = Debug|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Release.ActiveCfg = Release|.NET + {DB29A1E1-1989-42D3-AA4E-E93FBB148C5A}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.suo b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.suo new file mode 100644 index 0000000..0a5954f Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.vbproj new file mode 100644 index 0000000..8c0e3b4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-26/Listing2-26.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-26/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-26/Test.vb new file mode 100644 index 0000000..cd14f55 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-26/Test.vb @@ -0,0 +1,33 @@ +Option Strict On + +Module Test + + Sub Main() + + Try + Console.WriteLine(CalcTotalOne(Single.NaN)) + Console.WriteLine(CalcTotalTwo(Single.NaN)) + Catch ex As Exception + Console.WriteLine(ex.Message) + Finally + Console.ReadLine() + End Try + + End Sub + + Function CalcTotalOne(ByVal PurchaseAmount As Single) As Single + If PurchaseAmount < 0.0 Then + Throw New ArgumentException("PurchaseAmount must be >= zero") + End If + Return PurchaseAmount * 1.08F + End Function + + Function CalcTotalTwo(ByVal PurchaseAmount As Single) As Single + If PurchaseAmount >= 0.0 Then + Return PurchaseAmount * 1.08F + Else + Throw New ArgumentException("PurchaseAmount must be >= zero") + End If + End Function + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-27/AssemblyInfo.vb new file mode 100644 index 0000000..8f8910b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-27/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.sln b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.sln new file mode 100644 index 0000000..85c80fa --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-27", "Listing2-27.vbproj", "{32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Debug.ActiveCfg = Debug|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Debug.Build.0 = Debug|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Release.ActiveCfg = Release|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.sln.old new file mode 100644 index 0000000..6c4f1e3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-27", "Listing2-27.vbproj", "{32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Debug.ActiveCfg = Debug|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Debug.Build.0 = Debug|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Release.ActiveCfg = Release|.NET + {32EAEC9E-0E5B-49F5-BF9E-B9793ED0406D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.suo b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.suo new file mode 100644 index 0000000..0753503 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.vbproj new file mode 100644 index 0000000..b4a3e1a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-27/Listing2-27.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-27/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-27/Test.vb new file mode 100644 index 0000000..97b4892 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-27/Test.vb @@ -0,0 +1,15 @@ +Option Strict On + +Module Test + + Sub Main() + + Dim X As Double, Y As Double + X = 10 ^ 18 + Y = X + 1 + Console.WriteLine("X = Y? " + (X = Y).ToString) + Console.ReadLine() + + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-28/AssemblyInfo.vb new file mode 100644 index 0000000..46393c4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-28/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.sln b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.sln new file mode 100644 index 0000000..81996f8 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-28", "Listing2-28.vbproj", "{B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Debug.ActiveCfg = Debug|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Debug.Build.0 = Debug|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Release.ActiveCfg = Release|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.sln.old new file mode 100644 index 0000000..873642b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-28", "Listing2-28.vbproj", "{B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Debug.ActiveCfg = Debug|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Debug.Build.0 = Debug|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Release.ActiveCfg = Release|.NET + {B3EE10CE-CD50-48E4-AFA3-77D21E7190CC}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.suo b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.suo new file mode 100644 index 0000000..d8f7668 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.vbproj new file mode 100644 index 0000000..d449033 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.vbproj.user new file mode 100644 index 0000000..29c78d4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-28/Listing2-28.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-28/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-28/Test.vb new file mode 100644 index 0000000..fbc67ae --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-28/Test.vb @@ -0,0 +1,12 @@ +Option Strict On + +Module Test + + Sub Main() + Dim X As Double = 2.45, Y As Double = 245 + X *= 100 + Console.WriteLine("X = Y? " + (X = Y).ToString) + Console.ReadLine() + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-3/AssemblyInfo.vb new file mode 100644 index 0000000..ecb4d27 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-3/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.sln b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.sln new file mode 100644 index 0000000..02469e2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-3", "Listing2-3.vbproj", "{E1D2974A-2952-4B9D-A767-0783A0FE75F8}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Debug.ActiveCfg = Debug|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Debug.Build.0 = Debug|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Release.ActiveCfg = Release|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.sln.old new file mode 100644 index 0000000..3c4cdcd --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-3", "Listing2-3.vbproj", "{E1D2974A-2952-4B9D-A767-0783A0FE75F8}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Debug.ActiveCfg = Debug|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Debug.Build.0 = Debug|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Release.ActiveCfg = Release|.NET + {E1D2974A-2952-4B9D-A767-0783A0FE75F8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.suo b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.suo new file mode 100644 index 0000000..7e9646b Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.vbproj new file mode 100644 index 0000000..3d77eb3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-3/Listing2-3.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-3/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-3/Test.vb new file mode 100644 index 0000000..e27213b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-3/Test.vb @@ -0,0 +1,35 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + Dim objDerived As New Derived() + Dim objTest As New MyTest() + objDerived.DoSomething(objTest) + Console.ReadLine() + End Sub + +End Class + +Class MyTest +End Class + +Class Base + + Public Overridable Sub DoSomething(ByVal NewValue As MyTest) + Console.WriteLine("Base:DoSomething(MyTest) called") + End Sub + +End Class + +Class Derived : Inherits Base + + Public Overloads Overrides Sub DoSomething(ByVal NewValue As MyTest) + Console.WriteLine("Derived:DoSomething(MyTest) called") + End Sub + + Public Overloads Sub DoSomething(ByVal NewValue As Object) + Console.WriteLine("Derived:DoSomething(Object) called") + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/App.ico b/Source/VisualStudio2003/Chapter02/Listing2-4/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-4/App.ico differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/AssemblyInfo.cs b/Source/VisualStudio2003/Chapter02/Listing2-4/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-4/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.csproj b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.csproj new file mode 100644 index 0000000..fdbb5c5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.csproj @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.csproj.user b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.csproj.user new file mode 100644 index 0000000..ab11334 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.sln b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.sln new file mode 100644 index 0000000..64dff39 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-4", "Listing2-4.csproj", "{19931BA2-7550-4959-A597-ECECD054B2C8}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {19931BA2-7550-4959-A597-ECECD054B2C8}.Debug.ActiveCfg = Debug|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Debug.Build.0 = Debug|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Release.ActiveCfg = Release|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.sln.old new file mode 100644 index 0000000..acd5370 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-4", "Listing2-4.csproj", "{19931BA2-7550-4959-A597-ECECD054B2C8}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {19931BA2-7550-4959-A597-ECECD054B2C8}.Debug.ActiveCfg = Debug|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Debug.Build.0 = Debug|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Release.ActiveCfg = Release|.NET + {19931BA2-7550-4959-A597-ECECD054B2C8}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.suo b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.suo new file mode 100644 index 0000000..c0c038e Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-4/Listing2-4.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/Test.cs b/Source/VisualStudio2003/Chapter02/Listing2-4/Test.cs new file mode 100644 index 0000000..6ed7d5b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-4/Test.cs @@ -0,0 +1,32 @@ +class Test +{ + public static void Main() + { + Derived objDerived = new Derived(); + MyTest objMyTest = new MyTest(); + objDerived.DoSomething(objMyTest); + System.Console.ReadLine(); + } +} + +class MyTest {} + +class Base +{ + public virtual void DoSomething(MyTest MyParameter) + { + System.Console.WriteLine("Base:DoSomething(MyTest) called"); + } +} + +class Derived : Base +{ + public override void DoSomething(MyTest MyParameter) + { + System.Console.WriteLine("Derived:DoSomething(MyTest) called"); + } + public void DoSomething(object MyParameter) + { + System.Console.WriteLine("Derived:DoSomething(Object) called"); + } +} diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/obj/Debug/Listing2-4.exe.incr b/Source/VisualStudio2003/Chapter02/Listing2-4/obj/Debug/Listing2-4.exe.incr new file mode 100644 index 0000000..d696965 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-4/obj/Debug/Listing2-4.exe.incr differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-4/obj/Debug/Listing2-4.projdata b/Source/VisualStudio2003/Chapter02/Listing2-4/obj/Debug/Listing2-4.projdata new file mode 100644 index 0000000..783878f Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-4/obj/Debug/Listing2-4.projdata differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-5/AssemblyInfo.vb new file mode 100644 index 0000000..a0c7309 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-5/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.sln b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.sln new file mode 100644 index 0000000..f89e5f1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-5", "Listing2-5.vbproj", "{8D6E435F-6608-4BEE-90FF-7B7CC145399E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Debug.ActiveCfg = Debug|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Debug.Build.0 = Debug|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Release.ActiveCfg = Release|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.sln.old new file mode 100644 index 0000000..4c8d15d --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-5", "Listing2-5.vbproj", "{8D6E435F-6608-4BEE-90FF-7B7CC145399E}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Debug.ActiveCfg = Debug|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Debug.Build.0 = Debug|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Release.ActiveCfg = Release|.NET + {8D6E435F-6608-4BEE-90FF-7B7CC145399E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.suo b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.suo new file mode 100644 index 0000000..2978f99 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.vbproj new file mode 100644 index 0000000..df80e10 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-5/Listing2-5.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-5/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-5/Test.vb new file mode 100644 index 0000000..c32567b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-5/Test.vb @@ -0,0 +1,33 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + Dim objDerived As New Derived() + objDerived.DoSomething(CLng(8)) + Console.ReadLine() + End Sub + +End Class + +Class Base + + Public Overridable Sub DoSomething(ByVal NewValue As Long) + Console.WriteLine("Base:DoSomething(Long) called") + End Sub + + Public Sub DoSomething(ByVal NewValue As Double) + Console.WriteLine("Base:DoSomething(Double) called") + End Sub +End Class + +Class Derived : Inherits Base + + Public Overloads Overrides Sub DoSomething(ByVal NewValue As Long) + Console.WriteLine("Derived:DoSomething(Long) called") + End Sub + + Public Overloads Sub DoSomething(ByVal NewValue As Integer) + Console.WriteLine("Derived:DoSomething(Integer) called") + End Sub +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/App.ico b/Source/VisualStudio2003/Chapter02/Listing2-6/App.ico new file mode 100644 index 0000000..3a5525f Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-6/App.ico differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/AssemblyInfo.cs b/Source/VisualStudio2003/Chapter02/Listing2-6/AssemblyInfo.cs new file mode 100644 index 0000000..9f89a32 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-6/AssemblyInfo.cs @@ -0,0 +1,58 @@ +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.csproj b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.csproj new file mode 100644 index 0000000..a1240c2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.csproj @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.csproj.user b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.csproj.user new file mode 100644 index 0000000..9b3833b --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.csproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.sln b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.sln new file mode 100644 index 0000000..2542b54 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-6", "Listing2-6.csproj", "{3A2336E2-DF01-47F4-97DC-F20E39391250}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Debug.ActiveCfg = Debug|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Debug.Build.0 = Debug|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Release.ActiveCfg = Release|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.sln.old new file mode 100644 index 0000000..41c076e --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Listing2-6", "Listing2-6.csproj", "{3A2336E2-DF01-47F4-97DC-F20E39391250}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Debug.ActiveCfg = Debug|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Debug.Build.0 = Debug|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Release.ActiveCfg = Release|.NET + {3A2336E2-DF01-47F4-97DC-F20E39391250}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.suo b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.suo new file mode 100644 index 0000000..1528f3c Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-6/Listing2-6.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/Test.cs b/Source/VisualStudio2003/Chapter02/Listing2-6/Test.cs new file mode 100644 index 0000000..f07f788 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-6/Test.cs @@ -0,0 +1,35 @@ +class Test +{ + public static void Main() + { + Derived objDerived = new Derived(); + objDerived.DoSomething((long) 8); + System.Console.ReadLine(); + } +} + +class Base +{ + public virtual void DoSomething(long NewValue) + { + System.Console.WriteLine("Base:DoSomething(Long) called"); + } + + public void DoSomething(double NewValue) + { + System.Console.WriteLine("Base:DoSomething(Double) called"); + } +} + +class Derived : Base +{ + override public void DoSomething(long NewValue) + { + System.Console.WriteLine("Derived:DoSomething(long) called"); + } + + public void DoSomething(int NewValue) + { + System.Console.WriteLine("Derived:DoSomething(Integer) called"); + } +} diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/obj/Debug/Listing2-6.exe.incr b/Source/VisualStudio2003/Chapter02/Listing2-6/obj/Debug/Listing2-6.exe.incr new file mode 100644 index 0000000..145ffd4 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-6/obj/Debug/Listing2-6.exe.incr differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-6/obj/Debug/Listing2-6.projdata b/Source/VisualStudio2003/Chapter02/Listing2-6/obj/Debug/Listing2-6.projdata new file mode 100644 index 0000000..70f66d2 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-6/obj/Debug/Listing2-6.projdata differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-7/AssemblyInfo.vb new file mode 100644 index 0000000..78700b2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-7/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.sln b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.sln new file mode 100644 index 0000000..0da20ad --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-7", "Listing2-7.vbproj", "{D582898F-DD17-42D9-A004-E22CF2E2CEB2}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Debug.ActiveCfg = Debug|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Debug.Build.0 = Debug|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Release.ActiveCfg = Release|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.sln.old new file mode 100644 index 0000000..1a557d4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-7", "Listing2-7.vbproj", "{D582898F-DD17-42D9-A004-E22CF2E2CEB2}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Debug.ActiveCfg = Debug|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Debug.Build.0 = Debug|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Release.ActiveCfg = Release|.NET + {D582898F-DD17-42D9-A004-E22CF2E2CEB2}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.suo b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.suo new file mode 100644 index 0000000..50be109 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.vbproj new file mode 100644 index 0000000..34a09f1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-7/Listing2-7.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-7/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-7/Test.vb new file mode 100644 index 0000000..b625010 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-7/Test.vb @@ -0,0 +1,14 @@ +Option Strict On + +Class Base + Overridable Sub DoSomething() + 'The method definition goes here + End Sub +End Class + +Class Derived : Inherits Base + Sub DoSomething() + 'This method will actually shadow its base method rather than Override it, + 'because the developer forgot to add the Overrides keyword + End Sub +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-8/AssemblyInfo.vb new file mode 100644 index 0000000..5b7ce5a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.sln b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.sln new file mode 100644 index 0000000..fb22fdd --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-8", "Listing2-8.vbproj", "{56218072-CB2B-49E2-B000-3180711BBC10}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {56218072-CB2B-49E2-B000-3180711BBC10}.Debug.ActiveCfg = Debug|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Debug.Build.0 = Debug|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Release.ActiveCfg = Release|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.sln.old new file mode 100644 index 0000000..95b3330 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-8", "Listing2-8.vbproj", "{56218072-CB2B-49E2-B000-3180711BBC10}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {56218072-CB2B-49E2-B000-3180711BBC10}.Debug.ActiveCfg = Debug|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Debug.Build.0 = Debug|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Release.ActiveCfg = Release|.NET + {56218072-CB2B-49E2-B000-3180711BBC10}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.suo b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.suo new file mode 100644 index 0000000..b8e113e Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.vbproj new file mode 100644 index 0000000..9ae4887 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8/Listing2-8.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-8/Test.vb new file mode 100644 index 0000000..234fa28 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8/Test.vb @@ -0,0 +1,59 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Overrides Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/AssemblyInfo.vb new file mode 100644 index 0000000..58b4bee --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln new file mode 100644 index 0000000..c740a60 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-8Shadows", "Listing2-8Shadows.vbproj", "{BB663C40-7108-4457-8984-E194358B1817}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB663C40-7108-4457-8984-E194358B1817}.Debug.ActiveCfg = Debug|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Debug.Build.0 = Debug|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Release.ActiveCfg = Release|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln.old new file mode 100644 index 0000000..86cfd7a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-8Shadows", "Listing2-8Shadows.vbproj", "{BB663C40-7108-4457-8984-E194358B1817}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB663C40-7108-4457-8984-E194358B1817}.Debug.ActiveCfg = Debug|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Debug.Build.0 = Debug|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Release.ActiveCfg = Release|.NET + {BB663C40-7108-4457-8984-E194358B1817}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.suo b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.suo new file mode 100644 index 0000000..8a350b8 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj new file mode 100644 index 0000000..1a0029f --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Listing2-8Shadows.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Test.vb new file mode 100644 index 0000000..24757cc --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-8Shadows/Test.vb @@ -0,0 +1,59 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Shadows Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter02/Listing2-9/AssemblyInfo.vb new file mode 100644 index 0000000..73c3d1a --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-9/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.sln b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.sln new file mode 100644 index 0000000..ee52917 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-9", "Listing2-9.vbproj", "{BDC11796-30AC-4600-9B6C-7446DD16279D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Debug.ActiveCfg = Debug|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Debug.Build.0 = Debug|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Release.ActiveCfg = Release|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.sln.old b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.sln.old new file mode 100644 index 0000000..35d2b2d --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Listing2-9", "Listing2-9.vbproj", "{BDC11796-30AC-4600-9B6C-7446DD16279D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Debug.ActiveCfg = Debug|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Debug.Build.0 = Debug|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Release.ActiveCfg = Release|.NET + {BDC11796-30AC-4600-9B6C-7446DD16279D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.suo b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.suo new file mode 100644 index 0000000..f7c2d26 Binary files /dev/null and b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.suo differ diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.vbproj b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.vbproj new file mode 100644 index 0000000..eb36b49 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.vbproj.user b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-9/Listing2-9.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter02/Listing2-9/Test.vb b/Source/VisualStudio2003/Chapter02/Listing2-9/Test.vb new file mode 100644 index 0000000..a0489ac --- /dev/null +++ b/Source/VisualStudio2003/Chapter02/Listing2-9/Test.vb @@ -0,0 +1,66 @@ +Option Strict On + +Module CatTester + + Sub Main() + + 'NormalCat + Dim objNormalCat As New Cat() + With objNormalCat + Console.WriteLine("NormalCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine() + End With + + 'LameCat + Dim objLameCat As New LameCat() + With objLameCat + Console.WriteLine("LameCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + 'UglyCat + Dim objUglyCat As New Cat() + objUglyCat = New LameCat() + With objUglyCat + Console.WriteLine("UglyCat is a " + .GetType.Name) + Console.WriteLine("It has " + .Legs.ToString + " legs and " + .Feet.ToString + " feet") + Console.WriteLine("Equal of a cat? " + .Equals(New Cat()).ToString) + Console.WriteLine() + End With + + Console.ReadLine() + End Sub + +End Module + +Class Cat + + Overridable Function Feet() As Int16 + Return 4 + End Function + + Overridable Function Legs() As Int16 + Return Me.Feet + End Function + +End Class + +Class LameCat : Inherits Cat + + Overrides Function Feet() As Int16 + Return 3 + End Function + + Overrides Function Legs() As Int16 + Return Me.Feet + End Function + + 'This overload doesn't work for a subtle reason + Overloads Function Equals(ByVal AnyCat As Cat) As Boolean + Return True + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter04/SortingSpeed/AssemblyInfo.vb new file mode 100644 index 0000000..e68a407 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.sln b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.sln new file mode 100644 index 0000000..0992622 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.sln @@ -0,0 +1,35 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoLogic", "SortingDll\DebugDemoLogic.vbproj", "{057FA2D6-5280-4393-BE33-C6631BA07451}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoForm", "DebugDemoForm.vbproj", "{1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}" + ProjectSection(ProjectDependencies) = postProject + {057FA2D6-5280-4393-BE33-C6631BA07451} = {057FA2D6-5280-4393-BE33-C6631BA07451} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + ReleaseCustom = ReleaseCustom + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.ActiveCfg = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.Build.0 = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.ActiveCfg = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.Build.0 = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.ActiveCfg = ReleaseCustom|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.Build.0 = ReleaseCustom|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.ActiveCfg = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.Build.0 = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.Build.0 = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.sln.old b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.sln.old new file mode 100644 index 0000000..b71c4dc --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.sln.old @@ -0,0 +1,33 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoLogic", "SortingDll\DebugDemoLogic.vbproj", "{057FA2D6-5280-4393-BE33-C6631BA07451}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoForm", "DebugDemoForm.vbproj", "{1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + ConfigName.2 = ReleaseCustom + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.0 = {057FA2D6-5280-4393-BE33-C6631BA07451} + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.ActiveCfg = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.Build.0 = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.ActiveCfg = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.Build.0 = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.ActiveCfg = ReleaseCustom|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.Build.0 = ReleaseCustom|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.ActiveCfg = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.Build.0 = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.Build.0 = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.suo b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.suo new file mode 100644 index 0000000..bc0825d Binary files /dev/null and b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemo.suo differ diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemoForm.vbproj b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemoForm.vbproj new file mode 100644 index 0000000..fda6517 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemoForm.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemoForm.vbproj.user b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemoForm.vbproj.user new file mode 100644 index 0000000..6f2ca04 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/DebugDemoForm.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DemoForm.resx b/Source/VisualStudio2003/Chapter04/SortingSpeed/DemoForm.resx new file mode 100644 index 0000000..363456d --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/DemoForm.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + Assembly + + + True + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + DebugDemo + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/DemoForm.vb b/Source/VisualStudio2003/Chapter04/SortingSpeed/DemoForm.vb new file mode 100644 index 0000000..cf4ee1a --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/DemoForm.vb @@ -0,0 +1,207 @@ +Public Class DebugDemo + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents lblTwo As System.Windows.Forms.Label + Friend WithEvents lblOne As System.Windows.Forms.Label + Friend WithEvents boxSort As System.Windows.Forms.GroupBox + Friend WithEvents Timing As System.Windows.Forms.Label + Friend WithEvents StartSort As System.Windows.Forms.Button + Friend WithEvents MaxValue As System.Windows.Forms.TextBox + Friend WithEvents NumberItems As System.Windows.Forms.TextBox + Friend WithEvents SortCounting As System.Windows.Forms.RadioButton + Friend WithEvents SortQuick As System.Windows.Forms.RadioButton + Friend WithEvents SortSelection As System.Windows.Forms.RadioButton + Friend WithEvents SortBubble As System.Windows.Forms.RadioButton + Private Sub InitializeComponent() + Me.lblTwo = New System.Windows.Forms.Label() + Me.lblOne = New System.Windows.Forms.Label() + Me.StartSort = New System.Windows.Forms.Button() + Me.MaxValue = New System.Windows.Forms.TextBox() + Me.NumberItems = New System.Windows.Forms.TextBox() + Me.boxSort = New System.Windows.Forms.GroupBox() + Me.SortCounting = New System.Windows.Forms.RadioButton() + Me.SortQuick = New System.Windows.Forms.RadioButton() + Me.SortSelection = New System.Windows.Forms.RadioButton() + Me.SortBubble = New System.Windows.Forms.RadioButton() + Me.Timing = New System.Windows.Forms.Label() + Me.boxSort.SuspendLayout() + Me.SuspendLayout() + ' + 'lblTwo + ' + Me.lblTwo.Location = New System.Drawing.Point(32, 96) + Me.lblTwo.Name = "lblTwo" + Me.lblTwo.Size = New System.Drawing.Size(112, 30) + Me.lblTwo.TabIndex = 14 + Me.lblTwo.Text = "Max item value" + ' + 'lblOne + ' + Me.lblOne.Location = New System.Drawing.Point(32, 40) + Me.lblOne.Name = "lblOne" + Me.lblOne.Size = New System.Drawing.Size(112, 30) + Me.lblOne.TabIndex = 12 + Me.lblOne.Text = "Number of items" + ' + 'StartSort + ' + Me.StartSort.Location = New System.Drawing.Point(280, 285) + Me.StartSort.Name = "StartSort" + Me.StartSort.Size = New System.Drawing.Size(92, 39) + Me.StartSort.TabIndex = 10 + Me.StartSort.Text = "Start sort" + ' + 'MaxValue + ' + Me.MaxValue.Location = New System.Drawing.Point(160, 96) + Me.MaxValue.Name = "MaxValue" + Me.MaxValue.Size = New System.Drawing.Size(72, 22) + Me.MaxValue.TabIndex = 13 + Me.MaxValue.Text = "10000" + ' + 'NumberItems + ' + Me.NumberItems.Location = New System.Drawing.Point(160, 40) + Me.NumberItems.Name = "NumberItems" + Me.NumberItems.Size = New System.Drawing.Size(72, 22) + Me.NumberItems.TabIndex = 11 + Me.NumberItems.Text = "1000" + ' + 'boxSort + ' + Me.boxSort.Controls.AddRange(New System.Windows.Forms.Control() {Me.SortCounting, Me.SortQuick, Me.SortSelection, Me.SortBubble}) + Me.boxSort.Location = New System.Drawing.Point(280, 16) + Me.boxSort.Name = "boxSort" + Me.boxSort.Size = New System.Drawing.Size(232, 247) + Me.boxSort.TabIndex = 9 + Me.boxSort.TabStop = False + Me.boxSort.Text = "Sort algorithm" + ' + 'SortCounting + ' + Me.SortCounting.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortCounting.Location = New System.Drawing.Point(41, 178) + Me.SortCounting.Name = "SortCounting" + Me.SortCounting.Size = New System.Drawing.Size(164, 29) + Me.SortCounting.TabIndex = 3 + Me.SortCounting.Text = "Counting sort" + ' + 'SortQuick + ' + Me.SortQuick.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortQuick.Location = New System.Drawing.Point(41, 128) + Me.SortQuick.Name = "SortQuick" + Me.SortQuick.Size = New System.Drawing.Size(164, 30) + Me.SortQuick.TabIndex = 2 + Me.SortQuick.Text = "Quick sort" + ' + 'SortSelection + ' + Me.SortSelection.Location = New System.Drawing.Point(41, 79) + Me.SortSelection.Name = "SortSelection" + Me.SortSelection.Size = New System.Drawing.Size(164, 30) + Me.SortSelection.TabIndex = 1 + Me.SortSelection.Text = "Selection sort" + ' + 'SortBubble + ' + Me.SortBubble.Checked = True + Me.SortBubble.Location = New System.Drawing.Point(41, 30) + Me.SortBubble.Name = "SortBubble" + Me.SortBubble.Size = New System.Drawing.Size(164, 29) + Me.SortBubble.TabIndex = 0 + Me.SortBubble.TabStop = True + Me.SortBubble.Text = "Bubble sort" + ' + 'Timing + ' + Me.Timing.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.Timing.Location = New System.Drawing.Point(400, 288) + Me.Timing.Name = "Timing" + Me.Timing.Size = New System.Drawing.Size(112, 32) + Me.Timing.TabIndex = 15 + ' + 'DebugDemo + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(544, 348) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Timing, Me.lblTwo, Me.lblOne, Me.StartSort, Me.MaxValue, Me.NumberItems, Me.boxSort}) + Me.Name = "DebugDemo" + Me.Text = "Debug demo" + Me.boxSort.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private m_SortType As DemoSort.SortType = DemoSort.SortType.BubbleSort + + Private Sub StartSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartSort.Click + Dim SortObject As New DemoSort() + + 'Show that we're busy + Cursor.Current = Cursors.WaitCursor + Me.StartSort.Enabled = False + + 'Build a list to sort + Me.Timing.Text = "Building list to sort..." + Me.Timing.Refresh() + SortObject.ListBuild(Convert.ToInt32(Me.NumberItems.Text), 1, Convert.ToInt32(Me.MaxValue.Text)) + + 'Do the sort and report timing + Me.Timing.Text = "Performing sort..." + Me.Timing.Refresh() + Me.Timing.Text = SortObject.DoSort(m_SortType).ToString & " seconds" + + 'Show that we've finished + Me.StartSort.Enabled = True + Cursor.Current = Cursors.Default + + End Sub + + Private Sub SortBubble_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortBubble.CheckedChanged + m_SortType = DemoSort.SortType.BubbleSort + End Sub + + Private Sub SortSelection_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortSelection.CheckedChanged + m_SortType = DemoSort.SortType.SelectionSort + End Sub + + Private Sub SortQuick_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortQuick.CheckedChanged + m_SortType = DemoSort.SortType.QuickSort + End Sub + + Private Sub SortCounting_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortCounting.CheckedChanged + m_SortType = DemoSort.SortType.CountingSort + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/AssemblyInfo.vb new file mode 100644 index 0000000..240f036 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/AssemblyInfo.vb @@ -0,0 +1,30 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj new file mode 100644 index 0000000..b9cbd77 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj.user b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj.user new file mode 100644 index 0000000..d7b0259 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DebugDemoLogic.vbproj.user @@ -0,0 +1,64 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DemoSort.vb b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DemoSort.vb new file mode 100644 index 0000000..13cc2f8 --- /dev/null +++ b/Source/VisualStudio2003/Chapter04/SortingSpeed/SortingDll/DemoSort.vb @@ -0,0 +1,265 @@ +Option Strict On + +Public Class DemoSort + + 'These are the sorting lists + Private ListUnsorted() As Int32 + Private ListBeingSorted() As Int32 + 'These are max and minimum sort settings + Private ListLengthMin As Int32 + Private ListLengthMax As Int32 + Private ListValueMin As Int32 + Private ListValueMax As Int32 + + Public Enum SortType As Integer + BubbleSort = 1 + SelectionSort = 2 + QuickSort = 3 + CountingSort = 4 + End Enum + + Public Sub ListBuild(ByVal ListLength As Int32, ByVal ValueMin As Int32, ByVal ValueMax As Int32) + Dim ArrayItem As Int32, objRandom As New System.Random(1) + + 'If parameters haven't changed, just use previous list + 'This enables multiple timing checks on an identical array + If ListLength = ListLengthMax And ValueMin = ListValueMin And ValueMax = ListValueMax Then + Exit Sub + End If + + 'Build a new list with given parameters + ReDim ListUnsorted(ListLength) + For ArrayItem = 1 To ListLength + ListUnsorted(ArrayItem) = objRandom.Next(ValueMin, ValueMax) + Next ArrayItem + + 'Set length of sorted list to match + ReDim ListBeingSorted(ListLength) + + 'Store min and max list items and values + ListLengthMin = 1 + ListLengthMax = ListLength + ListValueMin = ValueMin + ListValueMax = ValueMax + + End Sub + + Public Function DoSort(ByVal Sort As SortType) As Double + Dim TimeStart As Int32, TimeFinish As Int32, ArrayItem As Int32 + + 'Copy to array that will contain newly-sorted list + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ArrayItem) = ListUnsorted(ArrayItem) + Next + + 'Start the clock so we can report how long the sorting took + TimeStart = System.Environment.TickCount() + + 'Do the sort + Select Case Sort + Case SortType.BubbleSort + SortBubble(ListLengthMin, ListLengthMax) + Case SortType.QuickSort + SortQuick(ListLengthMin, ListLengthMax) + Case SortType.SelectionSort + SortSelection() + Case SortType.CountingSort + SortCounting() + Case Else + Trace.Fail(CStr(Sort) & " is an invalid sort type") + End Select + + 'Stop the clock and report how long the sorting took + TimeFinish = System.Environment.TickCount() + 'Check sort + SortCheck() + 'Convert elapsed time into seconds + Return (TimeFinish - TimeStart) / 1000 + + End Function + + Private Sub SortBubble(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim intLastSwap As Int32, intLoop1 As Int32, intLoop2 As Int32 + Dim intDrop As Int32 + + 'Repeat until we are done + Do While ItemLow < ItemHigh + + 'First bubble upwards + intLastSwap = ItemLow - 1 + intLoop1 = ItemLow + 1 + + Do While intLoop1 <= ItemHigh + 'Find a bubble + If ListBeingSorted(intLoop1 - 1) > ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 - 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) < intDrop + ListBeingSorted(intLoop2 - 1) = ListBeingSorted(intLoop2) + intLoop2 += 1 + If intLoop2 > ItemHigh Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 - 1) = intDrop + intLastSwap = intLoop2 - 1 + intLoop1 = intLoop2 + 1 + Else + intLoop1 += 1 + End If + Loop + + 'Update maximum value + ItemHigh = intLastSwap - 1 + + 'Next bubble downwards + intLastSwap = ItemHigh + 1 + intLoop1 = ItemHigh - 1 + + Do While intLoop1 >= ItemLow + 'Find a bubble + If ListBeingSorted(intLoop1 + 1) < ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 + 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) > intDrop + ListBeingSorted(intLoop2 + 1) = ListBeingSorted(intLoop2) + intLoop2 -= 1 + If intLoop2 < ItemLow Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 + 1) = intDrop + intLastSwap = intLoop2 + 1 + intLoop1 = intLoop2 - 1 + Else + intLoop1 -= 1 + End If + Loop + + 'Update minimum value + ItemLow = intLastSwap + 1 + + Loop + + End Sub + + Private Sub SortSelection() + Dim LoopOuter As Int32, LoopInner As Int32, BestValue As Int32, BestInnerIndex As Int32 + + For LoopOuter = ListLengthMin To ListLengthMax - 1 + + 'Init lowest-value search + BestValue = ListBeingSorted(LoopOuter) + BestInnerIndex = LoopOuter + + 'Find lowest value that hasn't already been sorted + For LoopInner = LoopOuter + 1 To ListLengthMax + If ListBeingSorted(LoopInner) < BestValue Then + BestValue = ListBeingSorted(LoopInner) + BestInnerIndex = LoopInner + End If + Next LoopInner + + 'Swap lowest value into proper position + ListBeingSorted(BestInnerIndex) = ListBeingSorted(LoopOuter) + ListBeingSorted(LoopOuter) = BestValue + + Next LoopOuter + + End Sub + + Private Sub SortQuick(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim IntermediateValue As Int32, Position As Int32 + Dim objRandom As New System.Random() + Dim intLow As Int32, intHigh As Int32 + + 'If the list has only 1 element, it's already sorted + If ItemLow >= ItemHigh Then Exit Sub + + 'Pick a dividing item + Position = objRandom.Next(ItemLow, ItemHigh) + IntermediateValue = ListBeingSorted(Position) + + 'Swap it to the front so we can find it easily + ListBeingSorted(Position) = ListBeingSorted(ItemLow) + + 'Move the items smaller than this into the left + 'half of the list. Move the others into the right. + intLow = ItemLow + intHigh = ItemHigh + Do + 'Look down from low item for a value < IntermediateValue + Do While ListBeingSorted(intHigh) >= IntermediateValue + intHigh -= 1 + If intHigh <= intLow Then Exit Do + Loop + If intHigh <= intLow Then + ListBeingSorted(intLow) = IntermediateValue + Exit Do + End If + + 'Swap the low and high values + ListBeingSorted(intLow) = ListBeingSorted(intHigh) + + 'Look up from ItemLow for a value >= IntermediateValue + intLow += 1 + Do While ListBeingSorted(intLow) < IntermediateValue + intLow += 1 + If intLow >= intHigh Then Exit Do + Loop + If intLow >= intHigh Then + intLow = intHigh + ListBeingSorted(intHigh) = IntermediateValue + Exit Do + End If + + 'Swap the low and high items + ListBeingSorted(intHigh) = ListBeingSorted(intLow) + Loop + + 'Sort the two sublists recursively + SortQuick(ItemLow, intLow - 1) + SortQuick(intHigh + 1, ItemHigh) + + End Sub + + Private Sub SortCounting() + Dim ListCounts(ListValueMax) As Int32 + Dim ArrayItem As Int32, ThisCount As Int32, NextOffset As Int32 + + 'Count the items + For ArrayItem = ListLengthMin To ListLengthMax + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + 'Convert the ListCounts into offsets + NextOffset = ListLengthMin + For ArrayItem = ListValueMin To ListValueMax + ThisCount = ListCounts(ArrayItem) + ListCounts(ArrayItem) = NextOffset + NextOffset += ThisCount + Next ArrayItem + + 'Place the items in the sorted array + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ListCounts(ListUnsorted(ArrayItem))) = ListUnsorted(ArrayItem) + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + End Sub + + Private Function SortCheck() As Boolean + Dim ArrayItem As Int32 + + For ArrayItem = 2 To ListLengthMax + If ListBeingSorted(ArrayItem - 1) > ListBeingSorted(ArrayItem) Then + Trace.Fail("Item " & (ArrayItem - 1).ToString & " is larger than item " & ArrayItem.ToString) + Exit For + End If + Next ArrayItem + + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter04/SortingSpeed/obj/Debug/DebugDemo.DebugDemo.resources b/Source/VisualStudio2003/Chapter04/SortingSpeed/obj/Debug/DebugDemo.DebugDemo.resources new file mode 100644 index 0000000..24379ba Binary files /dev/null and b/Source/VisualStudio2003/Chapter04/SortingSpeed/obj/Debug/DebugDemo.DebugDemo.resources differ diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter05/ErrorHandling/AssemblyInfo.vb new file mode 100644 index 0000000..1ab76fe --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/ErrorHandling/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.sln b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.sln new file mode 100644 index 0000000..4a73ea3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ErrorHandling", "ErrorHandling.vbproj", "{20437FF3-C011-4EBB-B7E5-3E4313ED2279}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Debug.ActiveCfg = Debug|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Debug.Build.0 = Debug|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Release.ActiveCfg = Release|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.sln.old b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.sln.old new file mode 100644 index 0000000..8c51823 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ErrorHandling", "ErrorHandling.vbproj", "{20437FF3-C011-4EBB-B7E5-3E4313ED2279}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Debug.ActiveCfg = Debug|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Debug.Build.0 = Debug|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Release.ActiveCfg = Release|.NET + {20437FF3-C011-4EBB-B7E5-3E4313ED2279}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.suo b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.suo new file mode 100644 index 0000000..1614306 Binary files /dev/null and b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.suo differ diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.vbproj b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.vbproj new file mode 100644 index 0000000..ced4eb5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.vbproj.user b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorHandling.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorTest.vb b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorTest.vb new file mode 100644 index 0000000..6d67bed --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/ErrorHandling/ErrorTest.vb @@ -0,0 +1,41 @@ +Option Strict On +Imports System.Data.SqlClient + +Module ErrorTest + + Sub Main() + Dim strConnection As String + 'Set up database connection + strConnection = "Initial Catalog = Northwind;" + strConnection += "Data Source = CHEETAH;" + strConnection += "Integrated Security = SSPI" + 'Try old and new error-handling functions + MethodOld(strConnection) + MethodNew(strConnection) + End Sub + + Function MethodOld(ByVal ConnectString As String) As Boolean + Dim objSqlConnect As SqlConnection + 'Test database connection with old error handling + On Error Resume Next + objSqlConnect = New SqlConnection(ConnectString) + MethodOld = CBool(Err.Number = 0) + objSqlConnect.Close() + objSqlConnect.Dispose() + End Function + + Function MethodNew(ByVal ConnectString As String) As Boolean + Dim objSqlConnect As SqlConnection + 'Test database connection with new error handling + Try + objSqlConnect = New SqlConnection(ConnectString) + objSqlConnect.Close() + objSqlConnect.Dispose() + Return True + Catch + Return False + Finally + End Try + End Function + +End Module diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter05/HelloWorld/AssemblyInfo.vb new file mode 100644 index 0000000..bdcac6c --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/HelloWorld/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.sln b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.sln new file mode 100644 index 0000000..72fecac --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HelloWorld", "HelloWorld.vbproj", "{B17D4890-3D55-4530-9BAB-331E9F4DB432}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Debug.ActiveCfg = Debug|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Debug.Build.0 = Debug|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Release.ActiveCfg = Release|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.sln.old b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.sln.old new file mode 100644 index 0000000..1fad0c7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HelloWorld", "HelloWorld.vbproj", "{B17D4890-3D55-4530-9BAB-331E9F4DB432}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Debug.ActiveCfg = Debug|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Debug.Build.0 = Debug|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Release.ActiveCfg = Release|.NET + {B17D4890-3D55-4530-9BAB-331E9F4DB432}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.suo b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.suo new file mode 100644 index 0000000..ab361fc Binary files /dev/null and b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.suo differ diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vb b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vb new file mode 100644 index 0000000..c1e98de --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vb @@ -0,0 +1,9 @@ +Module HelloWorld + + Sub Main() + + System.Console.WriteLine("Hello VB.Net world") + + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vbproj b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vbproj new file mode 100644 index 0000000..82445fd --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vbproj.user b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/HelloWorld/HelloWorld.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/AssemblyInfo.vb new file mode 100644 index 0000000..b81bc27 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.sln b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.sln new file mode 100644 index 0000000..04e62dd --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringPerfTestOne", "StringPerfTestOne.vbproj", "{8454C1C9-B876-4ACF-8562-02C70E18505E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.ActiveCfg = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.Build.0 = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.ActiveCfg = Release|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.sln.old b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.sln.old new file mode 100644 index 0000000..0429d40 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringPerfTestOne", "StringPerfTestOne.vbproj", "{8454C1C9-B876-4ACF-8562-02C70E18505E}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.ActiveCfg = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.Build.0 = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.ActiveCfg = Release|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.suo b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.suo new file mode 100644 index 0000000..058d266 Binary files /dev/null and b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.suo differ diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj new file mode 100644 index 0000000..0c0fd7d --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj.user b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/StringPerfTestOne.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestOne/Test.vb b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/Test.vb new file mode 100644 index 0000000..aafbbb1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestOne/Test.vb @@ -0,0 +1,15 @@ +Option Strict On + +Module StringPerfTestOne + + Sub Main() + Dim strTest As String = "Coming up: ", intTest As Integer = 0 + System.Console.WriteLine("Starting...") + For intTest = 1 To 20000 + strTest += "another test " + Next + System.Console.WriteLine("Finished") + System.Console.ReadLine() + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/AssemblyInfo.vb new file mode 100644 index 0000000..b81bc27 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln new file mode 100644 index 0000000..e6c7833 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringPerfTestTwo", "StringPerfTestTwo.vbproj", "{8454C1C9-B876-4ACF-8562-02C70E18505E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.ActiveCfg = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.Build.0 = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.ActiveCfg = Release|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln.old b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln.old new file mode 100644 index 0000000..8a00ffe --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "StringPerfTestTwo", "StringPerfTestTwo.vbproj", "{8454C1C9-B876-4ACF-8562-02C70E18505E}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.ActiveCfg = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Debug.Build.0 = Debug|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.ActiveCfg = Release|.NET + {8454C1C9-B876-4ACF-8562-02C70E18505E}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.suo b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.suo new file mode 100644 index 0000000..69979c9 Binary files /dev/null and b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.suo differ diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj new file mode 100644 index 0000000..0c0fd7d --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj.user b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/StringPerfTestTwo.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/Test.vb b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/Test.vb new file mode 100644 index 0000000..19a18e8 --- /dev/null +++ b/Source/VisualStudio2003/Chapter05/StringPerfTestTwo/Test.vb @@ -0,0 +1,16 @@ +Option Strict On + +Module StringPerfTestTwo + + Sub Main() + Dim sbTest As New System.Text.StringBuilder("Coming up: ") + Dim intTest As Integer = 0 + System.Console.WriteLine("Starting...") + For intTest = 1 To 20000 + sbTest.Append("another test ") + Next + System.Console.WriteLine("Finished") + System.Console.ReadLine() + End Sub + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/AssemblyInfo.vb new file mode 100644 index 0000000..c42de65 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln new file mode 100644 index 0000000..b6493f9 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BooleanSwitchTest", "BooleanSwitchTest.vbproj", "{74999BA0-648F-4433-B23B-66CD0A996617}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {74999BA0-648F-4433-B23B-66CD0A996617}.Debug.ActiveCfg = Debug|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Debug.Build.0 = Debug|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Release.ActiveCfg = Release|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln.old b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln.old new file mode 100644 index 0000000..2e701cf --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BooleanSwitchTest", "BooleanSwitchTest.vbproj", "{74999BA0-648F-4433-B23B-66CD0A996617}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {74999BA0-648F-4433-B23B-66CD0A996617}.Debug.ActiveCfg = Debug|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Debug.Build.0 = Debug|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Release.ActiveCfg = Release|.NET + {74999BA0-648F-4433-B23B-66CD0A996617}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.suo b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.suo new file mode 100644 index 0000000..2431c6e Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.suo differ diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj new file mode 100644 index 0000000..99c4fbe --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj.user b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/BooleanSwitchTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/Test.vb b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/Test.vb new file mode 100644 index 0000000..2a785a3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/BooleanSwitchTest/Test.vb @@ -0,0 +1,25 @@ +Option Strict On + +Module Test + + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + Private bswTraceOutput As New Diagnostics.BooleanSwitch("MyAppTracing", "Test BooleanSwitch") + + Public Sub Main() + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + bswTraceOutput.Enabled = True + Test() + End Sub + + Public Sub Test() + 'Show whether the BooleanSwitch is enabled or disabled + If bswTraceOutput.Enabled Then + Trace.WriteLine(bswTraceOutput.DisplayName & " is enabled") + Else + Trace.WriteLine(bswTraceOutput.DisplayName & " is disabled") + End If + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/AssemblyInfo.vb new file mode 100644 index 0000000..17cf2fd --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.sln b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.sln new file mode 100644 index 0000000..52bba7d --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomSwitchTest", "CustomSwitchTest.vbproj", "{02FBDF20-1D73-429D-928A-15C519BAD91D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Debug.ActiveCfg = Debug|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Debug.Build.0 = Debug|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Release.ActiveCfg = Release|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.sln.old b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.sln.old new file mode 100644 index 0000000..a26faad --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomSwitchTest", "CustomSwitchTest.vbproj", "{02FBDF20-1D73-429D-928A-15C519BAD91D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Debug.ActiveCfg = Debug|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Debug.Build.0 = Debug|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Release.ActiveCfg = Release|.NET + {02FBDF20-1D73-429D-928A-15C519BAD91D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.suo b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.suo new file mode 100644 index 0000000..7e18635 Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.suo differ diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj new file mode 100644 index 0000000..712c958 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj.user b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/CustomSwitchTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/CustomSwitchTest/Test.vb b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/Test.vb new file mode 100644 index 0000000..b265118 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomSwitchTest/Test.vb @@ -0,0 +1,96 @@ +Option Strict On + +Module Test + + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + Private AppTrace As New TraceSwitchCustom("AppTrace", "A custom trace switch") + + Public Sub Main() + 'Show a trace information message + AppTrace.MessageInfo("Trace information message", _ + "This is a verbose version of the trace information") + 'Show a trace warning message + AppTrace.MessageWarning("Trace warning message", _ + "This is a verbose version of the trace warning") + 'Show a trace error message + AppTrace.MessageError("Trace error message", _ + "This is a verbose version of the trace error") + End Sub + +End Module + +Public Class TraceSwitchCustom : Inherits TraceSwitch + + Sub New(ByVal DisplayName As String, ByVal Description As String) + 'Chain call to base class, then show that tracing has started + MyBase.New(DisplayName, Description) + ControlTraceOutput(TraceLevel.Info, Me.DisplayName & _ + " trace listener created - trace level is " & Me.Level.ToString, "", 1) + End Sub + + Protected Overrides Sub OnSwitchSettingChanged() + 'Show that switch setting has changed + If Me.TraceInfo Then + ControlTraceOutput(TraceLevel.Info, Me.DisplayName & _ + " trace level is now " & Me.Level.ToString, "", 1) + End If + End Sub + + Public Sub MessageError(ByVal Message As String, ByVal VerboseMessage As String) + 'Show trace error message if errors are switched on + If Me.TraceError Then + ControlTraceOutput(TraceLevel.Error, Message, VerboseMessage, 2) + End If + End Sub + + Public Sub MessageWarning(ByVal Message As String, ByVal VerboseMessage As String) + 'Show trace warning message if warnings are switched on + If Me.TraceWarning Then + ControlTraceOutput(TraceLevel.Warning, Message, VerboseMessage, 2) + End If + End Sub + + Public Sub MessageInfo(ByVal Message As String, ByVal VerboseMessage As String) + 'Show trace information message if information messages are switched on + If Me.TraceInfo Then + ControlTraceOutput(TraceLevel.Info, Message, VerboseMessage, 2) + End If + End Sub + + Private Sub ControlTraceOutput(ByVal MessageLevel As TraceLevel, ByVal Message As String, ByVal VerboseMessage As String, ByVal StackDepth As Int16) + 'Validate parameters supplied by caller + If Message Is Nothing Then Message = "" + If VerboseMessage Is Nothing Then VerboseMessage = "" + 'Add system date/time to the trace message + Dim strDateTime As String = New System.DateTime().Now.ToString + 'Add originating module/procedure name to the trace message + '(catch any stackframe error, probably a permission problem) + Dim strTraceSource As String + Try + Dim objStackFrame As New System.Diagnostics.StackFrame(StackDepth) + strTraceSource = objStackFrame.GetMethod.DeclaringType.FullName & _ + "." & objStackFrame.GetMethod.Name + Catch + strTraceSource = _ + "unknown procedure (stackframe call failed - check permissions)" + Finally + Trace.WriteLine _ + (MessageLevel.ToString & " message at " & strDateTime & _ + " from " & strTraceSource, Me.DisplayName) + End Try + 'Write augmented trace message + Trace.Indent() + Trace.WriteLine(Message) + 'Emit verbose trace message if allowed and supplied + If Me.TraceVerbose And VerboseMessage.Length > 0 Then + Trace.Indent() + Trace.WriteLine(VerboseMessage) + Trace.Unindent() + End If + 'Finish message + Trace.Unindent() + Trace.Flush() + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/CustomTraceListener/AssemblyInfo.vb new file mode 100644 index 0000000..0e631e6 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.sln b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.sln new file mode 100644 index 0000000..f9976eb --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomTraceListener", "CustomTraceListener.vbproj", "{39549A95-F908-4BE4-AF53-C349C8E49FC5}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Debug.ActiveCfg = Debug|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Debug.Build.0 = Debug|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Release.ActiveCfg = Release|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.sln.old b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.sln.old new file mode 100644 index 0000000..1e7ea25 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomTraceListener", "CustomTraceListener.vbproj", "{39549A95-F908-4BE4-AF53-C349C8E49FC5}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Debug.ActiveCfg = Debug|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Debug.Build.0 = Debug|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Release.ActiveCfg = Release|.NET + {39549A95-F908-4BE4-AF53-C349C8E49FC5}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.suo b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.suo new file mode 100644 index 0000000..11346cc Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.suo differ diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.vbproj b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.vbproj new file mode 100644 index 0000000..d45ba0d --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.vbproj.user b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/CustomTraceListener.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/Test.vb b/Source/VisualStudio2003/Chapter06/CustomTraceListener/Test.vb new file mode 100644 index 0000000..1ef4e2a --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/Test.vb @@ -0,0 +1,114 @@ +Option Strict On +Imports System.Diagnostics +Imports System.Threading +Imports System.Text +Imports System.IO +Imports System + +Public Module Test + + Public Sub Main() + 'Activate the custom trace listener and its output file stream + Dim objPerformOutput As Stream = File.Create("Performance.xml") + Dim objPerformRecorder As New TimerTraceListener(objPerformOutput) + Trace.Listeners.Add(objPerformRecorder) + 'Add this statement at the start of every monitored procedure + Trace.WriteLine("Entering procedure") + 'Add this statement at the end of every monitored procedure + Trace.WriteLine("Leaving procedure") + 'Add these statements when closing the custom trace listener + objPerformRecorder.Flush() + objPerformRecorder.Close() + End Sub + +End Module + +Public Class TimerTraceListener : Inherits TextWriterTraceListener + + Private msbBuffer As New StringBuilder() + + 'All of our constructors are here + Public Sub New(ByVal Stream As Stream) + MyBase.New(Stream) + EmitHeader() + End Sub + + Public Sub New(ByVal Stream As Stream, ByVal Name As String) + MyBase.New(Stream, Name) + EmitHeader() + End Sub + + Public Sub New(ByVal Writer As TextWriter) + MyBase.New(Writer) + EmitHeader() + End Sub + + Public Sub New(ByVal Writer As TextWriter, ByVal Name As String) + MyBase.New(Writer, Name) + EmitHeader() + End Sub + + Protected Sub EmitHeader() + 'Start tracing performance data + MyBase.WriteLine("") + End Sub + + Public Overloads Overrides Sub Write(ByVal Message As String) + If msbBuffer Is Nothing Then + msbBuffer = New StringBuilder() + End If + msbBuffer.Append(Message) + End Sub + + Public Overloads Overrides Sub WriteLine(ByVal Message As String) + If Not (msbBuffer Is Nothing) Then + Message = msbBuffer.ToString & Message + msbBuffer = Nothing + End If + EmitMessage(Message) + End Sub + + Protected Sub EmitMessage(ByVal Message As String) + 'Write performance data + Dim objNow As DateTime = New System.DateTime().Now + Dim objCalledFrom As New StackFrame(4) + MyBase.WriteLine("") + 'Timing data + With objNow + MyBase.WriteLine(CreateTag("time", .ToLongTimeString() & "." & .Millisecond.ToString)) + MyBase.WriteLine(CreateTag("message", Message)) + End With + 'Caller data + With objCalledFrom.GetMethod + MyBase.WriteLine(CreateTag("method", .DeclaringType.FullName & "." & .Name)) + End With + 'Thread data + MyBase.WriteLine(CreateTag("thread", Thread.CurrentThread.Name)) + 'Finish log entry + MyBase.WriteLine("") + End Sub + + Protected Function CreateTag(ByVal TagName As String, ByVal TagContents As String) As String + 'Return an XML tag + Return "<" & TagName & ">" & TagContents & "" + End Function + + Public Overrides Sub Flush() + 'Flush any remaining information to file + If Not (msbBuffer Is Nothing) Then + EmitMessage(msbBuffer.ToString) + msbBuffer = Nothing + End If + 'Don’t forget to chain to MyBase + MyBase.Flush() + End Sub + + Public Overrides Sub Close() + 'Finish tracing performance data + MyBase.WriteLine("") + Me.Flush() + 'Don’t forget to chain to MyBase + MyBase.Close() + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter06/CustomTraceListener/bin/Performance.xml b/Source/VisualStudio2003/Chapter06/CustomTraceListener/bin/Performance.xml new file mode 100644 index 0000000..8742f16 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/CustomTraceListener/bin/Performance.xml @@ -0,0 +1,14 @@ + + + +Entering procedure +CustomTraceListener.Test.Main + + + + +Leaving procedure +CustomTraceListener.Test.Main + + + diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/AssemblyInfo.vb new file mode 100644 index 0000000..a4facbb --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln new file mode 100644 index 0000000..11e353e --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RemoveDefaultTrace", "RemoveDefaultTrace.vbproj", "{831BA6C7-D44A-4C54-B62F-C12A3D3831C6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Debug.ActiveCfg = Debug|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Debug.Build.0 = Debug|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Release.ActiveCfg = Release|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln.old b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln.old new file mode 100644 index 0000000..619bb4e --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RemoveDefaultTrace", "RemoveDefaultTrace.vbproj", "{831BA6C7-D44A-4C54-B62F-C12A3D3831C6}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Debug.ActiveCfg = Debug|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Debug.Build.0 = Debug|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Release.ActiveCfg = Release|.NET + {831BA6C7-D44A-4C54-B62F-C12A3D3831C6}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.suo b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.suo new file mode 100644 index 0000000..7e01741 Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.suo differ diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj new file mode 100644 index 0000000..931f935 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj.user b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/RemoveDefaultTrace.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/Test.vb b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/Test.vb new file mode 100644 index 0000000..9a76b38 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/RemoveDefaultTrace/Test.vb @@ -0,0 +1,12 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + 'Remove the default trace listener from the listeners collection + 'This method takes either a string containing the listener name + 'or the listener object + Trace.Listeners.Remove("DefaultTraceListener") + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/TraceAssert/AssemblyInfo.vb new file mode 100644 index 0000000..3223915 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceAssert/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/Test.vb b/Source/VisualStudio2003/Chapter06/TraceAssert/Test.vb new file mode 100644 index 0000000..86f8991 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceAssert/Test.vb @@ -0,0 +1,21 @@ +Option Strict On + +Module Test + + Sub Main() + Dim VbClassic As Int16, VbNet As Int16 + 'Does TRUE have the same value when using + 'VB.Classic functions and VB .NET functions? + VbClassic = CInt(True) + VbNet = Convert.ToInt16(True) + 'This overload just shows the call stack leading to the assertion failure + Trace.Assert(VbClassic = VbNet) + 'This overload adds an brief explanation of the assertion failure + Trace.Assert(VbClassic = VbNet, "Assertion failed: VbClassic(True) <> VbNet(True)") + 'This overload adds a more detailed explanation of the assertion failure + Trace.Assert(VbClassic = VbNet, "Assertion failed: VbClassic(True) <> VbNet(True)", _ + "CInt(True)=" & VbClassic.ToString & _ + " : Convert.ToInt16(True)=" & VbNet.ToString) + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.sln b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.sln new file mode 100644 index 0000000..b59b5ab --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceAssert", "TraceAssert.vbproj", "{DB28045D-F29C-46C5-88B1-1B5A786DC862}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Debug.ActiveCfg = Debug|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Debug.Build.0 = Debug|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Release.ActiveCfg = Release|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.sln.old b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.sln.old new file mode 100644 index 0000000..cef6116 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceAssert", "TraceAssert.vbproj", "{DB28045D-F29C-46C5-88B1-1B5A786DC862}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Debug.ActiveCfg = Debug|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Debug.Build.0 = Debug|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Release.ActiveCfg = Release|.NET + {DB28045D-F29C-46C5-88B1-1B5A786DC862}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.suo b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.suo new file mode 100644 index 0000000..da4b203 Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.suo differ diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.vbproj b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.vbproj new file mode 100644 index 0000000..e699902 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.vbproj.user b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceAssert/TraceAssert.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/AssemblyInfo.vb new file mode 100644 index 0000000..bbded1f --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/Test.vb b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/Test.vb new file mode 100644 index 0000000..3d9c0af --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/Test.vb @@ -0,0 +1,28 @@ +Option Strict On + +Module Test + + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + Private tswTraceControl As New Diagnostics.TraceSwitch("SwitchTrace", "Test trace switch") + + Public Sub Main() + 'Create switch for controlling tracing in hypothetical component and set + 'the boolean for this switch – setting could come from registry or config file + tswTraceControl.Level = TraceLevel.Warning + Test() + End Sub + + Public Sub Test() + 'Either check the TraceError, TraceWarning, TraceInfo + 'or TraceVerbose properties + If tswTraceControl.TraceError Then + Trace.WriteLine("Trace only shows if traceswitch is set to show errors") + End If + 'Or check the Level property against the TraceLevel enumeration + If tswTraceControl.Level = TraceLevel.Warning Then + Trace.WriteLine("Trace shows if traceswitch is set to show warnings or errors") + End If + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.sln b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.sln new file mode 100644 index 0000000..57541e3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceSwitchTest", "TraceSwitchTest.vbproj", "{CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Debug.ActiveCfg = Debug|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Debug.Build.0 = Debug|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Release.ActiveCfg = Release|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.sln.old b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.sln.old new file mode 100644 index 0000000..fb5873a --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceSwitchTest", "TraceSwitchTest.vbproj", "{CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Debug.ActiveCfg = Debug|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Debug.Build.0 = Debug|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Release.ActiveCfg = Release|.NET + {CAFE2AF3-2EE8-48D0-BBAA-5BA83250ADA0}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.suo b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.suo new file mode 100644 index 0000000..b02fbc7 Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.suo differ diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj new file mode 100644 index 0000000..8b336c7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj.user b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceSwitchTest/TraceSwitchTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/TraceToConsole/AssemblyInfo.vb new file mode 100644 index 0000000..5dac7a1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToConsole/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/Test.vb b/Source/VisualStudio2003/Chapter06/TraceToConsole/Test.vb new file mode 100644 index 0000000..38175fe --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToConsole/Test.vb @@ -0,0 +1,23 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + 'Create a trace listener that writes trace information to the console + Dim objTraceToConsole As New TextWriterTraceListener(System.Console.Out) + 'Add the new trace listener to the collection of listeners + Trace.Listeners.Add(objTraceToConsole) + 'Write trace information to all listeners, including the console + Trace.WriteLine("This trace information is for all listeners") + 'Write trace information to just the console listener + objTraceToConsole.WriteLine _ + ("This trace information is just for the console listener") + 'Pause application to see console output + Console.ReadLine() + 'Finish and clean up our console listener + objTraceToConsole.Flush() + objTraceToConsole.Close() + objTraceToConsole.Dispose() + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.sln b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.sln new file mode 100644 index 0000000..2c171b0 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToConsole", "TraceToConsole.vbproj", "{10886B1B-5C6A-4023-ADAC-D32412E5B9AC}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Debug.ActiveCfg = Debug|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Debug.Build.0 = Debug|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Release.ActiveCfg = Release|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.sln.old b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.sln.old new file mode 100644 index 0000000..111c80f --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToConsole", "TraceToConsole.vbproj", "{10886B1B-5C6A-4023-ADAC-D32412E5B9AC}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Debug.ActiveCfg = Debug|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Debug.Build.0 = Debug|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Release.ActiveCfg = Release|.NET + {10886B1B-5C6A-4023-ADAC-D32412E5B9AC}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.suo b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.suo new file mode 100644 index 0000000..d97c4b1 Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.suo differ diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.vbproj b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.vbproj new file mode 100644 index 0000000..d40c767 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.vbproj.user b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToConsole/TraceToConsole.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/TraceToEventLog/AssemblyInfo.vb new file mode 100644 index 0000000..aa32d4b --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToEventLog/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/Test.vb b/Source/VisualStudio2003/Chapter06/TraceToEventLog/Test.vb new file mode 100644 index 0000000..a4d8324 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToEventLog/Test.vb @@ -0,0 +1,29 @@ +Option Strict On + +Class Test + + Public Shared Sub Main() + + 'Create an event log trace listener, give it a name, and configure it + Dim objTraceToAppLog As New EventLogTraceListener("LogTraceListener") + With objTraceToAppLog + 'Write to the Application event log + .EventLog.Log = "Application" + 'Specify source of tracing information + .EventLog.Source = "AppName." & .Name + End With + 'Add the new trace listener to the collection of listeners + Trace.Listeners.Add(objTraceToAppLog) + 'Write trace information to all listeners, + 'including the Application event log + Trace.WriteLine("This trace information is for all listeners") + 'Finish and clean up our console listener + With objTraceToAppLog + .Flush() + .Close() + .Dispose() + End With + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.sln b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.sln new file mode 100644 index 0000000..e8aece5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToEventLog", "TraceToEventLog.vbproj", "{DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Debug.ActiveCfg = Debug|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Debug.Build.0 = Debug|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Release.ActiveCfg = Release|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.sln.old b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.sln.old new file mode 100644 index 0000000..da1a871 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToEventLog", "TraceToEventLog.vbproj", "{DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Debug.ActiveCfg = Debug|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Debug.Build.0 = Debug|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Release.ActiveCfg = Release|.NET + {DC3BFCE2-7CBB-43BB-BD42-514F04E0CB3D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.suo b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.suo new file mode 100644 index 0000000..f2898b4 Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.suo differ diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.vbproj b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.vbproj new file mode 100644 index 0000000..58af692 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.vbproj.user b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToEventLog/TraceToEventLog.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter06/TraceToText/AssemblyInfo.vb new file mode 100644 index 0000000..307f6ec --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/Test.vb b/Source/VisualStudio2003/Chapter06/TraceToText/Test.vb new file mode 100644 index 0000000..464ca21 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/Test.vb @@ -0,0 +1,22 @@ +Option Strict On +Imports System.IO + +Class Test + + Public Shared Sub Main() + + 'Create a trace listener that writes trace information to a text file + Dim objTextFile As Stream = File.Create("TraceListener.txt") + Dim objTraceToText As New TextWriterTraceListener(objTextFile) + 'Add the new trace listener to the collection of listeners + Trace.Listeners.Add(objTraceToText) + 'Write trace information to all listeners, including the text file + Trace.WriteLine("This trace information is for all listeners") + 'Finish and clean up our console listener + objTraceToText.Flush() + objTraceToText.Close() + objTraceToText.Dispose() + + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.sln b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.sln new file mode 100644 index 0000000..cd9cac6 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToText", "TraceToText.vbproj", "{32485B72-9BD6-46CE-BA3D-A685907A58D2}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Debug.ActiveCfg = Debug|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Debug.Build.0 = Debug|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Release.ActiveCfg = Release|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.sln.old b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.sln.old new file mode 100644 index 0000000..c600440 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TraceToText", "TraceToText.vbproj", "{32485B72-9BD6-46CE-BA3D-A685907A58D2}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Debug.ActiveCfg = Debug|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Debug.Build.0 = Debug|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Release.ActiveCfg = Release|.NET + {32485B72-9BD6-46CE-BA3D-A685907A58D2}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.suo b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.suo new file mode 100644 index 0000000..33e785f Binary files /dev/null and b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.suo differ diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.vbproj b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.vbproj new file mode 100644 index 0000000..966a681 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.vbproj.user b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/TraceToText.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter06/TraceToText/bin/TraceListener.txt b/Source/VisualStudio2003/Chapter06/TraceToText/bin/TraceListener.txt new file mode 100644 index 0000000..913e28a --- /dev/null +++ b/Source/VisualStudio2003/Chapter06/TraceToText/bin/TraceListener.txt @@ -0,0 +1 @@ +This trace information is for all listeners diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter07/DebugAddIn/AssemblyInfo.vb new file mode 100644 index 0000000..65078ef --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/AssemblyInfo.vb @@ -0,0 +1,36 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +'TODO: Review the values of the assembly attributes + + + + + + + + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Revision +' Build Number +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + + + + + + +' Note: A strong name key has been generated. If you wish to use it, uncomment the following line: +' diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/Connect.vb b/Source/VisualStudio2003/Chapter07/DebugAddIn/Connect.vb new file mode 100644 index 0000000..fc4c4e6 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/Connect.vb @@ -0,0 +1,83 @@ +Imports Microsoft.Office.Core +imports Extensibility +imports System.Runtime.InteropServices +Imports EnvDTE + +#Region " Read me for Add-in installation and setup information. " +' When run, the Add-in wizard prepared the registry for the Add-in. +' At a later time, if the Add-in becomes unavailable for reasons such as: +' 1) You moved this project to a computer other than which is was originally created on. +' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. +' 3) Registry corruption. +' you will need to re-register the Add-in by building the DebugAddInSetup project +' by right clicking the project in the Solution Explorer, then choosing install. +#End Region + + _ +Public Class Connect + + Implements Extensibility.IDTExtensibility2 + Implements IDTCommandTarget + + Dim applicationObject As EnvDTE.DTE + Dim addInInstance as EnvDTE.AddIn + + Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown + End Sub + + Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnAddInsUpdate + End Sub + + Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete + End Sub + + Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection + End Sub + + Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection + + applicationObject = CType(application, EnvDTE.DTE) + addInInstance = CType(addInInst, EnvDTE.AddIn) + If connectMode = Extensibility.ext_ConnectMode.ext_cm_UISetup Then + Dim objAddIn As AddIn = CType(addInInst, AddIn) + Dim CommandObj As Command + + ' When run, the Add-in wizard prepared the registry for the Add-in. + ' At a later time, the Add-in or its commands may become unavailable for reasons such as: + ' 1) You moved this project to a computer other than which is was originally created on. + ' 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in. + ' 3) You add new commands or modify commands already defined. + ' You will need to re-register the Add-in by building the DebugAddInSetup project, + ' right-clicking the project in the Solution Explorer, and then choosing install. + ' Alternatively, you could execute the ReCreateCommands.reg file the Add-in Wizard generated in + ' the project directory, or run 'devenv /setup' from a command prompt. + Try + CommandObj = applicationObject.Commands.AddNamedCommand(objAddIn, "DebugAddIn", "DebugAddIn", "Executes the command for DebugAddIn", True, 59, Nothing, 1 + 2) '1+2 == vsCommandStatusSupported+vsCommandStatusEnabled + CommandObj.AddControl(applicationObject.CommandBars.Item("Tools")) + Catch e as System.Exception + End Try + End If + End Sub + + Public Sub Exec(ByVal cmdName As String, ByVal executeOption As vsCommandExecOption, ByRef varIn As Object, ByRef varOut As Object, ByRef handled As Boolean) Implements IDTCommandTarget.Exec + handled = False + If (executeOption = vsCommandExecOption.vsCommandExecOptionDoDefault) Then + If cmdName = "DebugAddIn.Connect.DebugAddIn" Then + 'Here is the active code + MsgBox("The add-in debugging demo is born", MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, "Welcome") + handled = True + Exit Sub + End If + End If + End Sub + + Public Sub QueryStatus(ByVal cmdName As String, ByVal neededText As vsCommandStatusTextWanted, ByRef statusOption As vsCommandStatus, ByRef commandText As Object) Implements IDTCommandTarget.QueryStatus + If neededText = EnvDTE.vsCommandStatusTextWanted.vsCommandStatusTextWantedNone Then + If cmdName = "DebugAddIn.Connect.DebugAddIn" Then + statusOption = CType(vsCommandStatus.vsCommandStatusEnabled + vsCommandStatus.vsCommandStatusSupported, vsCommandStatus) + Else + statusOption = vsCommandStatus.vsCommandStatusUnsupported + End If + End If + End Sub +End Class diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.sln b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.sln new file mode 100644 index 0000000..53d6a5f --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugAddIn", "DebugAddIn.vbproj", "{535259D0-3BAD-4EA0-8E16-9FC33E98294F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DebugAddInSetup", "DebugAddInSetup\DebugAddInSetup.vdproj", "{456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Debug.ActiveCfg = Debug|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Debug.Build.0 = Debug|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Release.ActiveCfg = Release|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Release.Build.0 = Release|.NET + {456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}.Debug.ActiveCfg = Debug + {456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}.Release.ActiveCfg = Release + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.sln.old b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.sln.old new file mode 100644 index 0000000..79a3573 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.sln.old @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugAddIn", "DebugAddIn.vbproj", "{535259D0-3BAD-4EA0-8E16-9FC33E98294F}" +EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "DebugAddInSetup", "DebugAddInSetup\DebugAddInSetup.vdproj", "{456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Debug.ActiveCfg = Debug|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Debug.Build.0 = Debug|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Release.ActiveCfg = Release|.NET + {535259D0-3BAD-4EA0-8E16-9FC33E98294F}.Release.Build.0 = Release|.NET + {456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}.Debug.ActiveCfg = Debug + {456DEF88-8A39-4CF8-9BF8-CF25DBBEDDA6}.Release.ActiveCfg = Release + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.suo b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.suo new file mode 100644 index 0000000..a78a56d Binary files /dev/null and b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.suo differ diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.vbproj b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.vbproj new file mode 100644 index 0000000..d684f47 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.vbproj @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.vbproj.user b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.vbproj.user new file mode 100644 index 0000000..7b3836b --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddIn.vbproj.user @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddInSetup/DebugAddInSetup.vdproj b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddInSetup/DebugAddInSetup.vdproj new file mode 100644 index 0000000..f9a80fe --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/DebugAddInSetup/DebugAddInSetup.vdproj @@ -0,0 +1,1089 @@ +"DeployProject" +{ +"VSVersion" = "3:701" +"ProjectType" = "8:{2C2AF0D9-9B47-4FE5-BEF2-169778172667}" +"IsWebType" = "8:FALSE" +"ProjectName" = "8:DebugAddInSetup" +"LanguageId" = "3:1033" +"CodePage" = "3:1252" +"UILanguageId" = "3:1033" +"SccProjectName" = "8:" +"SccLocalPath" = "8:" +"SccAuxPath" = "8:" +"SccProvider" = "8:" + "Hierarchy" + { + "Entry" + { + "MsmKey" = "8:_0F4F71DAC220C61A7421F72C99601122" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_4ED3A28D6D324C77A6C0F50FDC0D5EB8" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_558FE741FD1E46CE401F7BA1D72B6167" + "OwnerKey" = "8:_0F4F71DAC220C61A7421F72C99601122" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "OwnerKey" = "8:_UNDEFINED" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_A1B4C5D4F0B04AD09A9661E61A87CADD" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_BDEBB69EADEC7D20D27BF63A0899C110" + "OwnerKey" = "8:_0F4F71DAC220C61A7421F72C99601122" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_BDEBB69EADEC7D20D27BF63A0899C110" + "OwnerKey" = "8:_A18D22CB7CF548E99EF4F3A51C564401" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F293FC85A07EACA34FA466B4955CB861" + "OwnerKey" = "8:_0F4F71DAC220C61A7421F72C99601122" + "MsmSig" = "8:_UNDEFINED" + } + "Entry" + { + "MsmKey" = "8:_F293FC85A07EACA34FA466B4955CB861" + "OwnerKey" = "8:_BDEBB69EADEC7D20D27BF63A0899C110" + "MsmSig" = "8:_UNDEFINED" + } + } + "Configurations" + { + "Debug" + { + "DisplayName" = "8:Debug" + "IsDebugOnly" = "11:TRUE" + "IsReleaseOnly" = "11:FALSE" + "OutputFilename" = "8:Debug\\DebugAddInSetup.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + "Release" + { + "DisplayName" = "8:Release" + "IsDebugOnly" = "11:FALSE" + "IsReleaseOnly" = "11:TRUE" + "OutputFilename" = "8:Release\\DebugAddInSetup.msi" + "PackageFilesAs" = "3:2" + "PackageFileSize" = "3:-2147483648" + "CabType" = "3:1" + "Compression" = "3:2" + "SignOutput" = "11:FALSE" + "CertificateFile" = "8:" + "PrivateKeyFile" = "8:" + "TimeStampServer" = "8:" + "InstallerBootstrapper" = "3:2" + } + } + "Deployable" + { + "CustomAction" + { + } + "DefaultFeature" + { + "Name" = "8:DefaultFeature" + "Title" = "8:" + "Description" = "8:" + } + "ExternalPersistence" + { + "LaunchCondition" + { + "{2522A265-4974-4402-83C5-3B575A2E935A}:_64C84FB153514CFFA559C6152F971F64" + { + "Name" = "8:MsiNetAssemblySupport" + "Message" = "8:[VSDNETMSG]" + "SupportedRuntimes" = "8:1.1.4322" + "InstallUrl" = "8:http://support.microsoft.com/support/vstudio/vsdeployment.asp" + } + } + } + "Feature" + { + } + "File" + { + "{FB480208-1853-44D0-9ABD-A3B734C3FAAA}:_0F4F71DAC220C61A7421F72C99601122" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_0F4F71DAC220C61A7421F72C99601122" + { + "Name" = "8:EnvDTE.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:EnvDTE.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{FB480208-1853-44D0-9ABD-A3B734C3FAAA}:_4ED3A28D6D324C77A6C0F50FDC0D5EB8" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Extensibility, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_4ED3A28D6D324C77A6C0F50FDC0D5EB8" + { + "Name" = "8:Extensibility.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Extensibility.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{A582A373-4685-4296-BEFE-614B80A702C3}:_558FE741FD1E46CE401F7BA1D72B6167" + { + "SourcePath" = "8:dte.olb" + "TargetName" = "8:dte.olb" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{FB480208-1853-44D0-9ABD-A3B734C3FAAA}:_BDEBB69EADEC7D20D27BF63A0899C110" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:FALSE" + "AssemblyAsmDisplayName" = "8:Office, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_BDEBB69EADEC7D20D27BF63A0899C110" + { + "Name" = "8:Office.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:Office.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + "{FB480208-1853-44D0-9ABD-A3B734C3FAAA}:_F293FC85A07EACA34FA466B4955CB861" + { + "AssemblyRegister" = "3:1" + "AssemblyIsInGAC" = "11:TRUE" + "AssemblyAsmDisplayName" = "8:stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" + "ScatterAssemblies" + { + "_F293FC85A07EACA34FA466B4955CB861" + { + "Name" = "8:stdole.dll" + "Attributes" = "3:512" + } + } + "SourcePath" = "8:stdole.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:TRUE" + "IsDependency" = "11:TRUE" + "IsolateTo" = "8:" + } + } + "FileType" + { + } + "Folder" + { + "{78BAF5CE-F2E5-45BE-83BC-DB6AF387E941}:_752873E334AC42F28BA930688B96759E" + { + "Name" = "8:#1919" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:ProgramMenuFolder" + "Folders" + { + } + } + "{78BAF5CE-F2E5-45BE-83BC-DB6AF387E941}:_B77B8CC82F544E14958EA25C687EBC48" + { + "Name" = "8:#1916" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:DesktopFolder" + "Folders" + { + } + } + "{58C0ADA3-3CEA-43BD-A3B3-2EA121BC8217}:_CDE300ED3B194097AE33ECB71ECE9B7F" + { + "DefaultLocation" = "8:[ProgramFilesFolder][Manufacturer]\\[ProductName]" + "Name" = "8:#1925" + "AlwaysCreate" = "11:FALSE" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Property" = "8:TARGETDIR" + "Folders" + { + } + } + } + "LaunchCondition" + { + } + "Locator" + { + } + "MsiBootstrapper" + { + "LangId" = "3:1033" + } + "Product" + { + "Name" = "8:Microsoft Visual Studio" + "ProductName" = "8:DebugAddInSetup" + "ProductCode" = "8:{3D050B02-F6BD-4803-BCF5-8FE325A4F971}" + "PackageCode" = "8:{7E2C78B2-2B27-4375-BD94-1DCCD3675BAC}" + "UpgradeCode" = "8:{6FB60611-7F9C-44AB-8E9B-799CE6399B7D}" + "RestartWWWService" = "11:FALSE" + "RemovePreviousVersions" = "11:FALSE" + "DetectNewerInstalledVersion" = "11:TRUE" + "ProductVersion" = "8:1.0.0" + "Manufacturer" = "8:Sleek Software Ltd" + "ARPHELPTELEPHONE" = "8:" + "ARPHELPLINK" = "8:" + "Title" = "8:DebugAddInSetup" + "Subject" = "8:" + "ARPCONTACT" = "8:Sleek Software Ltd" + "Keywords" = "8:" + "ARPCOMMENTS" = "8:" + "ARPURLINFOABOUT" = "8:" + "ARPPRODUCTICON" = "8:" + "ARPIconIndex" = "3:0" + "SearchPath" = "8:" + "UseSystemSearchPath" = "11:TRUE" + } + "Registry" + { + "HKLM" + { + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_D8629588BB434B99AFF1B48A49CB55F6" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_69989357966443E881ABD5623DDA1BE3" + { + "Name" = "8:Microsoft" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_09A6D1EA72204C8F95507099738A41DE" + { + "Name" = "8:VSA" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_273AAC7056794D72975B80AA8D6C91D0" + { + "Name" = "8:7.0" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_F83464988848477BAF60E13BD25C51A0" + { + "Name" = "8:AddIns" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_760A9241284549849D704A7092BB9869" + { + "Name" = "8:DebugAddIn.Connect" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_11947A1EA185469590A77AF750773B0E" + { + "Name" = "8:Description" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Demonstrate add-in debugging" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_3E878CE40D6141BC8DA290F9FB5D7D60" + { + "Name" = "8:LoadBehavior" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_7A2F3F5E81E24C36BBD71FA51E9462B8" + { + "Name" = "8:AboutBoxIcon" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:4" + "Value" = "8:0000010002002020100000000000E8020000260000001010100000000000280100000E0300002800000020000000400000000100040000000000800200000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ABA00000000000000000000000000000BAB00000000000000000000000000000ABA00000000000000000000000F00000BAB00000000000008888888888F0ABABABABABA0000000008F77777777F0BABABABABAB0000000008F77777777F0ABABABABABA0000000008F77777777F00000BAB00000000000008F77777777FFFFF0ABA00000008880008F777777777777F0BAB00000887788008F777777777777F0ABA000008FF770778F777777777777F0000000008FFF78088F777777777777FFFFFF000008FF70008F7777777777777777800000008880008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008FFFFFFFFFFFFFFFFF800000000000008888888888888888888000000000000000000870000008700000000000000000000008F0000008F000000000000000000000008000000080000000000000000000000808000008080000000000000000000877788008777880000000000000000008FF778008FF7780000000000000000008FFF78008FFF7800000000000000000008FF700008FF7000000000000000000000777000007770000000000000000000000000000000000000000FFFFFFFFFFFFFE0FFFFFFE0FFFFFFE0FFFFFFE0FFF000000FF000000FF000000FF000000FF000000C700000F8300000F0000000F0000000F0000000F8300000FC700000FFF00000FFF00000FFF00000FFF00000FFF00000FFFF8F8FFFFF8F8FFFFF8F8FFFFF0707FFFE0203FFFE0203FFFE0203FFFF0707FFFF8F8FFFFFFFFFF2800000010000000200000000100040000000000C00000000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000000000000000000000000000A000000000000000B00000000000F0ABABA000008F88F000B00000008F77FFF0A00070708F7777F000000F008F7777FFFF0070708F777777800000008FFFFFFF800000008888888880000000000000000000000000070700000000000000F00000000000000707000000FFFF0000FFE30000FFE30000FF800000F0000000F0000000F0030000100300000003000010030000F0030000F0030000FF7F0000FE3F0000FE3F0000FE3F0000" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_8FEFF79061BA49B08795EDCEF0FAD25C" + { + "Name" = "8:CommandLineSafe" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:0" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_A7C4E07C9B3049C28FB2C27A063E04F1" + { + "Name" = "8:FriendlyName" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Debug AddIn" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_AE28F0AFA43741458B1449FB88335D41" + { + "Name" = "8:CommandPreload" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_DC92F045E0DD4F048CC51E5AEB57B049" + { + "Name" = "8:AboutBoxDetails" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:This Visual Studio .NET add-in is a debugging demonstration" + } + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_EFB6A2CFDF204BFF845AFADBF144FB32" + { + "Name" = "8:VisualStudio" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_5D224508FB724B778F87AE714E8EB555" + { + "Name" = "8:7.0" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_0D86E33CA23741F8BBD2C390AC4ED8B6" + { + "Name" = "8:AddIns" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_F9CE86043D2B48369CE7E86AA726972E" + { + "Name" = "8:DebugAddIn.Connect" + "Condition" = "8:" + "AlwaysCreate" = "11:TRUE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_058E8ADEBEBC4DA5BFA240CF913CD84C" + { + "Name" = "8:AboutBoxIcon" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:4" + "Value" = "8:0000010002002020100000000000E8020000260000001010100000000000280100000E0300002800000020000000400000000100040000000000800200000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ABA00000000000000000000000000000BAB00000000000000000000000000000ABA00000000000000000000000F00000BAB00000000000008888888888F0ABABABABABA0000000008F77777777F0BABABABABAB0000000008F77777777F0ABABABABABA0000000008F77777777F00000BAB00000000000008F77777777FFFFF0ABA00000008880008F777777777777F0BAB00000887788008F777777777777F0ABA000008FF770778F777777777777F0000000008FFF78088F777777777777FFFFFF000008FF70008F7777777777777777800000008880008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008F7777777777777777800000000000008FFFFFFFFFFFFFFFFF800000000000008888888888888888888000000000000000000870000008700000000000000000000008F0000008F000000000000000000000008000000080000000000000000000000808000008080000000000000000000877788008777880000000000000000008FF778008FF7780000000000000000008FFF78008FFF7800000000000000000008FF700008FF7000000000000000000000777000007770000000000000000000000000000000000000000FFFFFFFFFFFFFE0FFFFFFE0FFFFFFE0FFFFFFE0FFF000000FF000000FF000000FF000000FF000000C700000F8300000F0000000F0000000F0000000F8300000FC700000FFF00000FFF00000FFF00000FFF00000FFF00000FFFF8F8FFFFF8F8FFFFF8F8FFFFF0707FFFE0203FFFE0203FFFE0203FFFF0707FFFF8F8FFFFFFFFFF2800000010000000200000000100040000000000C00000000000000000000000000000000000000000000000000080000080000000808000800000008000800080800000C0C0C000808080000000FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF0000000000000000000000000000000000000000000000A000000000000000B00000000000F0ABABA000008F88F000B00000008F77FFF0A00070708F7777F000000F008F7777FFFF0070708F777777800000008FFFFFFF800000008888888880000000000000000000000000070700000000000000F00000000000000707000000FFFF0000FFE30000FFE30000FF800000F0000000F0000000F0030000100300000003000010030000F0030000F0030000FF7F0000FE3F0000FE3F0000FE3F0000" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_66BFFC4A036F475F8630545DE4F7F84E" + { + "Name" = "8:AboutBoxDetails" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:This Visual Studio .NET add-in is a debugging demonstration" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_94963B340CE84207BF19AA8403B83E9B" + { + "Name" = "8:CommandLineSafe" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:0" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_B6F46FA7092B4CB19031659BD70DB93C" + { + "Name" = "8:Description" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Demonstrate add-in debugging" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_BDFB3C729CE84D42AECADBDAA31673F4" + { + "Name" = "8:LoadBehavior" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_D50A998B828C4589BFABB1E3E4BD6D56" + { + "Name" = "8:CommandPreload" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:3" + "Value" = "3:1" + } + "{35AE352C-BC79-4EF9-ABD8-61F467188583}:_F5DE8AC508494456A4773705B4A1C6FD" + { + "Name" = "8:FriendlyName" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "ValueTypes" = "3:1" + "Value" = "8:Debug AddIn" + } + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + "Values" + { + } + } + } + } + "HKCU" + { + "Keys" + { + "{6A471EEF-D31B-40F8-BCF6-C9E8EC783F36}:_6B40E74C6A3648E19EC5C00FD7DA0A53" + { + "Name" = "8:Software" + "Condition" = "8:" + "AlwaysCreate" = "11:FALSE" + "DeleteAtUninstall" = "11:FALSE" + "Transitive" = "11:FALSE" + "Keys" + { + } + "Values" + { + } + } + } + } + "HKCR" + { + "Keys" + { + } + } + "HKU" + { + "Keys" + { + } + } + "HKPU" + { + "Keys" + { + } + } + } + "Sequences" + { + } + "Shortcut" + { + } + "UserInterface" + { + "{B654A020-6903-4E6A-A86C-75DC463DB54B}:_6218B88E89FE478E8B64EE267D46CFB2" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdUserInterface.wim" + } + "{8D9DEE8B-DD8B-4F48-9072-C4364E4F4011}:_6C6A2019794A428AAC594CF1F4D0D8D0" + { + "Name" = "8:#1901" + "Sequence" = "3:2" + "Attributes" = "3:2" + "Dialogs" + { + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_3DDA4B78A4D44F9EA0C350450DFFBB62" + { + "Sequence" = "3:100" + "DisplayName" = "8:Progress" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{8D9DEE8B-DD8B-4F48-9072-C4364E4F4011}:_7B0B0E38D1C04BFAB059184A451012ED" + { + "Name" = "8:#1902" + "Sequence" = "3:2" + "Attributes" = "3:3" + "Dialogs" + { + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_032AE689439C4F52B1646CEC625D44BA" + { + "Sequence" = "3:100" + "DisplayName" = "8:Finished" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{8D9DEE8B-DD8B-4F48-9072-C4364E4F4011}:_9A854B9E75D447AC8A77C302D70B2349" + { + "Name" = "8:#1902" + "Sequence" = "3:1" + "Attributes" = "3:3" + "Dialogs" + { + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_182877F5792B4153B0623805DCD78B2E" + { + "Sequence" = "3:100" + "DisplayName" = "8:Finished" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFinishedDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "UpdateText" + { + "Name" = "8:UpdateText" + "DisplayName" = "8:#1058" + "Description" = "8:#1158" + "Type" = "3:15" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1258" + "DefaultValue" = "8:#1258" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{8D9DEE8B-DD8B-4F48-9072-C4364E4F4011}:_B0D7A8425A044AC494921E9159923DDA" + { + "Name" = "8:#1900" + "Sequence" = "3:2" + "Attributes" = "3:1" + "Dialogs" + { + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_3419C658202E4141A292F8097FA90D51" + { + "Sequence" = "3:200" + "DisplayName" = "8:Installation Folder" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_3D47C35321644641B44D8910FFCD10AC" + { + "Sequence" = "3:100" + "DisplayName" = "8:Welcome" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_50A57E1AB4AB486AA7FE6F9D752B8383" + { + "Sequence" = "3:300" + "DisplayName" = "8:Confirm Installation" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdAdminConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{8D9DEE8B-DD8B-4F48-9072-C4364E4F4011}:_B866188749924DE390D758D413B13E1D" + { + "Name" = "8:#1901" + "Sequence" = "3:1" + "Attributes" = "3:2" + "Dialogs" + { + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_9FF09CF32AA4497DAA0CF1AD1051F8EF" + { + "Sequence" = "3:100" + "DisplayName" = "8:Progress" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdProgressDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "ShowProgress" + { + "Name" = "8:ShowProgress" + "DisplayName" = "8:#1009" + "Description" = "8:#1109" + "Type" = "3:5" + "ContextData" = "8:1;True=1;False=0" + "Attributes" = "3:0" + "Setting" = "3:0" + "Value" = "3:1" + "DefaultValue" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + "{B654A020-6903-4E6A-A86C-75DC463DB54B}:_C354EEFC52134F47A537732481755B06" + { + "UseDynamicProperties" = "11:FALSE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdBasicDialogs.wim" + } + "{8D9DEE8B-DD8B-4F48-9072-C4364E4F4011}:_CE2DB2EACD34479992CADC4C0326386E" + { + "Name" = "8:#1900" + "Sequence" = "3:1" + "Attributes" = "3:1" + "Dialogs" + { + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_4EEE0209AC304F7981534B738F1E4D14" + { + "Sequence" = "3:100" + "DisplayName" = "8:Welcome" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdWelcomeDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + "CopyrightWarning" + { + "Name" = "8:CopyrightWarning" + "DisplayName" = "8:#1002" + "Description" = "8:#1102" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1202" + "DefaultValue" = "8:#1202" + "UsePlugInResources" = "11:TRUE" + } + "Welcome" + { + "Name" = "8:Welcome" + "DisplayName" = "8:#1003" + "Description" = "8:#1103" + "Type" = "3:3" + "ContextData" = "8:" + "Attributes" = "3:0" + "Setting" = "3:1" + "Value" = "8:#1203" + "DefaultValue" = "8:#1203" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_51687977F6BE4225ADB22755AA7A8AF8" + { + "Sequence" = "3:200" + "DisplayName" = "8:Installation Folder" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdFolderDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + "{18ADD6EC-89FE-4ED7-AD3E-211C40278470}:_917F1F1053AC478B9AB035F9D81BB6F9" + { + "Sequence" = "3:300" + "DisplayName" = "8:Confirm Installation" + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:FALSE" + "SourcePath" = "8:\\VsdConfirmDlg.wid" + "Properties" + { + "BannerBitmap" + { + "Name" = "8:BannerBitmap" + "DisplayName" = "8:#1001" + "Description" = "8:#1101" + "Type" = "3:8" + "ContextData" = "8:Bitmap" + "Attributes" = "3:4" + "Setting" = "3:1" + "UsePlugInResources" = "11:TRUE" + } + } + } + } + } + } + "MergeModule" + { + "{35A69C6E-5BA4-440D-803D-762B59A45393}:_A1B4C5D4F0B04AD09A9661E61A87CADD" + { + "UseDynamicProperties" = "11:TRUE" + "IsDependency" = "11:TRUE" + "SourcePath" = "8:dotnetfxredist_x86.msm" + "Properties" + { + } + "LanguageId" = "3:1033" + "Exclude" = "11:TRUE" + "Folder" = "8:" + "Feature" = "8:" + "IsolateTo" = "8:" + } + } + "ProjectOutput" + { + "{8062640A-2EEE-46E9-AB67-688E9A886E9F}:_A18D22CB7CF548E99EF4F3A51C564401" + { + "SourcePath" = "8:..\\obj\\Debug\\DebugAddIn.dll" + "TargetName" = "8:" + "Tag" = "8:" + "Folder" = "8:_CDE300ED3B194097AE33ECB71ECE9B7F" + "Condition" = "8:" + "Transitive" = "11:FALSE" + "Vital" = "11:TRUE" + "ReadOnly" = "11:FALSE" + "Hidden" = "11:FALSE" + "System" = "11:FALSE" + "Permanent" = "11:FALSE" + "SharedLegacy" = "11:FALSE" + "PackageAs" = "3:1" + "Register" = "3:1" + "Exclude" = "11:FALSE" + "IsDependency" = "11:FALSE" + "IsolateTo" = "8:" + "ProjectOutputGroupRegister" = "3:2" + "OutputConfiguration" = "8:" + "OutputGroupCanonicalName" = "8:Built" + "OutputProjectGuid" = "8:{535259D0-3BAD-4EA0-8E16-9FC33E98294F}" + "ShowKeyOutput" = "11:TRUE" + "ExcludeFilters" + { + } + } + } + } +} diff --git a/Source/VisualStudio2003/Chapter07/DebugAddIn/ReCreateCommands.reg b/Source/VisualStudio2003/Chapter07/DebugAddIn/ReCreateCommands.reg new file mode 100644 index 0000000..1b4cb3f --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/DebugAddIn/ReCreateCommands.reg @@ -0,0 +1,5 @@ +REGEDIT4 +[HKEY_CURRENT_USER\SOFTWARE\Microsoft\VSA\7.0\PreloadAddinState] +"DebugAddIn.Connect"=dword:1 +[HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\7.0\PreloadAddinState] +"DebugAddIn.Connect"=dword:1 diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter07/NumericTextBox/AssemblyInfo.vb new file mode 100644 index 0000000..8741dfc --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/ControlContainer.resx b/Source/VisualStudio2003/Chapter07/NumericTextBox/ControlContainer.resx new file mode 100644 index 0000000..d10f386 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/ControlContainer.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + ControlContainer + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/ControlContainer.vb b/Source/VisualStudio2003/Chapter07/NumericTextBox/ControlContainer.vb new file mode 100644 index 0000000..bb29be2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/ControlContainer.vb @@ -0,0 +1,66 @@ +Option Strict On + +Public Class ControlContainer + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Switch on control debugging + Me.CustomControl.DebugMode = True + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents CustomControl As DebugDemo.NumericTextBox + Private Sub InitializeComponent() + Me.CustomControl = New DebugDemo.NumericTextBox() + Me.SuspendLayout() + ' + 'CustomControl + ' + Me.CustomControl.DebugMode = False + Me.CustomControl.Location = New System.Drawing.Point(80, 112) + Me.CustomControl.Name = "CustomControl" + Me.CustomControl.TabIndex = 0 + Me.CustomControl.Text = "" + ' + 'ControlContainer + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.CustomControl}) + Me.Name = "ControlContainer" + Me.Text = "Form1" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub ShowDebugMessage(ByVal DebugMethod As String, ByVal DebugComment As String) Handles CustomControl.DebugMessage + 'Show the debug message whenever user types non-numeric character + MsgBox(DebugComment, MsgBoxStyle.OKOnly Or MsgBoxStyle.Information, DebugMethod) + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBox.resx b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBox.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBox.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBox.vb b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBox.vb new file mode 100644 index 0000000..3a73386 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBox.vb @@ -0,0 +1,11 @@ +Imports System.Windows.Forms + +Public Class NumericTextBox : Inherits TextBox + + Private Sub NumericTextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles MyBase.KeyPress + If e.KeyChar < "0"c Or e.KeyChar > "9"c Then + e.Handled = True + End If + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.sln b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.sln new file mode 100644 index 0000000..cc6fb80 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NumericTextBoxTest", "NumericTextBoxTest.vbproj", "{8A595660-BB97-4824-AD3F-43500C201AB4}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8A595660-BB97-4824-AD3F-43500C201AB4}.Debug.ActiveCfg = Debug|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Debug.Build.0 = Debug|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Release.ActiveCfg = Release|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(SolutionItems) = postSolution + ..\DebugDemoControl\NumericTextBox.vb = ..\DebugDemoControl\NumericTextBox.vb + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.sln.old b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.sln.old new file mode 100644 index 0000000..9ee862d --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.sln.old @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "NumericTextBoxTest", "NumericTextBoxTest.vbproj", "{8A595660-BB97-4824-AD3F-43500C201AB4}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {8A595660-BB97-4824-AD3F-43500C201AB4}.Debug.ActiveCfg = Debug|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Debug.Build.0 = Debug|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Release.ActiveCfg = Release|.NET + {8A595660-BB97-4824-AD3F-43500C201AB4}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(SolutionItems) = postSolution + Item:1 = ..\DebugDemoControl\NumericTextBox.vb + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.suo b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.suo new file mode 100644 index 0000000..eb6c42e Binary files /dev/null and b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.suo differ diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj new file mode 100644 index 0000000..4debbda --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj.user b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj.user new file mode 100644 index 0000000..6f2ca04 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/NumericTextBox/NumericTextBoxTest.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/NumericTextBox/obj/Debug/WindowsApplication10.ControlContainer.resources b/Source/VisualStudio2003/Chapter07/NumericTextBox/obj/Debug/WindowsApplication10.ControlContainer.resources new file mode 100644 index 0000000..7d2717a Binary files /dev/null and b/Source/VisualStudio2003/Chapter07/NumericTextBox/obj/Debug/WindowsApplication10.ControlContainer.resources differ diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter07/SortingDebug/AssemblyInfo.vb new file mode 100644 index 0000000..e68a407 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.sln b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.sln new file mode 100644 index 0000000..0992622 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.sln @@ -0,0 +1,35 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoLogic", "SortingDll\DebugDemoLogic.vbproj", "{057FA2D6-5280-4393-BE33-C6631BA07451}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoForm", "DebugDemoForm.vbproj", "{1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}" + ProjectSection(ProjectDependencies) = postProject + {057FA2D6-5280-4393-BE33-C6631BA07451} = {057FA2D6-5280-4393-BE33-C6631BA07451} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + ReleaseCustom = ReleaseCustom + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.ActiveCfg = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.Build.0 = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.ActiveCfg = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.Build.0 = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.ActiveCfg = ReleaseCustom|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.Build.0 = ReleaseCustom|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.ActiveCfg = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.Build.0 = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.Build.0 = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.sln.old b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.sln.old new file mode 100644 index 0000000..b71c4dc --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.sln.old @@ -0,0 +1,33 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoLogic", "SortingDll\DebugDemoLogic.vbproj", "{057FA2D6-5280-4393-BE33-C6631BA07451}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "DebugDemoForm", "DebugDemoForm.vbproj", "{1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + ConfigName.2 = ReleaseCustom + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.0 = {057FA2D6-5280-4393-BE33-C6631BA07451} + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.ActiveCfg = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Debug.Build.0 = Debug|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.ActiveCfg = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.Release.Build.0 = Release|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.ActiveCfg = ReleaseCustom|.NET + {057FA2D6-5280-4393-BE33-C6631BA07451}.ReleaseCustom.Build.0 = ReleaseCustom|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.ActiveCfg = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Debug.Build.0 = Debug|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.Release.Build.0 = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.ActiveCfg = Release|.NET + {1AA3BEBF-5A57-486B-B4E1-84A24B1D5AB9}.ReleaseCustom.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.suo b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.suo new file mode 100644 index 0000000..ab9a81d Binary files /dev/null and b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemo.suo differ diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemoForm.vbproj b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemoForm.vbproj new file mode 100644 index 0000000..fda6517 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemoForm.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemoForm.vbproj.user b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemoForm.vbproj.user new file mode 100644 index 0000000..6f2ca04 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/DebugDemoForm.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DemoForm.resx b/Source/VisualStudio2003/Chapter07/SortingDebug/DemoForm.resx new file mode 100644 index 0000000..363456d --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/DemoForm.resx @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + Assembly + + + True + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + Assembly + + + True + + + DebugDemo + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/DemoForm.vb b/Source/VisualStudio2003/Chapter07/SortingDebug/DemoForm.vb new file mode 100644 index 0000000..cf4ee1a --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/DemoForm.vb @@ -0,0 +1,207 @@ +Public Class DebugDemo + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents lblTwo As System.Windows.Forms.Label + Friend WithEvents lblOne As System.Windows.Forms.Label + Friend WithEvents boxSort As System.Windows.Forms.GroupBox + Friend WithEvents Timing As System.Windows.Forms.Label + Friend WithEvents StartSort As System.Windows.Forms.Button + Friend WithEvents MaxValue As System.Windows.Forms.TextBox + Friend WithEvents NumberItems As System.Windows.Forms.TextBox + Friend WithEvents SortCounting As System.Windows.Forms.RadioButton + Friend WithEvents SortQuick As System.Windows.Forms.RadioButton + Friend WithEvents SortSelection As System.Windows.Forms.RadioButton + Friend WithEvents SortBubble As System.Windows.Forms.RadioButton + Private Sub InitializeComponent() + Me.lblTwo = New System.Windows.Forms.Label() + Me.lblOne = New System.Windows.Forms.Label() + Me.StartSort = New System.Windows.Forms.Button() + Me.MaxValue = New System.Windows.Forms.TextBox() + Me.NumberItems = New System.Windows.Forms.TextBox() + Me.boxSort = New System.Windows.Forms.GroupBox() + Me.SortCounting = New System.Windows.Forms.RadioButton() + Me.SortQuick = New System.Windows.Forms.RadioButton() + Me.SortSelection = New System.Windows.Forms.RadioButton() + Me.SortBubble = New System.Windows.Forms.RadioButton() + Me.Timing = New System.Windows.Forms.Label() + Me.boxSort.SuspendLayout() + Me.SuspendLayout() + ' + 'lblTwo + ' + Me.lblTwo.Location = New System.Drawing.Point(32, 96) + Me.lblTwo.Name = "lblTwo" + Me.lblTwo.Size = New System.Drawing.Size(112, 30) + Me.lblTwo.TabIndex = 14 + Me.lblTwo.Text = "Max item value" + ' + 'lblOne + ' + Me.lblOne.Location = New System.Drawing.Point(32, 40) + Me.lblOne.Name = "lblOne" + Me.lblOne.Size = New System.Drawing.Size(112, 30) + Me.lblOne.TabIndex = 12 + Me.lblOne.Text = "Number of items" + ' + 'StartSort + ' + Me.StartSort.Location = New System.Drawing.Point(280, 285) + Me.StartSort.Name = "StartSort" + Me.StartSort.Size = New System.Drawing.Size(92, 39) + Me.StartSort.TabIndex = 10 + Me.StartSort.Text = "Start sort" + ' + 'MaxValue + ' + Me.MaxValue.Location = New System.Drawing.Point(160, 96) + Me.MaxValue.Name = "MaxValue" + Me.MaxValue.Size = New System.Drawing.Size(72, 22) + Me.MaxValue.TabIndex = 13 + Me.MaxValue.Text = "10000" + ' + 'NumberItems + ' + Me.NumberItems.Location = New System.Drawing.Point(160, 40) + Me.NumberItems.Name = "NumberItems" + Me.NumberItems.Size = New System.Drawing.Size(72, 22) + Me.NumberItems.TabIndex = 11 + Me.NumberItems.Text = "1000" + ' + 'boxSort + ' + Me.boxSort.Controls.AddRange(New System.Windows.Forms.Control() {Me.SortCounting, Me.SortQuick, Me.SortSelection, Me.SortBubble}) + Me.boxSort.Location = New System.Drawing.Point(280, 16) + Me.boxSort.Name = "boxSort" + Me.boxSort.Size = New System.Drawing.Size(232, 247) + Me.boxSort.TabIndex = 9 + Me.boxSort.TabStop = False + Me.boxSort.Text = "Sort algorithm" + ' + 'SortCounting + ' + Me.SortCounting.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortCounting.Location = New System.Drawing.Point(41, 178) + Me.SortCounting.Name = "SortCounting" + Me.SortCounting.Size = New System.Drawing.Size(164, 29) + Me.SortCounting.TabIndex = 3 + Me.SortCounting.Text = "Counting sort" + ' + 'SortQuick + ' + Me.SortQuick.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft + Me.SortQuick.Location = New System.Drawing.Point(41, 128) + Me.SortQuick.Name = "SortQuick" + Me.SortQuick.Size = New System.Drawing.Size(164, 30) + Me.SortQuick.TabIndex = 2 + Me.SortQuick.Text = "Quick sort" + ' + 'SortSelection + ' + Me.SortSelection.Location = New System.Drawing.Point(41, 79) + Me.SortSelection.Name = "SortSelection" + Me.SortSelection.Size = New System.Drawing.Size(164, 30) + Me.SortSelection.TabIndex = 1 + Me.SortSelection.Text = "Selection sort" + ' + 'SortBubble + ' + Me.SortBubble.Checked = True + Me.SortBubble.Location = New System.Drawing.Point(41, 30) + Me.SortBubble.Name = "SortBubble" + Me.SortBubble.Size = New System.Drawing.Size(164, 29) + Me.SortBubble.TabIndex = 0 + Me.SortBubble.TabStop = True + Me.SortBubble.Text = "Bubble sort" + ' + 'Timing + ' + Me.Timing.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.Timing.Location = New System.Drawing.Point(400, 288) + Me.Timing.Name = "Timing" + Me.Timing.Size = New System.Drawing.Size(112, 32) + Me.Timing.TabIndex = 15 + ' + 'DebugDemo + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(544, 348) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Timing, Me.lblTwo, Me.lblOne, Me.StartSort, Me.MaxValue, Me.NumberItems, Me.boxSort}) + Me.Name = "DebugDemo" + Me.Text = "Debug demo" + Me.boxSort.ResumeLayout(False) + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private m_SortType As DemoSort.SortType = DemoSort.SortType.BubbleSort + + Private Sub StartSort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartSort.Click + Dim SortObject As New DemoSort() + + 'Show that we're busy + Cursor.Current = Cursors.WaitCursor + Me.StartSort.Enabled = False + + 'Build a list to sort + Me.Timing.Text = "Building list to sort..." + Me.Timing.Refresh() + SortObject.ListBuild(Convert.ToInt32(Me.NumberItems.Text), 1, Convert.ToInt32(Me.MaxValue.Text)) + + 'Do the sort and report timing + Me.Timing.Text = "Performing sort..." + Me.Timing.Refresh() + Me.Timing.Text = SortObject.DoSort(m_SortType).ToString & " seconds" + + 'Show that we've finished + Me.StartSort.Enabled = True + Cursor.Current = Cursors.Default + + End Sub + + Private Sub SortBubble_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortBubble.CheckedChanged + m_SortType = DemoSort.SortType.BubbleSort + End Sub + + Private Sub SortSelection_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortSelection.CheckedChanged + m_SortType = DemoSort.SortType.SelectionSort + End Sub + + Private Sub SortQuick_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortQuick.CheckedChanged + m_SortType = DemoSort.SortType.QuickSort + End Sub + + Private Sub SortCounting_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SortCounting.CheckedChanged + m_SortType = DemoSort.SortType.CountingSort + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/AssemblyInfo.vb new file mode 100644 index 0000000..240f036 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/AssemblyInfo.vb @@ -0,0 +1,30 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj new file mode 100644 index 0000000..b9cbd77 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj.user b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj.user new file mode 100644 index 0000000..d7b0259 --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DebugDemoLogic.vbproj.user @@ -0,0 +1,64 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DemoSort.vb b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DemoSort.vb new file mode 100644 index 0000000..038eb8a --- /dev/null +++ b/Source/VisualStudio2003/Chapter07/SortingDebug/SortingDll/DemoSort.vb @@ -0,0 +1,265 @@ +Option Strict On + +Public Class DemoSort + + 'These are the sorting lists + Private ListUnsorted() As Int32 + Private ListBeingSorted() As Int32 + 'These are max and minimum sort settings + Private ListLengthMin As Int32 + Private ListLengthMax As Int32 + Private ListValueMin As Int32 + Private ListValueMax As Int32 + + Public Enum SortType As Integer + BubbleSort = 1 + SelectionSort = 2 + QuickSort = 3 + CountingSort = 4 + End Enum + + Public Sub ListBuild(ByVal ListLength As Int32, ByVal ValueMin As Int32, ByVal ValueMax As Int32) + Dim ArrayItem As Int32, objRandom As New System.Random(1) + + 'If parameters haven't changed, just use previous list + 'This enables multiple timing checks on an identical array + If ListLength = ListLengthMax And ValueMin = ListValueMin And ValueMax = ListValueMax Then + Exit Sub + End If + + 'Build a new list with given parameters + ReDim ListUnsorted(ListLength) + For ArrayItem = 1 To ListLength + ListUnsorted(ArrayItem) = objRandom.Next(ValueMin, ValueMax) + Next ArrayItem + + 'Set length of sorted list to match + ReDim ListBeingSorted(ListLength) + + 'Store min and max list items and values + ListLengthMin = 1 + ListLengthMax = ListLength + ListValueMin = ValueMin + ListValueMax = ValueMax + + End Sub + + Public Function DoSort(ByVal Sort As SortType) As Double + Dim TimeStart As Int32, TimeFinish As Int32, ArrayItem As Int32 + + 'Copy to array that will contain newly-sorted list + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ArrayItem) = ListUnsorted(ArrayItem) + Next + + 'Start the clock so we can report how long the sorting took + TimeStart = System.Environment.TickCount() + + 'Do the sort + Select Case Sort + Case SortType.BubbleSort + SortBubble(ListLengthMin, ListLengthMax) + Case SortType.QuickSort + SortQuick(ListLengthMin, ListLengthMax) + Case SortType.SelectionSort + SortSelection() + Case SortType.CountingSort + SortCounting() + Case Else + Trace.Fail(CStr(Sort) & " is an invalid sort type") + End Select + + 'Stop the clock and report how long the sorting took + TimeFinish = System.Environment.TickCount() + 'Check sort + SortCheck() + 'Convert elapsed time into seconds + Return (TimeFinish - TimeStart) / 1000 + + End Function + + Private Sub SortBubble(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim intLastSwap As Int32, intLoop1 As Int32, intLoop2 As Int32 + Dim intDrop As Int32 + + 'Repeat until we are done + Do While ItemLow < ItemHigh + + 'First bubble upwards + intLastSwap = ItemLow - 1 + intLoop1 = ItemLow + 1 + + Do While intLoop1 <= ItemHigh + 'Find a bubble + If ListBeingSorted(intLoop1 - 1) > ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 - 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) < intDrop + ListBeingSorted(intLoop2 - 1) = ListBeingSorted(intLoop2) + intLoop2 += 1 + If intLoop2 > ItemHigh Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 - 1) = intDrop + intLastSwap = intLoop2 - 1 + intLoop1 = intLoop2 + 1 + Else + intLoop1 += 1 + End If + Loop + + 'Update maximum value + ItemHigh = intLastSwap - 1 + + 'Next bubble downwards + intLastSwap = ItemHigh + 1 + intLoop1 = ItemHigh - 1 + + Do While intLoop1 >= ItemLow + 'Find a bubble + If ListBeingSorted(intLoop1 + 1) < ListBeingSorted(intLoop1) Then + 'See where to drop the bubble + intDrop = ListBeingSorted(intLoop1 + 1) + intLoop2 = intLoop1 + Do While ListBeingSorted(intLoop2) > intDrop + ListBeingSorted(intLoop2 + 1) = ListBeingSorted(intLoop2) + intLoop2 -= 1 + If intLoop2 < ItemLow Then + Exit Do + End If + Loop + ListBeingSorted(intLoop2 + 1) = intDrop + intLastSwap = intLoop2 + 1 + intLoop1 = intLoop2 - 1 + Else + intLoop1 -= 1 + End If + Loop + + 'Update minimum value + ItemLow = intLastSwap + 1 + + Loop + + End Sub + + Private Sub SortSelection() + Dim LoopOuter As Int32, LoopInner As Int32, BestValue As Int32, BestInnerIndex As Int32 + + For LoopOuter = ListLengthMin To ListLengthMax - 1 + + 'Init lowest-value search + BestValue = ListBeingSorted(LoopOuter) + BestInnerIndex = LoopOuter + + 'Find lowest value that hasn't already been sorted + For LoopInner = LoopOuter + 1 To ListLengthMax + If ListBeingSorted(LoopInner) < BestValue Then + BestValue = ListBeingSorted(LoopInner) + 1 + BestInnerIndex = LoopInner + End If + Next LoopInner + + 'Swap lowest value into proper position + ListBeingSorted(BestInnerIndex) = ListBeingSorted(LoopOuter) + ListBeingSorted(LoopOuter) = BestValue + + Next LoopOuter + + End Sub + + Private Sub SortQuick(ByVal ItemLow As Int32, ByVal ItemHigh As Int32) + Dim IntermediateValue As Int32, Position As Int32 + Dim objRandom As New System.Random() + Dim intLow As Int32, intHigh As Int32 + + 'If the list has only 1 element, it's already sorted + If ItemLow >= ItemHigh Then Exit Sub + + 'Pick a dividing item + Position = objRandom.Next(ItemLow, ItemHigh) + IntermediateValue = ListBeingSorted(Position) + + 'Swap it to the front so we can find it easily + ListBeingSorted(Position) = ListBeingSorted(ItemLow) + + 'Move the items smaller than this into the left + 'half of the list. Move the others into the right. + intLow = ItemLow + intHigh = ItemHigh + Do + 'Look down from low item for a value < IntermediateValue + Do While ListBeingSorted(intHigh) >= IntermediateValue + intHigh -= 1 + If intHigh <= intLow Then Exit Do + Loop + If intHigh <= intLow Then + ListBeingSorted(intLow) = IntermediateValue + Exit Do + End If + + 'Swap the low and high values + ListBeingSorted(intLow) = ListBeingSorted(intHigh) + + 'Look up from ItemLow for a value >= IntermediateValue + intLow += 1 + Do While ListBeingSorted(intLow) < IntermediateValue + intLow += 1 + If intLow >= intHigh Then Exit Do + Loop + If intLow >= intHigh Then + intLow = intHigh + ListBeingSorted(intHigh) = IntermediateValue + Exit Do + End If + + 'Swap the low and high items + ListBeingSorted(intHigh) = ListBeingSorted(intLow) + Loop + + 'Sort the two sublists recursively + SortQuick(ItemLow, intLow - 1) + SortQuick(intHigh + 1, ItemHigh) + + End Sub + + Private Sub SortCounting() + Dim ListCounts(ListValueMax) As Int32 + Dim ArrayItem As Int32, ThisCount As Int32, NextOffset As Int32 + + 'Count the items + For ArrayItem = ListLengthMin To ListLengthMax + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + 'Convert the ListCounts into offsets + NextOffset = ListLengthMin + For ArrayItem = ListValueMin To ListValueMax + ThisCount = ListCounts(ArrayItem) + ListCounts(ArrayItem) = NextOffset + NextOffset += ThisCount + Next ArrayItem + + 'Place the items in the sorted array + For ArrayItem = ListLengthMin To ListLengthMax + ListBeingSorted(ListCounts(ListUnsorted(ArrayItem))) = ListUnsorted(ArrayItem) + ListCounts(ListUnsorted(ArrayItem)) += 1 + Next ArrayItem + + End Sub + + Private Function SortCheck() As Boolean + Dim ArrayItem As Int32 + + For ArrayItem = 2 To ListLengthMax + If ListBeingSorted(ArrayItem - 1) > ListBeingSorted(ArrayItem) Then + Trace.Fail("Item " & (ArrayItem - 1).ToString & " is larger than item " & ArrayItem.ToString) + Exit For + End If + Next ArrayItem + + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter07/SortingDebug/obj/Debug/DebugDemo.DebugDemo.resources b/Source/VisualStudio2003/Chapter07/SortingDebug/obj/Debug/DebugDemo.DebugDemo.resources new file mode 100644 index 0000000..24379ba Binary files /dev/null and b/Source/VisualStudio2003/Chapter07/SortingDebug/obj/Debug/DebugDemo.DebugDemo.resources differ diff --git a/Source/VisualStudio2003/Chapter08/ReadMe.txt b/Source/VisualStudio2003/Chapter08/ReadMe.txt new file mode 100644 index 0000000..516d70a --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/ReadMe.txt @@ -0,0 +1,13 @@ +To setup the TimeService web service on your IIS web server, +use IIS to create a IIS virtual directory called TimeServer, +pointing at the real folder C:\Inetpub\wwwroot\TimeServer. +This real folder should have been created when you un-zipped +the zip file containing the source code. + +Then in Visual Studio 2003, load the TimeServer solution and set +a web reference to the TimeService web service (using the +Project...Add web reference menu item). The web service can be +found at the ISS virtual directory that you've just created. + + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServer.sln b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServer.sln new file mode 100644 index 0000000..6403331 --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServer.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServer", "http://localhost/TimeServer/TimeServer.vbproj", "{1BB5B66C-C66B-474D-BE43-03E212F5DF3F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServerClient", "TimeServerClient\TimeServerClient.vbproj", "{B2064CD5-D49D-4BF7-B31E-57025D69727C}" + ProjectSection(ProjectDependencies) = postProject + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F} = {1BB5B66C-C66B-474D-BE43-03E212F5DF3F} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.ActiveCfg = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.Build.0 = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.ActiveCfg = Release|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.Build.0 = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.ActiveCfg = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.Build.0 = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.ActiveCfg = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServer.suo b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServer.suo new file mode 100644 index 0000000..896e3e9 Binary files /dev/null and b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServer.suo differ diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/AssemblyInfo.vb new file mode 100644 index 0000000..30e9959 --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.resx b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.resx new file mode 100644 index 0000000..323365d --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + ClientForm + + + 80 + + + True + + + Assembly + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.vb b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.vb new file mode 100644 index 0000000..3a537ca --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/ClientForm.vb @@ -0,0 +1,206 @@ +Option Strict On +Imports System.Windows.Forms + +Public Class ClientForm : Inherits System.Windows.Forms.Form + + Private m_TimeTest As localhost.TimeService + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents GetTime As System.Windows.Forms.Button + Friend WithEvents ShowTime As System.Windows.Forms.Label + Friend WithEvents ProxyDebugDemo As System.Windows.Forms.Button + Friend WithEvents TriggerRawException As System.Windows.Forms.Button + Friend WithEvents TriggerCustomException As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.GetTime = New System.Windows.Forms.Button + Me.ShowTime = New System.Windows.Forms.Label + Me.ProxyDebugDemo = New System.Windows.Forms.Button + Me.TriggerRawException = New System.Windows.Forms.Button + Me.TriggerCustomException = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'GetTime + ' + Me.GetTime.Location = New System.Drawing.Point(40, 40) + Me.GetTime.Name = "GetTime" + Me.GetTime.Size = New System.Drawing.Size(160, 56) + Me.GetTime.TabIndex = 0 + Me.GetTime.Text = "Test time retrieval" + ' + 'ShowTime + ' + Me.ShowTime.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.ShowTime.Location = New System.Drawing.Point(240, 48) + Me.ShowTime.Name = "ShowTime" + Me.ShowTime.Size = New System.Drawing.Size(128, 48) + Me.ShowTime.TabIndex = 1 + ' + 'ProxyDebugDemo + ' + Me.ProxyDebugDemo.Location = New System.Drawing.Point(40, 120) + Me.ProxyDebugDemo.Name = "ProxyDebugDemo" + Me.ProxyDebugDemo.Size = New System.Drawing.Size(160, 56) + Me.ProxyDebugDemo.TabIndex = 2 + Me.ProxyDebugDemo.Text = "Demo proxy debugging" + ' + 'TriggerRawException + ' + Me.TriggerRawException.Location = New System.Drawing.Point(40, 200) + Me.TriggerRawException.Name = "TriggerRawException" + Me.TriggerRawException.Size = New System.Drawing.Size(160, 56) + Me.TriggerRawException.TabIndex = 4 + Me.TriggerRawException.Text = "Trigger raw exception" + ' + 'TriggerCustomException + ' + Me.TriggerCustomException.Location = New System.Drawing.Point(40, 280) + Me.TriggerCustomException.Name = "TriggerCustomException" + Me.TriggerCustomException.Size = New System.Drawing.Size(160, 56) + Me.TriggerCustomException.TabIndex = 5 + Me.TriggerCustomException.Text = "Trigger custom exception" + ' + 'ClientForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(432, 396) + Me.Controls.Add(Me.TriggerCustomException) + Me.Controls.Add(Me.TriggerRawException) + Me.Controls.Add(Me.ProxyDebugDemo) + Me.Controls.Add(Me.ShowTime) + Me.Controls.Add(Me.GetTime) + Me.Name = "ClientForm" + Me.Text = "TimeServer client" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub ClientForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Create web service instance (via proxy) and + 'ensure timeout never happens during debugging + m_TimeTest = New localhost.TimeService +#If DEBUG Then + m_TimeTest.Timeout = -1 +#End If + + End Sub + + Private Sub GetTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetTime.Click + 'Get time details + Me.ShowTime.Text = m_TimeTest.CurrentTime + + End Sub + + Private Sub ProxyDebugDemo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyDebugDemo.Click + 'Trigger exception without catching it + 'Ensure proxy has DebuggerStepthroughAttribute removed + 'This exception will then break into the debugger + m_TimeTest.ThrowExceptionRaw() + + End Sub + + Private Sub TriggerRawException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerRawException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger raw exception and show it + Try + m_TimeTest.ThrowExceptionRaw() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage += "RECEIVED EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .GetType.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .StackTrace + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + End With + + MessageBox.Show(ExceptionMessage, "Web service raw exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub TriggerCustomException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerCustomException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger custom exception and show it + Try + m_TimeTest.ThrowExceptionCustom() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage = "ORIGINAL EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionType").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionMessage").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionTrace").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Raw SOAP message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + End With + + MessageBox.Show(ExceptionMessage, "Web service custom exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub ClientForm_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed + 'Close web service instance + m_TimeTest.Dispose() + m_TimeTest = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj new file mode 100644 index 0000000..487e33a --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj.user b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj.user new file mode 100644 index 0000000..9a7fdd0 --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/TimeServerClient.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources new file mode 100644 index 0000000..50edb59 Binary files /dev/null and b/Source/VisualStudio2003/Chapter08/TimeServerBrowserClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources differ diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServer.sln b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServer.sln new file mode 100644 index 0000000..6403331 --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServer.sln @@ -0,0 +1,30 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServer", "http://localhost/TimeServer/TimeServer.vbproj", "{1BB5B66C-C66B-474D-BE43-03E212F5DF3F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "TimeServerClient", "TimeServerClient\TimeServerClient.vbproj", "{B2064CD5-D49D-4BF7-B31E-57025D69727C}" + ProjectSection(ProjectDependencies) = postProject + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F} = {1BB5B66C-C66B-474D-BE43-03E212F5DF3F} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.ActiveCfg = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Debug.Build.0 = Debug|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.ActiveCfg = Release|.NET + {1BB5B66C-C66B-474D-BE43-03E212F5DF3F}.Release.Build.0 = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.ActiveCfg = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Debug.Build.0 = Debug|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.ActiveCfg = Release|.NET + {B2064CD5-D49D-4BF7-B31E-57025D69727C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServer.suo b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServer.suo new file mode 100644 index 0000000..093194e Binary files /dev/null and b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServer.suo differ diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/AssemblyInfo.vb new file mode 100644 index 0000000..30e9959 --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.resx b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.resx new file mode 100644 index 0000000..323365d --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.resx @@ -0,0 +1,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + ClientForm + + + 80 + + + True + + + Assembly + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.vb b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.vb new file mode 100644 index 0000000..3a537ca --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/ClientForm.vb @@ -0,0 +1,206 @@ +Option Strict On +Imports System.Windows.Forms + +Public Class ClientForm : Inherits System.Windows.Forms.Form + + Private m_TimeTest As localhost.TimeService + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents GetTime As System.Windows.Forms.Button + Friend WithEvents ShowTime As System.Windows.Forms.Label + Friend WithEvents ProxyDebugDemo As System.Windows.Forms.Button + Friend WithEvents TriggerRawException As System.Windows.Forms.Button + Friend WithEvents TriggerCustomException As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.GetTime = New System.Windows.Forms.Button + Me.ShowTime = New System.Windows.Forms.Label + Me.ProxyDebugDemo = New System.Windows.Forms.Button + Me.TriggerRawException = New System.Windows.Forms.Button + Me.TriggerCustomException = New System.Windows.Forms.Button + Me.SuspendLayout() + ' + 'GetTime + ' + Me.GetTime.Location = New System.Drawing.Point(40, 40) + Me.GetTime.Name = "GetTime" + Me.GetTime.Size = New System.Drawing.Size(160, 56) + Me.GetTime.TabIndex = 0 + Me.GetTime.Text = "Test time retrieval" + ' + 'ShowTime + ' + Me.ShowTime.FlatStyle = System.Windows.Forms.FlatStyle.Popup + Me.ShowTime.Location = New System.Drawing.Point(240, 48) + Me.ShowTime.Name = "ShowTime" + Me.ShowTime.Size = New System.Drawing.Size(128, 48) + Me.ShowTime.TabIndex = 1 + ' + 'ProxyDebugDemo + ' + Me.ProxyDebugDemo.Location = New System.Drawing.Point(40, 120) + Me.ProxyDebugDemo.Name = "ProxyDebugDemo" + Me.ProxyDebugDemo.Size = New System.Drawing.Size(160, 56) + Me.ProxyDebugDemo.TabIndex = 2 + Me.ProxyDebugDemo.Text = "Demo proxy debugging" + ' + 'TriggerRawException + ' + Me.TriggerRawException.Location = New System.Drawing.Point(40, 200) + Me.TriggerRawException.Name = "TriggerRawException" + Me.TriggerRawException.Size = New System.Drawing.Size(160, 56) + Me.TriggerRawException.TabIndex = 4 + Me.TriggerRawException.Text = "Trigger raw exception" + ' + 'TriggerCustomException + ' + Me.TriggerCustomException.Location = New System.Drawing.Point(40, 280) + Me.TriggerCustomException.Name = "TriggerCustomException" + Me.TriggerCustomException.Size = New System.Drawing.Size(160, 56) + Me.TriggerCustomException.TabIndex = 5 + Me.TriggerCustomException.Text = "Trigger custom exception" + ' + 'ClientForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(432, 396) + Me.Controls.Add(Me.TriggerCustomException) + Me.Controls.Add(Me.TriggerRawException) + Me.Controls.Add(Me.ProxyDebugDemo) + Me.Controls.Add(Me.ShowTime) + Me.Controls.Add(Me.GetTime) + Me.Name = "ClientForm" + Me.Text = "TimeServer client" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub ClientForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load + 'Create web service instance (via proxy) and + 'ensure timeout never happens during debugging + m_TimeTest = New localhost.TimeService +#If DEBUG Then + m_TimeTest.Timeout = -1 +#End If + + End Sub + + Private Sub GetTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GetTime.Click + 'Get time details + Me.ShowTime.Text = m_TimeTest.CurrentTime + + End Sub + + Private Sub ProxyDebugDemo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProxyDebugDemo.Click + 'Trigger exception without catching it + 'Ensure proxy has DebuggerStepthroughAttribute removed + 'This exception will then break into the debugger + m_TimeTest.ThrowExceptionRaw() + + End Sub + + Private Sub TriggerRawException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerRawException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger raw exception and show it + Try + m_TimeTest.ThrowExceptionRaw() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage += "RECEIVED EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .GetType.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .StackTrace + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + End With + + MessageBox.Show(ExceptionMessage, "Web service raw exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub TriggerCustomException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TriggerCustomException.Click + Dim ExceptionMessage As String, Sep As String = Space$(4) + 'Trigger custom exception and show it + Try + m_TimeTest.ThrowExceptionCustom() + + Catch SoapExc As System.Web.Services.Protocols.SoapException + + With SoapExc + ExceptionMessage = "ORIGINAL EXCEPTION INFORMATION" + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Type: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionType").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Message: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionMessage").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Stack trace: " & Environment.NewLine + ExceptionMessage += Sep & .Detail("ExceptionTrace").InnerText + ExceptionMessage += Environment.NewLine + ExceptionMessage += "SOAP fault: " & Environment.NewLine + ExceptionMessage += Sep & .Code.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Web service URL: " & Environment.NewLine + ExceptionMessage += Sep & .Actor.ToString + ExceptionMessage += Environment.NewLine + ExceptionMessage += "Raw SOAP message: " & Environment.NewLine + ExceptionMessage += Sep & .Message + End With + + MessageBox.Show(ExceptionMessage, "Web service custom exception", MessageBoxButtons.OK) + + End Try + + End Sub + + Private Sub ClientForm_Closed(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Closed + 'Close web service instance + m_TimeTest.Dispose() + m_TimeTest = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj new file mode 100644 index 0000000..487e33a --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj.user b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj.user new file mode 100644 index 0000000..9a7fdd0 --- /dev/null +++ b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/TimeServerClient.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources new file mode 100644 index 0000000..50edb59 Binary files /dev/null and b/Source/VisualStudio2003/Chapter08/TimeServerSoapClient/TimeServerClient/obj/Debug/TimeServerClient.ClientForm.resources differ diff --git a/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/AspNetDebugDemo.sln b/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/AspNetDebugDemo.sln new file mode 100644 index 0000000..d5ac44e --- /dev/null +++ b/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/AspNetDebugDemo.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "AspNetDebugDemo", "http://localhost/AspNetDebugDemo/AspNetDebugDemo.vbproj", "{135C30F3-6B37-4B7D-BC76-0EEF97726826}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Debug.ActiveCfg = Debug|.NET + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Debug.Build.0 = Debug|.NET + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Release.ActiveCfg = Release|.NET + {135C30F3-6B37-4B7D-BC76-0EEF97726826}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/AspNetDebugDemo.suo b/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/AspNetDebugDemo.suo new file mode 100644 index 0000000..9d8c888 Binary files /dev/null and b/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/AspNetDebugDemo.suo differ diff --git a/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/ReadMe.txt b/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/ReadMe.txt new file mode 100644 index 0000000..5963a3d --- /dev/null +++ b/Source/VisualStudio2003/Chapter09/AspNetDebugDemo/ReadMe.txt @@ -0,0 +1,10 @@ +To setup the AspNetDebugDemo application on your IIS web server, +use IIS to create a IIS virtual directory called AspNetDebugDemo, +pointing at the real folder C:\Inetpub\wwwroot\AspNetDebugDemo. +This real folder should have been created when you un-zipped +the zip file containing the source code. + +Then in Visual Studio 2003, load the AspNetDebugDemo solution. + + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter10/DebugOnStart/AssemblyInfo.vb new file mode 100644 index 0000000..64988a1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/Client.vb b/Source/VisualStudio2003/Chapter10/DebugOnStart/Client.vb new file mode 100644 index 0000000..601e85c --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/Client.vb @@ -0,0 +1,130 @@ +Option Strict On + +Imports System.Net +Imports System.Text +Imports System.Threading +Imports System +Imports System.IO +Imports System.ServiceProcess + +Public Class Client + + Private ThisClient As Sockets.Socket = Nothing + Private ReadBuffer(16384) As Byte + Private PageBuffer(16384) As Byte + Private EmptyBuffer() As Byte = Encoding.ASCII.GetBytes(Space$(1024)) + + Public Sub New(ByVal NewClient As Sockets.Socket) + + Me.ThisClient = NewClient + + End Sub + + Public Sub Start() + Dim HtmlStream As StreamReader, PageRequest As String, PageText As String + + Try + Me.ThisClient.Receive(Me.ReadBuffer, Me.ReadBuffer.Length, Sockets.SocketFlags.None) + PageRequest = ReturnPage(Encoding.ASCII.GetString(Me.ReadBuffer)) + 'Open requested page + HtmlStream = New StreamReader(PageRequest) + PageText = HtmlStream.ReadToEnd() + HtmlStream.Close() + 'If status page, display services + PageText = PageText.Replace("#1#", Environment.MachineName & " (" & Me.ThisClient.LocalEndPoint.ToString & ")") + PageText = PageText.Replace("#2#", Me.DisplayServices) + 'Display requested page + Trace.WriteLine("Sending page " & PageRequest) + Me.PageBuffer = Encoding.ASCII.GetBytes(PageText) + Me.ThisClient.Send(Me.PageBuffer, Me.PageBuffer.Length, Sockets.SocketFlags.None) + Me.Close() + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + Close() + + End Try + + End Sub + + Private Function ReturnPage(ByVal PageRequest As String) As String + Dim HtmlPage As String, IndexStart As Int32, IndexEnd As Int32 + + 'Extract page + IndexStart = InStr(PageRequest, "/") + 1 + IndexEnd = InStr(IndexStart, PageRequest, " ") + HtmlPage = Mid$(PageRequest, IndexStart, IndexEnd - IndexStart) + 'add suffix if necessary + If Right$(HtmlPage, 5) <> ".html" Then + HtmlPage += ".html" + End If + 'Add local path + HtmlPage = Me.ReturnPath & HtmlPage + 'Check page exists + If File.Exists(HtmlPage) = False Then + HtmlPage = Me.ReturnPath & "error.html" + End If + 'Return page + Trace.WriteLine("Page requested: " & HtmlPage) + Return HtmlPage + + End Function + + Private Function ReturnPath() As String + + If Right$(AppDomain.CurrentDomain.BaseDirectory, 1) = "\" Then + Return AppDomain.CurrentDomain.BaseDirectory + Else + Return AppDomain.CurrentDomain.BaseDirectory & "\" + End If + + End Function + + Private Function DisplayServices() As String + Dim ThisService As ServiceController, TempPage As String + + For Each ThisService In ServiceController.GetServices + TempPage += "" & Environment.NewLine + 'Add service name + TempPage += "
" + TempPage += ThisService.ServiceName & "
" & Environment.NewLine + 'Add service friendly name + TempPage += "
" + TempPage += ThisService.DisplayName & "
" & Environment.NewLine + 'Add service status + TempPage += "
" + TempPage += ThisService.Status.ToString & "
" & Environment.NewLine + TempPage += "" & Environment.NewLine + 'Finished with this service + ThisService.Dispose() + Next + + Return TempPage + + End Function + + Public Function IsConnected() As Boolean + + If Me.ThisClient Is Nothing Then + Return False + Else + Return Me.ThisClient.Connected + End If + + End Function + + Public Sub Close() + + If Not (Me.ThisClient Is Nothing) Then + Trace.WriteLine("Closing client socket") + Me.ThisClient.Shutdown(Sockets.SocketShutdown.Both) + Me.ThisClient.Close() + Me.ThisClient = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/DummyService.resx b/Source/VisualStudio2003/Chapter10/DebugOnStart/DummyService.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/DummyService.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/DummyService.vb b/Source/VisualStudio2003/Chapter10/DebugOnStart/DummyService.vb new file mode 100644 index 0000000..6d34e4f --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/DummyService.vb @@ -0,0 +1,50 @@ +Option Strict On +Imports System.ServiceProcess +Imports System.Threading + +Public Class DummyService : Inherits System.ServiceProcess.ServiceBase + + +#Region " Component Designer generated code " + + Public Sub New() + MyBase.New() + + ' This call is required by the Component Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call + + End Sub + + 'UserService overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' The main entry point for the process + _ + Shared Sub Main() + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container() + Me.ServiceName = "DummyService" + End Sub + +#End Region + + +End Class diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ProjectInstaller.resx b/Source/VisualStudio2003/Chapter10/DebugOnStart/ProjectInstaller.resx new file mode 100644 index 0000000..142cb5c --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/ProjectInstaller.resx @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Assembly + + + 17, 17 + + + Assembly + + + Assembly + + + 211, 17 + + + Assembly + + + Assembly + + + 360, 17 + + + ProjectInstaller + + + Assembly + + + False + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ProjectInstaller.vb b/Source/VisualStudio2003/Chapter10/DebugOnStart/ProjectInstaller.vb new file mode 100644 index 0000000..98ed79d --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/ProjectInstaller.vb @@ -0,0 +1,89 @@ +Imports System.ComponentModel +Imports System.Configuration.Install +Imports Microsoft.Win32 + + Public Class ProjectInstaller + Inherits System.Configuration.Install.Installer + +#Region " Component Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Installer overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller + Friend WithEvents ServiceInstaller2 As System.ServiceProcess.ServiceInstaller + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller + Me.ServiceInstaller2 = New System.ServiceProcess.ServiceInstaller + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.ServiceName = "ServiceAdmin" + ' + 'ServiceInstaller2 + ' + Me.ServiceInstaller2.ServiceName = "DummyService" + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1, Me.ServiceInstaller2}) + + End Sub + +#End Region + + Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) + + 'First do the install + MyBase.Install(stateSaver) + + 'System.Diagnostics.Debugger.Launch() + + Dim SystemKey As RegistryKey = Registry.LocalMachine.OpenSubKey("System") + Dim ControlSetKey As RegistryKey = SystemKey.OpenSubKey("CurrentControlSet") + Dim ServicesKey As RegistryKey = ControlSetKey.OpenSubKey("Services") + Dim ServiceKey As RegistryKey = ServicesKey.OpenSubKey(Me.ServiceInstaller1.ServiceName, True) + + 'Set the service description + ServiceKey.SetValue("Description", "Allows remote service administration") + + 'Cleanup + ServiceKey.Close() + ServicesKey.Close() + ControlSetKey.Close() + SystemKey.Close() + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/Service.resx b/Source/VisualStudio2003/Chapter10/DebugOnStart/Service.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/Service.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/Service.vb b/Source/VisualStudio2003/Chapter10/DebugOnStart/Service.vb new file mode 100644 index 0000000..5c3fc82 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/Service.vb @@ -0,0 +1,82 @@ +Option Strict On +Imports System.ServiceProcess + +Public Class ServiceAdmin : Inherits System.ServiceProcess.ServiceBase + +#Region " Component Designer generated code " + + Private Listener As ServiceListener = Nothing + + Public Sub New() + MyBase.New() + + ' This call is required by the Component Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call + + End Sub + + 'UserService overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' The main entry point for the process + _ + Shared Sub Main() + +#If DEBUG Then + Dim DebugService As New ServiceAdmin + DebugService.OnStart(Nothing) +#Else + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + 'The following line instantiates just your service + 'ServicesToRun = New ServiceBase() {New ServiceAdmin()} + + 'The following line (instead of the previous line) additionally instantiates a dummy service within the same + 'process as your real service. Starting the dummy service allows you to attach to the service process - then + 'you can debug your service's OnStart method by setting a breakpoint before starting your service. + ServicesToRun = New ServiceBase() {New ServiceAdmin, New DummyService} + + 'Start the service + ServiceBase.Run(ServicesToRun) +#End If + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container + Me.ServiceName = "ServiceAdmin" + End Sub + +#End Region + + Protected Overrides Sub OnStart(ByVal args() As String) + + Me.Listener = New ServiceListener + Me.Listener.Start() + + End Sub + + Protected Overrides Sub OnStop() + + If Not (Me.Listener Is Nothing) Then + Me.Listener.Close() + Me.Listener = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.sln b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.sln new file mode 100644 index 0000000..fe31dc5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ServiceAdmin", "ServiceAdmin.vbproj", "{A7151D9F-543D-46BF-B098-49E2616B8F05}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.ActiveCfg = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.Build.0 = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.ActiveCfg = Release|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.suo b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.suo new file mode 100644 index 0000000..ac05350 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.suo differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.vbproj b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.vbproj new file mode 100644 index 0000000..b367c02 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.vbproj @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.vbproj.user b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.vbproj.user new file mode 100644 index 0000000..7136437 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceAdmin.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceListener.vb b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceListener.vb new file mode 100644 index 0000000..2dcaa2e --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/ServiceListener.vb @@ -0,0 +1,92 @@ +Option Strict On + +Imports System.Threading +Imports System.Net + +Public Class ServiceListener + + Private ListenThread As Thread = Nothing + Private ThreadExit As Boolean = False + Private Clients As ArrayList = New ArrayList + + Public Sub New() + + End Sub + + Public Sub Start() + + If Me.ListenThread Is Nothing Then + Me.ThreadExit = False + Me.ListenThread = New Thread(New ThreadStart(AddressOf ListeningThread)) + Me.ListenThread.Start() + Else + Throw New InvalidOperationException("Listener thread already started") + End If + + End Sub + + Private Sub ListeningThread() + Dim MyTcpListener As Sockets.TcpListener = Nothing + Dim LocalAddress As Net.IPAddress = IPAddress.Any + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Try + MyTcpListener = New Sockets.TcpListener(LocalAddress, 5005) + MyTcpListener.Start() + Trace.WriteLine("Listening thread starting on " & MyTcpListener.LocalEndpoint.ToString) + + While Me.ThreadExit = False + Thread.Sleep(500) + If MyTcpListener.Pending = True Then + Trace.WriteLine(Environment.NewLine & "Connecting new client") + ThisClient = New Client(MyTcpListener.AcceptSocket()) + Clients.Add(ThisClient) + ThisClient.Start() + Else + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + If ThisClient.IsConnected = False Then + Trace.WriteLine("Performing client cleanup") + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + End If + Next + End If + End While + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + + Finally + Trace.WriteLine("Listen thread ending...") + If Not (MyTcpListener Is Nothing) Then + MyTcpListener.Stop() + End If + Trace.WriteLine("Listen thread ended") + + End Try + + End Sub + + Public Sub Close() + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Me.ThreadExit = True + 'Pause to process pending requests and do cleanup + Thread.Sleep(1000) + 'Time to die + If Me.ListenThread.IsAlive Then + Me.ListenThread.Abort() + Me.ListenThread = Nothing + End If + 'Dump any client still connected! + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + Next + Me.Clients = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/bin/error.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/bin/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/bin/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/bin/status.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/bin/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/bin/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/error.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.DummyService.resources b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.DummyService.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.DummyService.resources differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ProjectInstaller.resources b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ProjectInstaller.resources new file mode 100644 index 0000000..9414ab0 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ProjectInstaller.resources differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ServiceAdmin.resources b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ServiceAdmin.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/ServiceAdmin.ServiceAdmin.resources differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/error.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/status.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Debug/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.DummyService.resources b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.DummyService.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.DummyService.resources differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ProjectInstaller.resources b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ProjectInstaller.resources new file mode 100644 index 0000000..9414ab0 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ProjectInstaller.resources differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ServiceAdmin.resources b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ServiceAdmin.resources new file mode 100644 index 0000000..d42e555 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/ServiceAdmin.ServiceAdmin.resources differ diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/error.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/status.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/obj/Release/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2003/Chapter10/DebugOnStart/status.html b/Source/VisualStudio2003/Chapter10/DebugOnStart/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/DebugOnStart/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter10/ServiceAdmin/AssemblyInfo.vb new file mode 100644 index 0000000..64988a1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/Client.vb b/Source/VisualStudio2003/Chapter10/ServiceAdmin/Client.vb new file mode 100644 index 0000000..601e85c --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/Client.vb @@ -0,0 +1,130 @@ +Option Strict On + +Imports System.Net +Imports System.Text +Imports System.Threading +Imports System +Imports System.IO +Imports System.ServiceProcess + +Public Class Client + + Private ThisClient As Sockets.Socket = Nothing + Private ReadBuffer(16384) As Byte + Private PageBuffer(16384) As Byte + Private EmptyBuffer() As Byte = Encoding.ASCII.GetBytes(Space$(1024)) + + Public Sub New(ByVal NewClient As Sockets.Socket) + + Me.ThisClient = NewClient + + End Sub + + Public Sub Start() + Dim HtmlStream As StreamReader, PageRequest As String, PageText As String + + Try + Me.ThisClient.Receive(Me.ReadBuffer, Me.ReadBuffer.Length, Sockets.SocketFlags.None) + PageRequest = ReturnPage(Encoding.ASCII.GetString(Me.ReadBuffer)) + 'Open requested page + HtmlStream = New StreamReader(PageRequest) + PageText = HtmlStream.ReadToEnd() + HtmlStream.Close() + 'If status page, display services + PageText = PageText.Replace("#1#", Environment.MachineName & " (" & Me.ThisClient.LocalEndPoint.ToString & ")") + PageText = PageText.Replace("#2#", Me.DisplayServices) + 'Display requested page + Trace.WriteLine("Sending page " & PageRequest) + Me.PageBuffer = Encoding.ASCII.GetBytes(PageText) + Me.ThisClient.Send(Me.PageBuffer, Me.PageBuffer.Length, Sockets.SocketFlags.None) + Me.Close() + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + Close() + + End Try + + End Sub + + Private Function ReturnPage(ByVal PageRequest As String) As String + Dim HtmlPage As String, IndexStart As Int32, IndexEnd As Int32 + + 'Extract page + IndexStart = InStr(PageRequest, "/") + 1 + IndexEnd = InStr(IndexStart, PageRequest, " ") + HtmlPage = Mid$(PageRequest, IndexStart, IndexEnd - IndexStart) + 'add suffix if necessary + If Right$(HtmlPage, 5) <> ".html" Then + HtmlPage += ".html" + End If + 'Add local path + HtmlPage = Me.ReturnPath & HtmlPage + 'Check page exists + If File.Exists(HtmlPage) = False Then + HtmlPage = Me.ReturnPath & "error.html" + End If + 'Return page + Trace.WriteLine("Page requested: " & HtmlPage) + Return HtmlPage + + End Function + + Private Function ReturnPath() As String + + If Right$(AppDomain.CurrentDomain.BaseDirectory, 1) = "\" Then + Return AppDomain.CurrentDomain.BaseDirectory + Else + Return AppDomain.CurrentDomain.BaseDirectory & "\" + End If + + End Function + + Private Function DisplayServices() As String + Dim ThisService As ServiceController, TempPage As String + + For Each ThisService In ServiceController.GetServices + TempPage += "" & Environment.NewLine + 'Add service name + TempPage += "
" + TempPage += ThisService.ServiceName & "
" & Environment.NewLine + 'Add service friendly name + TempPage += "
" + TempPage += ThisService.DisplayName & "
" & Environment.NewLine + 'Add service status + TempPage += "
" + TempPage += ThisService.Status.ToString & "
" & Environment.NewLine + TempPage += "" & Environment.NewLine + 'Finished with this service + ThisService.Dispose() + Next + + Return TempPage + + End Function + + Public Function IsConnected() As Boolean + + If Me.ThisClient Is Nothing Then + Return False + Else + Return Me.ThisClient.Connected + End If + + End Function + + Public Sub Close() + + If Not (Me.ThisClient Is Nothing) Then + Trace.WriteLine("Closing client socket") + Me.ThisClient.Shutdown(Sockets.SocketShutdown.Both) + Me.ThisClient.Close() + Me.ThisClient = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ProjectInstaller.resx b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ProjectInstaller.resx new file mode 100644 index 0000000..482e83e --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ProjectInstaller.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Assembly + + + 17, 17 + + + Assembly + + + Assembly + + + 211, 17 + + + ProjectInstaller + + + Assembly + + + False + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ProjectInstaller.vb b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ProjectInstaller.vb new file mode 100644 index 0000000..4c0d513 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ProjectInstaller.vb @@ -0,0 +1,83 @@ +Imports System.ComponentModel +Imports System.Configuration.Install +Imports Microsoft.Win32 + + Public Class ProjectInstaller + Inherits System.Configuration.Install.Installer + +#Region " Component Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Component Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Installer overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Component Designer + 'It can be modified using the Component Designer. + 'Do not modify it using the code editor. + Friend WithEvents ServiceProcessInstaller1 As System.ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As System.ServiceProcess.ServiceInstaller + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.ServiceName = "ServiceAdmin" + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) + + End Sub + +#End Region + + Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary) + + 'First do the install + MyBase.Install(stateSaver) + + 'System.Diagnostics.Debugger.Launch() + + Dim SystemKey As RegistryKey = Registry.LocalMachine.OpenSubKey("System") + Dim ControlSetKey As RegistryKey = SystemKey.OpenSubKey("CurrentControlSet") + Dim ServicesKey As RegistryKey = ControlSetKey.OpenSubKey("Services") + Dim ServiceKey As RegistryKey = ServicesKey.OpenSubKey(Me.ServiceInstaller1.ServiceName, True) + + 'Set the service description + ServiceKey.SetValue("Description", "Allows remote service administration") + + 'Cleanup + ServiceKey.Close() + ServicesKey.Close() + ControlSetKey.Close() + SystemKey.Close() + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/Service.resx b/Source/VisualStudio2003/Chapter10/ServiceAdmin/Service.resx new file mode 100644 index 0000000..df79c33 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/Service.resx @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.0.0.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/Service.vb b/Source/VisualStudio2003/Chapter10/ServiceAdmin/Service.vb new file mode 100644 index 0000000..caf9754 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/Service.vb @@ -0,0 +1,82 @@ +Option Strict On +Imports System.ServiceProcess + +Public Class ServiceAdmin : Inherits System.ServiceProcess.ServiceBase + +#Region " Component Designer generated code " + + Private Listener As ServiceListener = Nothing + + Public Sub New() + MyBase.New() + + ' This call is required by the Component Designer. + InitializeComponent() + + ' Add any initialization after the InitializeComponent() call + + End Sub + + 'UserService overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + ' The main entry point for the process + _ + Shared Sub Main() + +#If DEBUG Then + Dim DebugService As New ServiceAdmin + DebugService.OnStart(Nothing) +#Else + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + 'The following line instantiates just your service + ServicesToRun = New ServiceBase() {New ServiceAdmin()} + + 'The following line (instead of the previous line) additionally instantiates a dummy service within the same + 'process as your real service. Starting the dummy service allows you to attach to the service process - then + 'you can debug your service's OnStart method by setting a breakpoint before starting your service. + 'ServicesToRun = New ServiceBase() {New ServiceAdmin(), New DummyService()} + + 'Start the service + ServiceBase.Run(ServicesToRun) +#End If + + End Sub + + 'Required by the Component Designer + Private components As System.ComponentModel.IContainer + + ' NOTE: The following procedure is required by the Component Designer + ' It can be modified using the Component Designer. + ' Do not modify it using the code editor. + Private Sub InitializeComponent() + components = New System.ComponentModel.Container + Me.ServiceName = "ServiceAdmin" + End Sub + +#End Region + + Protected Overrides Sub OnStart(ByVal args() As String) + + Me.Listener = New ServiceListener + Me.Listener.Start() + + End Sub + + Protected Overrides Sub OnStop() + + If Not (Me.Listener Is Nothing) Then + Me.Listener.Close() + Me.Listener = Nothing + End If + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.sln b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.sln new file mode 100644 index 0000000..fe31dc5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ServiceAdmin", "ServiceAdmin.vbproj", "{A7151D9F-543D-46BF-B098-49E2616B8F05}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.ActiveCfg = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Debug.Build.0 = Debug|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.ActiveCfg = Release|.NET + {A7151D9F-543D-46BF-B098-49E2616B8F05}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.suo b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.suo new file mode 100644 index 0000000..85d9970 Binary files /dev/null and b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.suo differ diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.vbproj b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.vbproj new file mode 100644 index 0000000..03387c2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.vbproj @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.vbproj.user b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceAdmin.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceListener.vb b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceListener.vb new file mode 100644 index 0000000..2dcaa2e --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/ServiceListener.vb @@ -0,0 +1,92 @@ +Option Strict On + +Imports System.Threading +Imports System.Net + +Public Class ServiceListener + + Private ListenThread As Thread = Nothing + Private ThreadExit As Boolean = False + Private Clients As ArrayList = New ArrayList + + Public Sub New() + + End Sub + + Public Sub Start() + + If Me.ListenThread Is Nothing Then + Me.ThreadExit = False + Me.ListenThread = New Thread(New ThreadStart(AddressOf ListeningThread)) + Me.ListenThread.Start() + Else + Throw New InvalidOperationException("Listener thread already started") + End If + + End Sub + + Private Sub ListeningThread() + Dim MyTcpListener As Sockets.TcpListener = Nothing + Dim LocalAddress As Net.IPAddress = IPAddress.Any + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Try + MyTcpListener = New Sockets.TcpListener(LocalAddress, 5005) + MyTcpListener.Start() + Trace.WriteLine("Listening thread starting on " & MyTcpListener.LocalEndpoint.ToString) + + While Me.ThreadExit = False + Thread.Sleep(500) + If MyTcpListener.Pending = True Then + Trace.WriteLine(Environment.NewLine & "Connecting new client") + ThisClient = New Client(MyTcpListener.AcceptSocket()) + Clients.Add(ThisClient) + ThisClient.Start() + Else + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + If ThisClient.IsConnected = False Then + Trace.WriteLine("Performing client cleanup") + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + End If + Next + End If + End While + + Catch Exc As Sockets.SocketException + Trace.WriteLine(Exc.Message) + + Finally + Trace.WriteLine("Listen thread ending...") + If Not (MyTcpListener Is Nothing) Then + MyTcpListener.Stop() + End If + Trace.WriteLine("Listen thread ended") + + End Try + + End Sub + + Public Sub Close() + Dim ThisClient As Client = Nothing, LoopCounter As Int32 + + Me.ThreadExit = True + 'Pause to process pending requests and do cleanup + Thread.Sleep(1000) + 'Time to die + If Me.ListenThread.IsAlive Then + Me.ListenThread.Abort() + Me.ListenThread = Nothing + End If + 'Dump any client still connected! + For LoopCounter = Me.Clients.Count - 1 To 0 Step -1 + ThisClient = DirectCast(Clients(LoopCounter), Client) + ThisClient.Close() + Me.Clients.RemoveAt(LoopCounter) + Next + Me.Clients = Nothing + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/error.html b/Source/VisualStudio2003/Chapter10/ServiceAdmin/error.html new file mode 100644 index 0000000..a64a784 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/error.html @@ -0,0 +1,16 @@ + + + + + + Couldn't find page + + + + +

Ooops!

+ +

Sorry - this page cannot be found

+ + diff --git a/Source/VisualStudio2003/Chapter10/ServiceAdmin/status.html b/Source/VisualStudio2003/Chapter10/ServiceAdmin/status.html new file mode 100644 index 0000000..d847698 --- /dev/null +++ b/Source/VisualStudio2003/Chapter10/ServiceAdmin/status.html @@ -0,0 +1,25 @@ + + + + + + Service administrator + + + + +

Windows services on

+

#1#

+ + + + + + + +#2# +
Service name
Service description
Service status
+ + + diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/FormInterop.frm b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/FormInterop.frm new file mode 100644 index 0000000..1d2038e --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/FormInterop.frm @@ -0,0 +1,42 @@ +VERSION 5.00 +Begin VB.Form FormInterop + Caption = "Interop debugging" + ClientHeight = 2544 + ClientLeft = 48 + ClientTop = 288 + ClientWidth = 3744 + LinkTopic = "Form1" + ScaleHeight = 2544 + ScaleWidth = 3744 + StartUpPosition = 2 'CenterScreen + Begin VB.CommandButton DebugTest + Caption = "Test debug of VB6 app calling VB .NET component" + Height = 1092 + Left = 720 + TabIndex = 0 + Top = 720 + Width = 2172 + End +End +Attribute VB_Name = "FormInterop" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = False +Attribute VB_PredeclaredId = True +Attribute VB_Exposed = False +Option Explicit + +Private Sub DebugTest_Click() +Dim InteropTest As InteropDemo.MathClass +Set InteropTest = New InteropDemo.MathClass + +Me.DebugTest.Caption = "Result = " & CStr(InteropTest.AddTwoNumbers(1.1, 2.2)) + +Set InteropTest = Nothing + +End Sub + +Private Sub Form_Load() + +Me.Caption = "Test interop debugging" + +End Sub diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/AssemblyInfo.vb new file mode 100644 index 0000000..b8889fb --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropClass.vb b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropClass.vb new file mode 100644 index 0000000..510e7b9 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropClass.vb @@ -0,0 +1,20 @@ +Option Strict On +Imports System.Runtime.InteropServices + +Public Interface IMathClass + Function AddTwoNumbers(ByVal FirstNumber As Double, _ + ByVal SecondNumber As Double) As Double +End Interface + + _ +Public Class MathClass : Implements IMathClass + + Public Sub New() + End Sub + + Public Function AddTwoNumbers(ByVal FirstNumber As Double, ByVal SecondNumber As Double) As Double Implements IMathClass.AddTwoNumbers + 'Return the result to VB6 + Return FirstNumber + SecondNumber + End Function + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln new file mode 100644 index 0000000..43f6f17 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDemoBetter", "InteropDemoBetter.vbproj", "{5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.ActiveCfg = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.Build.0 = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.ActiveCfg = Release|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln.old b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln.old new file mode 100644 index 0000000..41538ff --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDemoBetter", "InteropDemoBetter.vbproj", "{5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.ActiveCfg = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.Build.0 = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.ActiveCfg = Release|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.suo b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.suo new file mode 100644 index 0000000..2ac2e9a Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.suo differ diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj new file mode 100644 index 0000000..20d6404 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj.user b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj.user new file mode 100644 index 0000000..04da67b --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/GoodComVersioning/InteropDemoBetter.vbproj.user @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.exe b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.exe new file mode 100644 index 0000000..5f251c4 Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.exe differ diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.pdb b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.pdb new file mode 100644 index 0000000..747fe6e Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.pdb differ diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.vbp b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.vbp new file mode 100644 index 0000000..181c660 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.vbp @@ -0,0 +1,36 @@ +Type=Exe +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\WINNT\System32\stdole2.tlb#OLE Automation +Form=FormInterop.frm +IconForm="FormInterop" +Startup="FormInterop" +HelpFile="" +Title="InteropDebug" +ExeName32="InteropDebug.exe" +Command32="" +Name="InteropDebug" +HelpContextID="0" +CompatibleMode="0" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="Sleek Software Ltd" +CompilationType=0 +OptimizationType=2 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=-1 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=0 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.vbw b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.vbw new file mode 100644 index 0000000..7ce665e --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDebug.vbw @@ -0,0 +1 @@ +FormInterop = 138, 138, 915, 786, Z, 92, 92, 869, 740, C diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/AssemblyInfo.vb new file mode 100644 index 0000000..b8889fb --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropClass.vb b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropClass.vb new file mode 100644 index 0000000..8468909 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropClass.vb @@ -0,0 +1,17 @@ +Option Strict On +Imports System.Runtime.InteropServices + + _ +Public Class MathClass + + Public Sub New() + End Sub + + Public Function AddTwoNumbers(ByVal FirstNumber As Double, ByVal SecondNumber As Double) As Double + + 'Return the result to VB6 + Return FirstNumber + SecondNumber + + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln new file mode 100644 index 0000000..de2af6c --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDemo", "InteropDemo.vbproj", "{5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.ActiveCfg = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.Build.0 = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.ActiveCfg = Release|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln.old b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln.old new file mode 100644 index 0000000..5188e56 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDemo", "InteropDemo.vbproj", "{5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.ActiveCfg = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Debug.Build.0 = Debug|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.ActiveCfg = Release|.NET + {5FC95C63-9DE4-46B7-B2F0-05E1EBD85DD3}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.suo b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.suo new file mode 100644 index 0000000..cd3a04e Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.suo differ diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj new file mode 100644 index 0000000..20d6404 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj.user b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj.user new file mode 100644 index 0000000..04da67b --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb6UsingVb7Component/InteropDemo/InteropDemo.vbproj.user @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/AssemblyInfo.vb new file mode 100644 index 0000000..b160da1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.dll b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.dll new file mode 100644 index 0000000..fc98996 Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.dll differ diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.pdb b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.pdb new file mode 100644 index 0000000..1707568 Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.pdb differ diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbp b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbp new file mode 100644 index 0000000..dff22ba --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbp @@ -0,0 +1,39 @@ +Type=OleDll +Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINNT\System32\stdole2.tlb#OLE Automation +Class=ComPrinting; ComPrinting.cls +Startup="(None)" +HelpFile="" +Title="ComPrintUtils" +ExeName32="ComPrintUtils.dll" +Command32="" +Name="ComPrintUtils" +HelpContextID="0" +CompatibleMode="2" +CompatibleEXE32="Compatibility\ComPrintUtils.dll" +VersionCompatible32="1" +MajorVer=1 +MinorVer=0 +RevisionVer=0 +AutoIncrementVer=0 +ServerSupportFiles=0 +VersionCompanyName="Sleek Software Ltd" +CompilationType=0 +OptimizationType=2 +FavorPentiumPro(tm)=0 +CodeViewDebugInfo=-1 +NoAliasing=0 +BoundsCheck=0 +OverflowCheck=0 +FlPointCheck=0 +FDIVCheck=0 +UnroundedFP=0 +StartMode=1 +Unattended=0 +Retained=0 +ThreadPerObject=0 +MaxNumberOfThreads=1 +ThreadingModel=1 +DebugStartupOption=0 + +[MS Transaction Server] +AutoRefresh=1 diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbw b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbw new file mode 100644 index 0000000..a6718a9 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrintUtils.vbw @@ -0,0 +1 @@ +ComPrinting = 23, 23, 800, 671, Z diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrinting.cls b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrinting.cls new file mode 100644 index 0000000..1321832 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/ComPrinting.cls @@ -0,0 +1,259 @@ +VERSION 1.0 CLASS +BEGIN + MultiUse = -1 'True + Persistable = 0 'NotPersistable + DataBindingBehavior = 0 'vbNone + DataSourceBehavior = 0 'vbNone + MTSTransactionMode = 0 'NotAnMTSObject +END +Attribute VB_Name = "ComPrinting" +Attribute VB_GlobalNameSpace = False +Attribute VB_Creatable = True +Attribute VB_PredeclaredId = False +Attribute VB_Exposed = True +Option Explicit +Option Base 0 + +Private Type PALETTEENTRY + peRed As Byte + peGreen As Byte + peBlue As Byte + peFlags As Byte +End Type + +Private Type LOGPALETTE + palVersion As Integer + palNumEntries As Integer + palPalEntry(255) As PALETTEENTRY ' Enough for 256 colors. +End Type + +Private Type GUID + Data1 As Long + Data2 As Integer + Data3 As Integer + Data4(7) As Byte +End Type + +Private Const RASTERCAPS As Long = 38 +Private Const RC_PALETTE As Long = &H100 +Private Const SIZEPALETTE As Long = 104 + +Private Type RECT + Left As Long + Top As Long + Right As Long + Bottom As Long +End Type + +Private Declare Function CreateCompatibleDC Lib "GDI32" (ByVal hDC As Long) As Long +Private Declare Function CreateCompatibleBitmap Lib "GDI32" (ByVal hDC As Long, _ + ByVal nWidth As Long, _ + ByVal nHeight As Long) As Long +Private Declare Function GetDeviceCaps Lib "GDI32" (ByVal hDC As Long, ByVal iCapability As Long) As Long +Private Declare Function GetSystemPaletteEntries Lib "GDI32" (ByVal hDC As Long, _ + ByVal wStartIndex As Long, ByVal wNumEntries As Long, _ + lpPaletteEntries As PALETTEENTRY) As Long +Private Declare Function CreatePalette Lib "GDI32" (lpLogPalette As LOGPALETTE) As Long +Private Declare Function SelectObject Lib "GDI32" (ByVal hDC As Long, ByVal hObject As Long) As Long +Private Declare Function BitBlt Lib "GDI32" (ByVal hDCDest As Long, ByVal XDest As Long, _ + ByVal YDest As Long, ByVal nWidth As Long, _ + ByVal nHeight As Long, ByVal hDCSrc As Long, _ + ByVal XSrc As Long, ByVal YSrc As Long, ByVal dwRop As Long) As Long +Private Declare Function DeleteDC Lib "GDI32" (ByVal hDC As Long) As Long +Private Declare Function GetForegroundWindow Lib "USER32" () As Long +Private Declare Function SelectPalette Lib "GDI32" (ByVal hDC As Long, ByVal hPalette As Long, _ + ByVal bForceBackground As Long) As Long +Private Declare Function RealizePalette Lib "GDI32" (ByVal hDC As Long) As Long +Private Declare Function GetWindowDC Lib "USER32" (ByVal hWnd As Long) As Long +Private Declare Function GetDC Lib "USER32" (ByVal hWnd As Long) As Long +Private Declare Function GetWindowRect Lib "USER32" (ByVal hWnd As Long, lpRect As RECT) As Long +Private Declare Function ReleaseDC Lib "USER32" (ByVal hWnd As Long, ByVal hDC As Long) As Long +Private Declare Function GetDesktopWindow Lib "USER32" () As Long + +Private Type PicBmp + Size As Long + Type As Long + hBmp As Long + hPal As Long + Reserved As Long +End Type + +Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" _ + (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, _ + IPic As IPicture) As Long + +Public Function CreateBitmapPicture(ByVal hBmp As Long, ByVal hPal As Long) As Picture +'Creates a bitmap type picture object from a bitmap and palette. +Dim r As Long, Pic As PicBmp, IPic As IPicture, IID_IDispatch As GUID + +'Fill in with IDispatch Interface ID. +With IID_IDispatch + .Data1 = &H20400 + .Data4(0) = &HC0 + .Data4(7) = &H46 +End With + +'Fill Pic with necessary parts. +With Pic + .Size = Len(Pic) ' Length of structure. + .Type = vbPicTypeBitmap ' Type of Picture (bitmap). + .hBmp = hBmp ' Handle to bitmap. + .hPal = hPal ' Handle to palette (may be null). +End With + +'Create picture object. +r = OleCreatePictureIndirect(Pic, IID_IDispatch, 1, IPic) + +'Return the new Picture object. +Set CreateBitmapPicture = IPic + +End Function + +Public Function CaptureWindow(ByVal hWndSrc As Long, ByVal Client As Boolean, _ + ByVal LeftSrc As Long, ByVal TopSrc As Long, _ + ByVal WidthSrc As Long, ByVal HeightSrc As Long) As Picture +'Captures any portion of a window. +Dim hDCMemory As Long, hBmp As Long, hBmpPrev As Long, r As Long +Dim hDCSrc As Long, hPal As Long, hPalPrev As Long, RasterCapsScrn As Long +Dim HasPaletteScrn As Long, PaletteSizeScrn As Long, LogPal As LOGPALETTE + +'Depending on the value of Client, get the proper device context. +If Client Then + hDCSrc = GetDC(hWndSrc) 'Get device context for client area. +Else + hDCSrc = GetWindowDC(hWndSrc) 'Get device context for entire window. +End If + +'Create a memory device context for the copy process. +hDCMemory = CreateCompatibleDC(hDCSrc) +'Create a bitmap and place it in the memory DC. +hBmp = CreateCompatibleBitmap(hDCSrc, WidthSrc, HeightSrc) +hBmpPrev = SelectObject(hDCMemory, hBmp) + +'Get screen properties. +RasterCapsScrn = GetDeviceCaps(hDCSrc, RASTERCAPS) 'Raster capabilities. +HasPaletteScrn = RasterCapsScrn And RC_PALETTE 'Palette support. +PaletteSizeScrn = GetDeviceCaps(hDCSrc, SIZEPALETTE) 'Size of palette. + +'If the screen has a palette make a copy and realize it. +If HasPaletteScrn And (PaletteSizeScrn = 256) Then + 'Create a copy of the system palette. + LogPal.palVersion = &H300 + LogPal.palNumEntries = 256 + r = GetSystemPaletteEntries(hDCSrc, 0, 256, LogPal.palPalEntry(0)) + hPal = CreatePalette(LogPal) + ' Select the new palette into the memory DC and realize it. + hPalPrev = SelectPalette(hDCMemory, hPal, 0) + r = RealizePalette(hDCMemory) +End If + +'Copy the on-screen image into the memory DC. +r = BitBlt(hDCMemory, 0, 0, WidthSrc, HeightSrc, hDCSrc, LeftSrc, TopSrc, vbSrcCopy) + +'Remove the new copy of the on-screen image. +hBmp = SelectObject(hDCMemory, hBmpPrev) + +'If the screen has a palette get back the palette that was selected in previously. +If HasPaletteScrn And (PaletteSizeScrn = 256) Then + hPal = SelectPalette(hDCMemory, hPalPrev, 0) +End If + +'Release the device context resources back to the system. +r = DeleteDC(hDCMemory) +r = ReleaseDC(hWndSrc, hDCSrc) + +'Call CreateBitmapPicture to create a picture object from the +'bitmap and palette handles. Then return the resulting picture object. +Set CaptureWindow = CreateBitmapPicture(hBmp, hPal) + +End Function + +Public Function CaptureScreen() As Picture +'Captures the entire screen. +Dim hWndScreen As Long + +' Get a handle to the desktop window. +hWndScreen = GetDesktopWindow() + +' Call CaptureWindow to capture the entire desktop give the handle +' and return the resulting Picture object. + +Set CaptureScreen = CaptureWindow(hWndScreen, False, 0, 0, _ + Screen.Width \ Screen.TwipsPerPixelX, _ + Screen.Height \ Screen.TwipsPerPixelY) + +End Function + +Public Function CaptureForm(ByVal WindowHandle As Long) As Picture +'Captures an entire form including title bar and border. +Dim r As Long, RectActive As RECT + +'Get the dimensions of the window. +r = GetWindowRect(WindowHandle, RectActive) + +'Call CaptureWindow to capture the active window given its +'handle and return the Resulting Picture object. +Set CaptureForm = CaptureWindow(WindowHandle, False, 0, 0, _ + RectActive.Right - RectActive.Left, _ + RectActive.Bottom - RectActive.Top) + +End Function + +Public Function CaptureActiveWindow() As Picture +'Captures the currently active window on the screen. +Dim hWndActive As Long, r As Long, RectActive As RECT + +'Get a handle to the active/foreground window. +hWndActive = GetForegroundWindow() + +'Get the dimensions of the window. +r = GetWindowRect(hWndActive, RectActive) + +'Call CaptureWindow to capture the active window given its +'handle and return the Resulting Picture object. +Set CaptureActiveWindow = CaptureWindow(hWndActive, False, 0, 0, _ + RectActive.Right - RectActive.Left, _ + RectActive.Bottom - RectActive.Top) + +End Function + +Public Sub PrintPictureToFitPage(ByRef Pic As Picture) +'Prints a Picture object as big as possible. +Const vbHiMetric As Integer = 8 +Dim PicRatio As Double, PrnWidth As Double, PrnHeight As Double +Dim PrnRatio As Double, PrnPicWidth As Double, PrnPicHeight As Double + +'Determine if picture should be printed in landscape or portrait +'and set the orientation. +If Pic.Height >= Pic.Width Then + Printer.Orientation = vbPRORPortrait 'Taller than wide. +Else + Printer.Orientation = vbPRORLandscape 'Wider than tall. +End If + +'Calculate device independent Width-to-Height ratio for picture. +PicRatio = Pic.Width / Pic.Height + +'Calculate the dimentions of the printable area in HiMetric. +With Printer + + 'Calculate device independent Width to Height ratio for printer. + PrnWidth = .ScaleX(.ScaleWidth, .ScaleMode, vbHiMetric) + PrnHeight = .ScaleY(.ScaleHeight, .ScaleMode, vbHiMetric) + PrnRatio = PrnWidth / PrnHeight + + 'Scale the output to the printable area. + If PicRatio >= PrnRatio Then + PrnPicWidth = .ScaleX(PrnWidth, vbHiMetric, .ScaleMode) + PrnPicHeight = .ScaleY(PrnWidth / PicRatio, vbHiMetric, .ScaleMode) + Else + PrnPicHeight = .ScaleY(PrnHeight, vbHiMetric, .ScaleMode) + PrnPicWidth = .ScaleX(PrnHeight * PicRatio, vbHiMetric, .ScaleMode) + End If + +End With + +'Print the picture using the PaintPicture method. +Printer.PaintPicture Pic, 0, 0, PrnPicWidth, PrnPicHeight + +End Sub diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/Compatibility/ComPrintUtils.dll b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/Compatibility/ComPrintUtils.dll new file mode 100644 index 0000000..82452cc Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/ComPrinting/Compatibility/ComPrintUtils.dll differ diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/FormInterop.resx b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/FormInterop.resx new file mode 100644 index 0000000..0a2c16a --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/FormInterop.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Form1 + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/FormInterop.vb b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/FormInterop.vb new file mode 100644 index 0000000..99f4c07 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/FormInterop.vb @@ -0,0 +1,67 @@ +Option Strict On + +Public Class Form1 + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents cmdTest As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.cmdTest = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'cmdTest + ' + Me.cmdTest.Location = New System.Drawing.Point(64, 104) + Me.cmdTest.Name = "cmdTest" + Me.cmdTest.Size = New System.Drawing.Size(152, 80) + Me.cmdTest.TabIndex = 0 + Me.cmdTest.Text = "Test debug of VB .NET app calling VB6 component" + ' + 'Form1 + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.cmdTest}) + Me.Name = "Form1" + Me.Text = "Interop debugging" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub cmdTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTest.Click + Dim DebugTest As New ComPrintUtils.ComPrinting() + DebugTest.PrintPictureToFitPage(DebugTest.CaptureForm(Me.Handle.ToInt32)) + System.Runtime.InteropServices.Marshal.ReleaseComObject(DebugTest) + DebugTest = Nothing + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.sln b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.sln new file mode 100644 index 0000000..ac3e57d --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDebug", "InteropDebug.vbproj", "{BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Debug.ActiveCfg = Debug|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Debug.Build.0 = Debug|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Release.ActiveCfg = Release|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.sln.old b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.sln.old new file mode 100644 index 0000000..27f661e --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "InteropDebug", "InteropDebug.vbproj", "{BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Debug.ActiveCfg = Debug|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Debug.Build.0 = Debug|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Release.ActiveCfg = Release|.NET + {BB1951AD-EA5D-4FCC-B2EE-DADFBB15129F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.suo b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.suo new file mode 100644 index 0000000..8dab2d5 Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.suo differ diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj new file mode 100644 index 0000000..fa18a59 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj.user b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj.user new file mode 100644 index 0000000..19b27d4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/InteropDebug.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/obj/Debug/InteropDebug.Form1.resources b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/obj/Debug/InteropDebug.Form1.resources new file mode 100644 index 0000000..0c0f382 Binary files /dev/null and b/Source/VisualStudio2003/Chapter11/Vb7UsingVb6Component/obj/Debug/InteropDebug.Form1.resources differ diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter12/SqlDebug/AssemblyInfo.vb new file mode 100644 index 0000000..d837e52 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.resx b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.resx new file mode 100644 index 0000000..7923464 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.resx @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + Assembly + + + Assembly + + + Assembly + + + SqlDebug + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.sln b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.sln new file mode 100644 index 0000000..1cd9d7c --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SqlDebug", "SqlDebug.vbproj", "{25E00B17-05B1-4234-AC07-5C21C167C48C}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Debug.ActiveCfg = Debug|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Debug.Build.0 = Debug|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Release.ActiveCfg = Release|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.sln.old b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.sln.old new file mode 100644 index 0000000..22ed41b --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "SqlDebug", "SqlDebug.vbproj", "{25E00B17-05B1-4234-AC07-5C21C167C48C}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Debug.ActiveCfg = Debug|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Debug.Build.0 = Debug|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Release.ActiveCfg = Release|.NET + {25E00B17-05B1-4234-AC07-5C21C167C48C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.suo b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.suo new file mode 100644 index 0000000..c14bd86 Binary files /dev/null and b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.suo differ diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vb b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vb new file mode 100644 index 0000000..a145ff1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vb @@ -0,0 +1,147 @@ +Option Strict On +Imports System.Data.SqlClient + +Public Class SqlDebug + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents ConnectionQuery As System.Windows.Forms.Button + Friend WithEvents ConnectionDestroy As System.Windows.Forms.Button + Friend WithEvents ConnectionCreate As System.Windows.Forms.Button + Friend WithEvents ValueToInsert As System.Windows.Forms.TextBox + Private Sub InitializeComponent() + Me.ConnectionQuery = New System.Windows.Forms.Button() + Me.ConnectionDestroy = New System.Windows.Forms.Button() + Me.ConnectionCreate = New System.Windows.Forms.Button() + Me.ValueToInsert = New System.Windows.Forms.TextBox() + Me.SuspendLayout() + ' + 'ConnectionQuery + ' + Me.ConnectionQuery.Location = New System.Drawing.Point(16, 96) + Me.ConnectionQuery.Name = "ConnectionQuery" + Me.ConnectionQuery.Size = New System.Drawing.Size(152, 40) + Me.ConnectionQuery.TabIndex = 0 + Me.ConnectionQuery.Text = "Insert new row" + ' + 'ConnectionDestroy + ' + Me.ConnectionDestroy.Location = New System.Drawing.Point(16, 168) + Me.ConnectionDestroy.Name = "ConnectionDestroy" + Me.ConnectionDestroy.Size = New System.Drawing.Size(152, 40) + Me.ConnectionDestroy.TabIndex = 1 + Me.ConnectionDestroy.Text = "Destroy connection" + ' + 'ConnectionCreate + ' + Me.ConnectionCreate.Location = New System.Drawing.Point(16, 24) + Me.ConnectionCreate.Name = "ConnectionCreate" + Me.ConnectionCreate.Size = New System.Drawing.Size(152, 40) + Me.ConnectionCreate.TabIndex = 2 + Me.ConnectionCreate.Text = "Create connection" + ' + 'ValueToInsert + ' + Me.ValueToInsert.Location = New System.Drawing.Point(184, 104) + Me.ValueToInsert.Name = "ValueToInsert" + Me.ValueToInsert.Size = New System.Drawing.Size(80, 22) + Me.ValueToInsert.TabIndex = 3 + Me.ValueToInsert.Text = "" + ' + 'SqlDebug + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.ValueToInsert, Me.ConnectionCreate, Me.ConnectionDestroy, Me.ConnectionQuery}) + Me.Name = "SqlDebug" + Me.Text = "SQL Debugging" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private m_DatabaseConnection As SqlConnection + + Private Sub ConnectionCreation(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionCreate.Click + Dim ConnectionString As String, ConnectStatus As String + + 'Setup database connection + ConnectionString = "Initial Catalog = pubs;" + ConnectionString += "Data Source = CHEETAH;" + ConnectionString += "Integrated Security = SSPI;" + ConnectionString += "Pooling = 'false'" + + 'Attempt database connection + Try + m_DatabaseConnection = New SqlConnection(ConnectionString) + ConnectStatus = "Connected" + Catch objException As Exception + ConnectStatus = "Not connected: " & objException.ToString + m_DatabaseConnection.Close() + m_DatabaseConnection.Dispose() + Finally + Me.Text = ConnectStatus + End Try + + End Sub + + Private Sub ConnectionTest(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionQuery.Click + Dim QuerySql As String, QueryResult As New DataSet() + Dim QueryTest As New SqlDataAdapter() + + 'Check that we have a valid number + If Len(Trim$(Me.ValueToInsert.Text)) = 0 Then + MsgBox("You should enter a number before adding new row", MsgBoxStyle.Information Or MsgBoxStyle.OKOnly, "Ooops") + Me.ValueToInsert.Focus() + Exit Sub + End If + + 'Setup and perform database query + QuerySql = "EXEC sp_DebugExample " & Me.ValueToInsert.Text + Try + QueryTest.SelectCommand = New SqlCommand(QuerySql, m_DatabaseConnection) + QueryTest.Fill(QueryResult) + Catch objException As Exception + MsgBox(objException.ToString) + Finally + QueryTest.Dispose() + End Try + End Sub + + Private Sub ConnectionDestruction(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ConnectionDestroy.Click + + m_DatabaseConnection.Close() + m_DatabaseConnection.Dispose() + Me.Text = "Not connected" + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vbproj b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vbproj new file mode 100644 index 0000000..0eacba7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vbproj @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vbproj.user b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vbproj.user new file mode 100644 index 0000000..e2b755e --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.zip b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.zip new file mode 100644 index 0000000..32072d0 Binary files /dev/null and b/Source/VisualStudio2003/Chapter12/SqlDebug/SqlDebug.zip differ diff --git a/Source/VisualStudio2003/Chapter12/SqlScripts/Corrected sp_DebugExample.sql b/Source/VisualStudio2003/Chapter12/SqlScripts/Corrected sp_DebugExample.sql new file mode 100644 index 0000000..8143012 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlScripts/Corrected sp_DebugExample.sql @@ -0,0 +1,23 @@ +USE PUBS +GO + +/* Create corrected example stored procedure */ +ALTER PROCEDURE sp_DebugExample + @KeyColumn int +AS + +DECLARE @rowcount int, + @error int + +INSERT DebugTest VALUES(@KeyColumn) +SELECT @error = @@error, + @rowcount = @@rowcount + +IF @error <> 0 +BEGIN + INSERT DebugError + (RowsInserted, ErrorNumber, ProblemValue) + VALUES (@rowcount, @error, @Keycolumn) +END +GO + diff --git a/Source/VisualStudio2003/Chapter12/SqlScripts/Original sp_DebugExample.sql b/Source/VisualStudio2003/Chapter12/SqlScripts/Original sp_DebugExample.sql new file mode 100644 index 0000000..1470a43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlScripts/Original sp_DebugExample.sql @@ -0,0 +1,17 @@ +USE PUBS +GO + +/* Create original example stored procedure */ +CREATE PROCEDURE sp_DebugExample + @KeyColumn int +AS + +INSERT DebugTest VALUES(@KeyColumn) + +IF @@error <> 0 +BEGIN + INSERT DebugError + (RowsInserted, ErrorNumber, ProblemValue) + VALUES (@@rowcount, @@error, @Keycolumn) +END +GO diff --git a/Source/VisualStudio2003/Chapter12/SqlScripts/tb_DebugTest.sql b/Source/VisualStudio2003/Chapter12/SqlScripts/tb_DebugTest.sql new file mode 100644 index 0000000..940a9c3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter12/SqlScripts/tb_DebugTest.sql @@ -0,0 +1,20 @@ +USE pubs +GO + +/* Build the first table */ +CREATE TABLE DebugTest +( +Id int NOT NULL IDENTITY (1,1), +KeyPrimary int NOT NULL PRIMARY KEY CHECK (KeyPrimary > 0) +) +GO + +/* Build the second table */ +CREATE TABLE DebugError +( +Id int NOT NULL IDENTITY (1,1), +RowsInserted int NOT NULL, +ErrorNumber int NOT NULL, +ProblemValue int NOT NULL +) +GO diff --git a/Source/VisualStudio2003/Chapter13/CustomException/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter13/CustomException/AssemblyInfo.vb new file mode 100644 index 0000000..04c890e --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter13/CustomException/CustomException.sln b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.sln new file mode 100644 index 0000000..df8b4da --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomException", "CustomException.vbproj", "{97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Debug.ActiveCfg = Debug|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Debug.Build.0 = Debug|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Release.ActiveCfg = Release|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/CustomException/CustomException.sln.old b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.sln.old new file mode 100644 index 0000000..8af6a60 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CustomException", "CustomException.vbproj", "{97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Debug.ActiveCfg = Debug|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Debug.Build.0 = Debug|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Release.ActiveCfg = Release|.NET + {97B3CFC4-AB0D-4A30-AE92-31925ACAAF8C}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/CustomException/CustomException.suo b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.suo new file mode 100644 index 0000000..0703d1d Binary files /dev/null and b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.suo differ diff --git a/Source/VisualStudio2003/Chapter13/CustomException/CustomException.vbproj b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.vbproj new file mode 100644 index 0000000..71ffd20 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.vbproj @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/CustomException/CustomException.vbproj.user b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/CustomException.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/CustomException/Test.vb b/Source/VisualStudio2003/Chapter13/CustomException/Test.vb new file mode 100644 index 0000000..4f60c1d --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/Test.vb @@ -0,0 +1,40 @@ +Option Strict On + +Module Test + + Sub Main() + + Try + UserDetailsLoad("MarkPearce") + Catch Exc As UserLoadException + Console.WriteLine(Exc.Message) + Finally + Console.ReadLine() + End Try + + End Sub + + Function UserDetailsLoad(ByVal UserId As String) As Collection + Dim HelpfulMessage As String + Dim FileStream As System.IO.StreamReader + + 'First try to open the specified file + Try + FileStream = New System.IO.StreamReader(UserId & ".data") + + Catch Exc As System.IO.FileNotFoundException + 'The specified file didn't exist, but this exception won't mean + 'much to a caller who doesn't know how this method is implemented + UserDetailsLoad = Nothing + HelpfulMessage = "User details for '" & UserId & "' cannot be located" + Throw New UserLoadException(HelpfulMessage, Exc, UserId) + + Finally + + End Try + + 'Code goes here to load and return user details + + End Function + +End Module diff --git a/Source/VisualStudio2003/Chapter13/CustomException/UserLoadException.vb b/Source/VisualStudio2003/Chapter13/CustomException/UserLoadException.vb new file mode 100644 index 0000000..c7ab814 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/CustomException/UserLoadException.vb @@ -0,0 +1,56 @@ +Option Strict On +Imports System.Runtime.Serialization + + _ +Public Class UserLoadException : Inherits System.ApplicationException + + Private m_UserId As String = "" + + Public Sub New() + MyBase.New() + End Sub + + Public Sub New(ByVal message As String) + MyBase.New(message) + End Sub + + Public Sub New(ByVal message As String, ByVal UserId As String) + MyBase.New(message) + m_UserId = UserId + End Sub + + Public Sub New(ByVal message As String, ByVal innerException As Exception) + MyBase.New(message, innerException) + End Sub + + Public Sub New(ByVal message As String, ByVal innerException As Exception, ByVal UserId As String) + MyBase.New(message, innerException) + m_UserId = UserId + End Sub + + 'To re-materialize exception and custom property at the receiving end + Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) + MyBase.New(info, context) + m_UserId = info.GetString("UserId") + End Sub + + 'To de-materialize custom property at the sending end + Public Overrides Sub GetObjectData(ByVal info As SerializationInfo, ByVal context As StreamingContext) + MyBase.GetObjectData(info, context) + info.AddValue("UserId", m_UserId) + End Sub + + 'To add custom property to standard exception message + Public Overrides ReadOnly Property Message() As String + Get + Return MyBase.Message & Environment.NewLine & "User id: " & m_UserId & Environment.NewLine + End Get + End Property + + ReadOnly Property UserId() As String + Get + UserId = m_UserId + End Get + End Property + +End Class diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter13/HidingDetail/AssemblyInfo.vb new file mode 100644 index 0000000..1a0cfa0 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/HidingDetail/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.sln b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.sln new file mode 100644 index 0000000..87ff703 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HidingDetail", "HidingDetail.vbproj", "{FA9CA985-D2C2-466D-8503-B447C738F116}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {FA9CA985-D2C2-466D-8503-B447C738F116}.Debug.ActiveCfg = Debug|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Debug.Build.0 = Debug|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Release.ActiveCfg = Release|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.sln.old b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.sln.old new file mode 100644 index 0000000..1179386 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HidingDetail", "HidingDetail.vbproj", "{FA9CA985-D2C2-466D-8503-B447C738F116}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {FA9CA985-D2C2-466D-8503-B447C738F116}.Debug.ActiveCfg = Debug|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Debug.Build.0 = Debug|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Release.ActiveCfg = Release|.NET + {FA9CA985-D2C2-466D-8503-B447C738F116}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.suo b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.suo new file mode 100644 index 0000000..0b6df73 Binary files /dev/null and b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.suo differ diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.vbproj b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.vbproj new file mode 100644 index 0000000..6e096a1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.vbproj.user b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/HidingDetail/HidingDetail.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/HidingDetail/Test.vb b/Source/VisualStudio2003/Chapter13/HidingDetail/Test.vb new file mode 100644 index 0000000..f1c2274 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/HidingDetail/Test.vb @@ -0,0 +1,40 @@ +Option Strict On + +Module Test + + Sub Main() + + Try + UserDetailsLoad("MarkPearce") + Catch Exc As Exception + Console.WriteLine(Exc.Message) + Finally + Console.ReadLine() + End Try + + End Sub + + Function UserDetailsLoad(ByVal UserId As String) As Collection + Dim HelpfulMessage As String + Dim FileStream As System.IO.StreamReader + + 'First try to open the specified file + Try + FileStream = New System.IO.StreamReader(UserId & ".data") + + Catch Exc As System.IO.FileNotFoundException + 'The specified file didn't exist, but this exception won't mean + 'much to a caller who doesn't know how this method is implemented + UserDetailsLoad = Nothing + HelpfulMessage = "User details for '" & UserId & "' cannot be located" + Throw New System.ArgumentException(HelpfulMessage, Exc) + + Finally + + End Try + + 'Code goes here to load and return user details + + End Function + +End Module \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter13/MoveFileWrapper/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter13/MoveFileWrapper/AssemblyInfo.vb new file mode 100644 index 0000000..95fb311 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/MoveFileWrapper/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter13/MoveFileWrapper/ExceptionWrapper.vb b/Source/VisualStudio2003/Chapter13/MoveFileWrapper/ExceptionWrapper.vb new file mode 100644 index 0000000..3b8ddbb --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/MoveFileWrapper/ExceptionWrapper.vb @@ -0,0 +1,89 @@ +Option Strict On +Imports System.IO + +Module ExceptionWrapper + + Sub Main() + Dim WrapperNo As Boolean = False, WrapperYes As Boolean = True + + 'MOVE commands producing good exception information + TestMove("C:\Demo\Source.txt", "C:\Demo\Destination.txt", WrapperNo, "Destination is read-only") + TestMove("C:\Demo\Source.txt", "", WrapperNo, "Destination is empty") + TestMove("C:\Demo\Source.txt", Nothing, WrapperNo, "Destination is nothing") + TestMove("C:\Demo\Source.txt", "C:\Dem\Destination.txt", WrapperNo, "Wrong destination folder") + TestMove("C:\Demo\SourceX.txt", "C:\Demo\Destination.txt", WrapperNo, "Source doesn't exist") + + 'MOVE commands producing bad exception information + TestMove("C:\Demo\Source.txt", "C:\Demo\*.txt", WrapperNo, "Wildcard in destination") + TestMove("C:\Demo\Sou + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/MoveFileWrapper/MoveFileWrapper.vbproj.user b/Source/VisualStudio2003/Chapter13/MoveFileWrapper/MoveFileWrapper.vbproj.user new file mode 100644 index 0000000..29c78d4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/MoveFileWrapper/MoveFileWrapper.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/AssemblyInfo.vb new file mode 100644 index 0000000..257341e --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln new file mode 100644 index 0000000..4b9ab73 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RealisticUnhandledExcFilter", "RealisticUnhandledExcFilter.vbproj", "{BB7379C0-225C-4404-8EF1-70A4A099FE5D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.ActiveCfg = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.Build.0 = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.ActiveCfg = Release|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln.old b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln.old new file mode 100644 index 0000000..1d226b2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RealisticUnhandledExcFilter", "RealisticUnhandledExcFilter.vbproj", "{BB7379C0-225C-4404-8EF1-70A4A099FE5D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.ActiveCfg = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.Build.0 = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.ActiveCfg = Release|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.suo b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.suo new file mode 100644 index 0000000..ed85be5 Binary files /dev/null and b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.suo differ diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj new file mode 100644 index 0000000..a76fbcf --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj.user b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/RealisticUnhandledExcFilter.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/Startup.vb b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/Startup.vb new file mode 100644 index 0000000..990f64b --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/RealisticUnhandledExcFilter/Startup.vb @@ -0,0 +1,70 @@ +Option Strict On +Imports System +Imports Microsoft.Win32 + +Module Startup + + Sub Main() + + 'Before running this program within the IDE, please use the Debug...Exceptions menu + 'item to ensure that the program continues in the face of an unhandled exception. + + 'Register the unhandled exception filter with the AppDomain. + 'This means that UnhandledExceptionFilter will be called whenever + 'a managed unhandled exception occurs. + AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionFilter + + 'Here's where the normal application code should appear. + 'In this case, deliberately create an exception so that + 'we can test the unhandled exception filter. + Dim objTest As Object + objTest.ToString() + + End Sub + + Private Sub UnhandledExceptionFilter(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) + 'This method will be called by any unhandled managed exception + Dim MessageFriendly As String, MessageDetail As String + + 'Log detailed exception message if no debugger is attached to this process + If Debugger.IsAttached = False Then + MessageDetail = "An unhandled exception occurred!" + Environment.NewLine + MessageDetail += e.ExceptionObject.ToString + Environment.NewLine + MessageDetail += "Application user was '" + Environment.UserName + "'." + Environment.NewLine + If e.IsTerminating = True Then + MessageDetail += "CLR will terminate this process (exception was on main thread)." + Else + MessageDetail += "CLR won't terminate this process (exception wasn't on main thread)." + End If + 'Write message to the Windows event Application log + Dim LogWriter As New EventLog("Application", ".", System.AppDomain.CurrentDomain.FriendlyName) + LogWriter.WriteEntry(MessageDetail, EventLogEntryType.Warning) + LogWriter.Close() + LogWriter.Dispose() + End If + +#If Debug = True Then + 'Launch the debugger if DEBUG build, no debugger already attached + 'and this is an interactive process (user is present) + If (Environment.UserInteractive = True) And (Debugger.IsAttached = False) Then + Debugger.Launch() + End If +#Else + 'If RELEASE build and this is an interactive process (user is present), + 'then show user either a warning or a critical message + If Environment.UserInteractive = True Then + MessageFriendly = "Unfortunately, this application hit an problem." + Environment.NewLine + If e.IsTerminating = True Then + MessageFriendly += "It will close now, but you can restart it." + Environment.NewLine + MessageFriendly += "Please contact application support and ask them to look in the event log." + MsgBox(MessageFriendly, MsgBoxStyle.Critical Or MsgBoxStyle.OKOnly, "Sorry for the inconvenience") + Else + MessageFriendly += "Please save your work asap before restarting the application." + MsgBox(MessageFriendly, MsgBoxStyle.Exclamation Or MsgBoxStyle.OKOnly, "Sorry for the inconvenience") + End If + End If +#End If + + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/AssemblyInfo.vb new file mode 100644 index 0000000..257341e --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/Startup.vb b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/Startup.vb new file mode 100644 index 0000000..491f61e --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/Startup.vb @@ -0,0 +1,86 @@ +Option Strict On +Imports System +Imports Microsoft.Win32 + +Module Startup + + Sub Main() + + 'Before running this program within the IDE, please use the Debug...Exceptions menu + 'item to ensure that the program continues in the face of an unhandled exception. + + 'Register the unhandled exception filter with the AppDomain. + 'This means that UnhandledExceptionFilter will be called whenever + 'a managed unhandled exception occurs. + AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionFilter + + 'Here's where the normal application code should appear. + 'In this case, deliberately create an exception so that + 'we can test the unhandled exception filter. + Dim objTest As Object + objTest.ToString() + + End Sub + + Sub UnhandledExceptionFilter(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) + 'This method will be called by any unhandled managed exception + 'Using DEBUG or RELEASE config + Dim JitDebugSetting As Object, RegKey As RegistryKey = Registry.LocalMachine + RegKey = RegKey.OpenSubKey("Software\Microsoft\.NetFramework") + JitDebugSetting = RegKey.GetValue("DbgJitDebugLaunchSetting") + RegKey.Close() + +#If Debug Then + Console.WriteLine("DEBUG configuration") + +#Else + Console.WriteLine("RELEASE configuration") +#End If + 'Who is user? + Console.WriteLine("User: " + Environment.UserName) + 'Is debugger attached? + Console.WriteLine("Debugger attached? " + Debugger.IsAttached.ToString) + 'Is there an end-user to show a message to? + Console.WriteLine("End-user present? " + Environment.UserInteractive.ToString) + 'Is this a CLS-compliant exception? + Console.WriteLine("CLS-compliant exception? " + ((TypeOf e.ExceptionObject Is Exception).ToString)) + 'What's the CLR going to do with the process? + If e.IsTerminating = True Then + Console.WriteLine("CLR will terminate this process") + Else + Console.WriteLine("CLR won't terminate this process") + End If + 'What's the CLR going to do about debugging? + If Debugger.IsAttached = True Then + Console.WriteLine("CLR didn't talk to user or spawn a debugger") + Else + 'If process is terminating, debugger checks registry for action. + 'Otherwise, CLR will deal with only the offending thread. + If e.IsTerminating = True Then + If JitDebugSetting Is Nothing Then + Console.WriteLine("No JIT debug setting in registry") + Else + Console.WriteLine("JIT debug setting: " + JitDebugSetting.ToString) + Select Case JitDebugSetting + Case 0 + Console.WriteLine("CLR asked user whether to spawn a debugger") + Case 1 + Console.WriteLine("CLR didn't talk to user or spawn a debugger") + Case 2 + Console.WriteLine("CLR spawned debugger and asked user about debugging") + Case Else + Console.WriteLine("JIT debug setting is invalid!") + End Select + End If + Else + Console.WriteLine("CLR didn't talk to user or spawn a debugger") + End If + End If + 'Write exception to console + Console.WriteLine(Environment.NewLine + "Exception text:") + Console.WriteLine(e.ExceptionObject.ToString) + Console.ReadLine() + + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln new file mode 100644 index 0000000..2bcd53e --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnhandledExcFilter", "UnhandledExcFilter.vbproj", "{BB7379C0-225C-4404-8EF1-70A4A099FE5D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.ActiveCfg = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.Build.0 = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.ActiveCfg = Release|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln.old b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln.old new file mode 100644 index 0000000..eb2eb9a --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnhandledExcFilter", "UnhandledExcFilter.vbproj", "{BB7379C0-225C-4404-8EF1-70A4A099FE5D}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.ActiveCfg = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Debug.Build.0 = Debug|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.ActiveCfg = Release|.NET + {BB7379C0-225C-4404-8EF1-70A4A099FE5D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.suo b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.suo new file mode 100644 index 0000000..c75b60c Binary files /dev/null and b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.suo differ diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj new file mode 100644 index 0000000..a76fbcf --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj.user b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExcFilter/UnhandledExcFilter.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/AssemblyInfo.vb new file mode 100644 index 0000000..a28d0fc --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/AssemblyInfo.vb @@ -0,0 +1,31 @@ +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/TestForm.resx b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/TestForm.resx new file mode 100644 index 0000000..aa5dcd4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/TestForm.resx @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Assembly + + + TestForm + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/TestForm.vb b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/TestForm.vb new file mode 100644 index 0000000..7440978 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/TestForm.vb @@ -0,0 +1,63 @@ +Public Class TestForm + Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents FireException As System.Windows.Forms.Button + Private Sub InitializeComponent() + Me.FireException = New System.Windows.Forms.Button() + Me.SuspendLayout() + ' + 'FireException + ' + Me.FireException.Location = New System.Drawing.Point(48, 136) + Me.FireException.Name = "FireException" + Me.FireException.Size = New System.Drawing.Size(184, 56) + Me.FireException.TabIndex = 0 + Me.FireException.Text = "&Fire exception" + ' + 'TestForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(292, 272) + Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.FireException}) + Me.Name = "TestForm" + Me.Text = "WinForms exception demo" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub FireException_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FireException.Click + Dim objTest As Object + objTest.GetType() + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptions.vb b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptions.vb new file mode 100644 index 0000000..2deab31 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptions.vb @@ -0,0 +1,41 @@ +Option Strict On +Imports System +Imports System.Windows.Forms + +Module UnhandledExceptions + + _ + Sub Main() + + 'First register the unhandled exception filter with the AppDomain. + 'This is useful to handle certain situations: + '1: An exception is thrown on a non-window thread or before first window launched. + '2: If a debugger is attached, unhandled exception will still reach here. + '3: If app config file specifies JIT debugging, unhandled exception still reaches here. + '4: Exceptions that are not CLS-compliant will still only be caught here. + AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExceptionFilter + + 'In a Windows Form app, if a managed exception occurs and a debugger + 'isn't attached, the CLR will display an exception warning dialog. + 'If we want to override this dialog, we need to register a delegate + 'so that our method will be called instead. + AddHandler Application.ThreadException, AddressOf OverrideClrDialog + + 'Normal application code goes here + 'In this case, click on the form button to trigger an unhandled exception + Application.Run(New TestForm()) + + End Sub + + Private Sub UnhandledExceptionFilter(ByVal sender As Object, ByVal e As UnhandledExceptionEventArgs) + 'This method deals with anything not handled by OverrideClrDialog + MsgBox(e.ExceptionObject.ToString, MsgBoxStyle.OKOnly, "UnhandledExceptionFilter: " + e.IsTerminating.ToString) + End Sub + + Private Sub OverrideClrDialog(ByVal sender As Object, ByVal e As System.Threading.ThreadExceptionEventArgs) + 'This method will be called by any unhandled managed exception + 'assuming that a debugger isn't attached + MsgBox(e.Exception.ToString, MsgBoxStyle.OKOnly, "OverrideClrDialog") + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln new file mode 100644 index 0000000..eaabe86 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnhandledExceptionsWinForms", "UnhandledExceptionsWinForms.vbproj", "{F2494349-133A-4CA8-A2E6-0F4422E9219F}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Debug.ActiveCfg = Debug|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Debug.Build.0 = Debug|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Release.ActiveCfg = Release|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln.old b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln.old new file mode 100644 index 0000000..f6e2f33 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.sln.old @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "UnhandledExceptionsWinForms", "UnhandledExceptionsWinForms.vbproj", "{F2494349-133A-4CA8-A2E6-0F4422E9219F}" +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Debug.ActiveCfg = Debug|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Debug.Build.0 = Debug|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Release.ActiveCfg = Release|.NET + {F2494349-133A-4CA8-A2E6-0F4422E9219F}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.suo b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.suo new file mode 100644 index 0000000..b84e31e Binary files /dev/null and b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.suo differ diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj new file mode 100644 index 0000000..7a9a435 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj.user b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj.user new file mode 100644 index 0000000..7136437 --- /dev/null +++ b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/UnhandledExceptionsWinForms.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/obj/Debug/UnhandledExceptionsWinForms.TestForm.resources b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/obj/Debug/UnhandledExceptionsWinForms.TestForm.resources new file mode 100644 index 0000000..f15a353 Binary files /dev/null and b/Source/VisualStudio2003/Chapter13/UnhandledExceptionWinForms/obj/Debug/UnhandledExceptionsWinForms.TestForm.resources differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadDeadlock/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/AssemblyInfo.vb new file mode 100644 index 0000000..41e5ba2 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadDeadlock/DeadlockTest.vb b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/DeadlockTest.vb new file mode 100644 index 0000000..86abc9c --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/DeadlockTest.vb @@ -0,0 +1,130 @@ +Option Strict On +Imports System.Threading + +Module DeadlockTest + + Sub Main() + Dim TransferTest As New Bank(2, 10000) + 'Console.ReadLine() + End Sub + +End Module + +Class Bank + + Private m_AccountOne As New Account(1000000) + Private m_AccountTwo As New Account(1000000) + + Public Sub New(ByVal NumberOfCashiers As Integer, ByVal NumberOfTransfers As Integer) + Dim EachWorker As Integer, NewThread As Thread, Worker As Cashier + + 'Show starting conditions + Console.WriteLine("{0} cashiers are performing {1} transfers each.", _ + NumberOfCashiers.ToString, NumberOfTransfers.ToString) + + 'Start specified number of worker threads + For EachWorker = 1 To NumberOfCashiers + Worker = New Cashier(Me, NumberOfTransfers) + NewThread = New Thread(AddressOf Worker.TransferMoney) + NewThread.Name = "Cashier" & EachWorker.ToString + NewThread.Start() + Next EachWorker + + End Sub + + Public ReadOnly Property AccountOne() As Account + Get + AccountOne = m_AccountOne + End Get + End Property + + Public ReadOnly Property AccountTwo() As Account + Get + AccountTwo = m_AccountTwo + End Get + End Property + +End Class + +Class Cashier + Private m_Bank As Bank, m_WorkerId As Integer + Private m_NumberOfTransfers As Integer + + Public Sub New(ByVal AnyBank As Bank, ByVal NumberOfTransfers As Integer) + m_Bank = AnyBank + m_NumberOfTransfers = NumberOfTransfers + End Sub + + Public Sub TransferMoney() + Dim CurrentTransfer As Integer + + With m_Bank + + For CurrentTransfer = 1 To m_NumberOfTransfers + + If TrueOrFalse() = True Then + SyncLock (.AccountOne) + 'Thread.Sleep(0) + SyncLock (.AccountTwo) + .AccountOne.CreditBalance(100) + .AccountTwo.DebitBalance(100) + Console.WriteLine("{0}: Transfer {1}", _ + Thread.CurrentThread.Name, CurrentTransfer.ToString) + End SyncLock + End SyncLock + Else + SyncLock (.AccountTwo) + 'Thread.Sleep(0) + SyncLock (.AccountOne) + .AccountOne.DebitBalance(100) + .AccountTwo.CreditBalance(100) + Console.WriteLine("{0}: Transfer {1}", _ + Thread.CurrentThread.Name, CurrentTransfer.ToString) + End SyncLock + End SyncLock + End If + Next CurrentTransfer + + End With + + End Sub + + Private Function TrueOrFalse() As Boolean + Randomize() + Dim Test As Single = (Int((2 * Rnd()) + 1)) + Return CBool(Test = 1) + End Function + +End Class + +Class Account + + Private m_AccountBalance As Decimal = 0 + + Public Sub New(ByVal StartingBalance As Decimal) + m_AccountBalance = StartingBalance + End Sub + + Public ReadOnly Property AccountBalance() As Decimal + Get + AccountBalance = m_AccountBalance + End Get + End Property + + Public ReadOnly Property HasSufficientBalance(ByVal AmountToTransfer As Decimal) As Boolean + Get + HasSufficientBalance = CBool(m_AccountBalance >= AmountToTransfer) + End Get + End Property + + Public Function DebitBalance(ByVal AmountToDebit As Decimal) As Decimal + m_AccountBalance -= AmountToDebit + Return m_AccountBalance + End Function + + Public Function CreditBalance(ByVal AmountToCredit As Decimal) As Decimal + m_AccountBalance += AmountToCredit + Return m_AccountBalance + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.sln b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.sln new file mode 100644 index 0000000..8476d3b --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadDeadlock", "ThreadDeadlock.vbproj", "{7864B20A-722A-41F1-BE06-6DCD4C444FED}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Debug.ActiveCfg = Debug|.NET + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Debug.Build.0 = Debug|.NET + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Release.ActiveCfg = Release|.NET + {7864B20A-722A-41F1-BE06-6DCD4C444FED}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.suo b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.suo new file mode 100644 index 0000000..32b5f88 Binary files /dev/null and b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.suo differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj new file mode 100644 index 0000000..7416afb --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj.user b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadDeadlock/ThreadDeadlock.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter14/ThreadGui/AssemblyInfo.vb new file mode 100644 index 0000000..55bb850 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/Calc.vb b/Source/VisualStudio2003/Chapter14/ThreadGui/Calc.vb new file mode 100644 index 0000000..d3f2f26 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/Calc.vb @@ -0,0 +1,46 @@ +Option Strict On + +Public Class Calc + + Private m_NumberToAccumulate As Int32 = 0 + Private m_NumberReached As Int32 = 0 + Private m_RunningTotal As Decimal = 0 + + Public Sub New(ByVal NumberToAccumulate As Int32) + m_NumberToAccumulate = NumberToAccumulate + End Sub + + Public Property NumberToAccumulate() As Int32 + Get + Return m_NumberToAccumulate + End Get + Set(ByVal NewValue As Int32) + m_NumberToAccumulate = NewValue + m_NumberReached = 0 + m_RunningTotal = 0 + End Set + End Property + + Public ReadOnly Property NumberReached() As Int32 + Get + Return m_NumberReached + End Get + End Property + + Public Function Accumulate(ByVal ShowProgressInterval As Int32) As Decimal + Dim LoopCounter As Int32 + + For LoopCounter = m_NumberReached To (m_NumberReached + ShowProgressInterval - 1) + If m_NumberReached <= m_NumberToAccumulate Then + m_RunningTotal += LoopCounter + m_NumberReached += 1 + Else + Exit For + End If + Next LoopCounter + + Return m_RunningTotal + + End Function + +End Class diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/MainForm.resx b/Source/VisualStudio2003/Chapter14/ThreadGui/MainForm.resx new file mode 100644 index 0000000..621c721 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/MainForm.resx @@ -0,0 +1,193 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + Assembly + + + False + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + Assembly + + + False + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Assembly + + + MainForm + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/MainForm.vb b/Source/VisualStudio2003/Chapter14/ThreadGui/MainForm.vb new file mode 100644 index 0000000..c566e05 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/MainForm.vb @@ -0,0 +1,220 @@ +Option Strict On +Imports System.Threading +Imports System.Runtime.Remoting.Messaging + +Public Class MainForm : Inherits System.Windows.Forms.Form + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents cmdCalc As System.Windows.Forms.Button + Friend WithEvents lblResult As System.Windows.Forms.Label + Friend WithEvents txtNumber As System.Windows.Forms.TextBox + Friend WithEvents cmdCancel As System.Windows.Forms.Button + Friend WithEvents Label1 As System.Windows.Forms.Label + Friend WithEvents Label2 As System.Windows.Forms.Label + Friend WithEvents txtInterval As System.Windows.Forms.TextBox + Private Sub InitializeComponent() + Me.cmdCalc = New System.Windows.Forms.Button + Me.txtNumber = New System.Windows.Forms.TextBox + Me.lblResult = New System.Windows.Forms.Label + Me.cmdCancel = New System.Windows.Forms.Button + Me.Label1 = New System.Windows.Forms.Label + Me.Label2 = New System.Windows.Forms.Label + Me.txtInterval = New System.Windows.Forms.TextBox + Me.SuspendLayout() + ' + 'cmdCalc + ' + Me.cmdCalc.Location = New System.Drawing.Point(160, 8) + Me.cmdCalc.Name = "cmdCalc" + Me.cmdCalc.Size = New System.Drawing.Size(144, 40) + Me.cmdCalc.TabIndex = 0 + Me.cmdCalc.Text = "Accumulate" + ' + 'txtNumber + ' + Me.txtNumber.Location = New System.Drawing.Point(24, 24) + Me.txtNumber.Name = "txtNumber" + Me.txtNumber.Size = New System.Drawing.Size(112, 22) + Me.txtNumber.TabIndex = 1 + Me.txtNumber.Text = "10000" + ' + 'lblResult + ' + Me.lblResult.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D + Me.lblResult.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.lblResult.Location = New System.Drawing.Point(16, 128) + Me.lblResult.Name = "lblResult" + Me.lblResult.Size = New System.Drawing.Size(288, 40) + Me.lblResult.TabIndex = 2 + Me.lblResult.Text = "Result is shown here" + ' + 'cmdCancel + ' + Me.cmdCancel.Enabled = False + Me.cmdCancel.Location = New System.Drawing.Point(160, 64) + Me.cmdCancel.Name = "cmdCancel" + Me.cmdCancel.Size = New System.Drawing.Size(144, 40) + Me.cmdCancel.TabIndex = 3 + Me.cmdCancel.Text = "Cancel" + ' + 'Label1 + ' + Me.Label1.Location = New System.Drawing.Point(24, 8) + Me.Label1.Name = "Label1" + Me.Label1.Size = New System.Drawing.Size(88, 16) + Me.Label1.TabIndex = 4 + Me.Label1.Text = "Number" + ' + 'Label2 + ' + Me.Label2.Location = New System.Drawing.Point(24, 64) + Me.Label2.Name = "Label2" + Me.Label2.Size = New System.Drawing.Size(120, 16) + Me.Label2.TabIndex = 6 + Me.Label2.Text = "Display interval" + ' + 'txtInterval + ' + Me.txtInterval.Location = New System.Drawing.Point(24, 80) + Me.txtInterval.Name = "txtInterval" + Me.txtInterval.Size = New System.Drawing.Size(112, 22) + Me.txtInterval.TabIndex = 5 + Me.txtInterval.Text = "100" + ' + 'MainForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(320, 212) + Me.Controls.Add(Me.Label2) + Me.Controls.Add(Me.txtInterval) + Me.Controls.Add(Me.Label1) + Me.Controls.Add(Me.cmdCancel) + Me.Controls.Add(Me.lblResult) + Me.Controls.Add(Me.txtNumber) + Me.Controls.Add(Me.cmdCalc) + Me.Name = "MainForm" + Me.Text = "GUI multithreading" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Delegate Sub CalcDelegate(ByVal AnyNumber As Int32) + Private Delegate Sub ProgressDelegate(ByVal CurrentTotal As Decimal, ByVal NumberReached As Int32, ByRef CancelRequest As Boolean) + Private m_CancelRequested As Boolean = False + + Private Sub ButtonCalc_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCalc.Click + + 'Init calculation + Me.cmdCalc.Enabled = False + Me.cmdCancel.Enabled = True + m_CancelRequested = False + + 'Use asynch delegate to launch new thread from the thread pool + Dim CalcAccumulation As CalcDelegate = New CalcDelegate(AddressOf CalculateAccumulation) + CalcAccumulation.BeginInvoke(Convert.ToInt32(Me.txtNumber.Text), AddressOf CalcComplete, Nothing) + + End Sub + + Private Sub ButtonCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click + + 'Request has been cancelled + m_CancelRequested = True + + End Sub + + Private Sub CalculateAccumulation(ByVal NumberToAccumulate As Int32) + Dim CalcObject As New Calc(NumberToAccumulate), CurrentTotal As Decimal = 0 + Dim CancelRequested As Boolean = False + + With CalcObject + + Do While .NumberReached <= NumberToAccumulate + CurrentTotal = .Accumulate(Convert.ToInt32(Me.txtInterval.Text)) + ShowProgress(CurrentTotal, .NumberReached, CancelRequested) + 'Throw New ApplicationException("Test exception") + If CancelRequested = True Then + Exit Do + End If + Loop + + End With + + End Sub + + Private Sub ShowProgress(ByVal CurrentAccumulation As Decimal, ByVal NumberReached As Int32, ByRef CancelRequest As Boolean) + + If Me.InvokeRequired = True Then + + 'Transfer to GUI thread to show progress + Dim CancelRequested As Object = False + Dim SP As ProgressDelegate = New ProgressDelegate(AddressOf ShowProgress) + Dim Arguments() As Object = New Object() {CurrentAccumulation, NumberReached, CancelRequested} + Me.Invoke(SP, Arguments) + CancelRequest = DirectCast(CancelRequested, Boolean) + + Else + + 'We're on the GUI thread, so just show progress + With Me.lblResult + .Text = "Number reached: " & NumberReached.ToString + .Text += Environment.NewLine + .Text += "Accumulated total: " & CurrentAccumulation.ToString + End With + + 'Pause for a short time to allow user to read display + Thread.CurrentThread.Sleep(100) + + 'Return any cancellation request + CancelRequest = m_CancelRequested + + End If + + End Sub + + Private Sub CalcComplete(ByVal CalcResult As System.IAsyncResult) + Dim Result As AsyncResult = CType(CalcResult, AsyncResult) + Dim OriginalDelegate As CalcDelegate = CType(Result.AsyncDelegate, CalcDelegate) + + 'Called when asynch thread completes + Me.cmdCalc.Enabled = True + Me.cmdCancel.Enabled = False + + Try + 'Find out if anything dodgy happened in the async thread + OriginalDelegate.EndInvoke(CalcResult) + Catch Exc As ApplicationException + MsgBox(Exc.Message, MsgBoxStyle.OKOnly, "Async thread exception") + End Try + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.sln b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.sln new file mode 100644 index 0000000..a5bb0e6 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadGui", "ThreadGui.vbproj", "{DFCF340A-17A9-4859-8638-D4BDED3F4BD0}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Debug.ActiveCfg = Debug|.NET + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Debug.Build.0 = Debug|.NET + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Release.ActiveCfg = Release|.NET + {DFCF340A-17A9-4859-8638-D4BDED3F4BD0}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.suo b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.suo new file mode 100644 index 0000000..311a385 Binary files /dev/null and b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.suo differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.vbproj b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.vbproj new file mode 100644 index 0000000..cd805b7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.vbproj.user b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.vbproj.user new file mode 100644 index 0000000..0d75857 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadGui/ThreadGui.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadGui/obj/Debug/ThreadGui.MainForm.resources b/Source/VisualStudio2003/Chapter14/ThreadGui/obj/Debug/ThreadGui.MainForm.resources new file mode 100644 index 0000000..fb1fcff Binary files /dev/null and b/Source/VisualStudio2003/Chapter14/ThreadGui/obj/Debug/ThreadGui.MainForm.resources differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter14/ThreadMonitor/AssemblyInfo.vb new file mode 100644 index 0000000..db9fc83 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/FactorialCalc.vb b/Source/VisualStudio2003/Chapter14/ThreadMonitor/FactorialCalc.vb new file mode 100644 index 0000000..0831a03 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/FactorialCalc.vb @@ -0,0 +1,18 @@ +Public Class FactorialCalc + + Public Event FactorialComplete(ByVal Factorial As Double, _ + ByVal TotalCalculations As Double) + + Public Shared Sub Factorial() + + Dim Working As Long = 1, FactorialResult As Double = 1 + Dim TotalCalcs As Long = 0 + Threading.Thread.Sleep(5000) + For Working = 1 To 20000000 + FactorialResult *= Working + TotalCalcs += 1 + Next Working + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/MainForm.resx b/Source/VisualStudio2003/Chapter14/ThreadMonitor/MainForm.resx new file mode 100644 index 0000000..c285df5 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/MainForm.resx @@ -0,0 +1,211 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + Assembly + + + 17, 17 + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + Assembly + + + Assembly + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + MainForm + + + True + + + 80 + + + True + + + Assembly + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/MainForm.vb b/Source/VisualStudio2003/Chapter14/ThreadMonitor/MainForm.vb new file mode 100644 index 0000000..56ff97b --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/MainForm.vb @@ -0,0 +1,328 @@ +Option Strict On +Imports System.Threading +Imports System.Diagnostics + +Public Class MainForm : Inherits System.Windows.Forms.Form + + Private UserThreads As New Collection + +#Region " Windows Form Designer generated code " + + Public Sub New() + MyBase.New() + + 'This call is required by the Windows Form Designer. + InitializeComponent() + + 'Add any initialization after the InitializeComponent() call + + End Sub + + 'Form overrides dispose to clean up the component list. + Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) + If disposing Then + If Not (components Is Nothing) Then + components.Dispose() + End If + End If + MyBase.Dispose(disposing) + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + Friend WithEvents ProcessList As System.Windows.Forms.ListBox + Friend WithEvents LabelThread As System.Windows.Forms.Label + Friend WithEvents LabelProcess As System.Windows.Forms.Label + Friend WithEvents ThreadList As System.Windows.Forms.ListView + Friend WithEvents LabelThreadName As System.Windows.Forms.Label + Friend WithEvents DisplayTimer As System.Windows.Forms.Timer + Friend WithEvents LaunchThread As System.Windows.Forms.Button + Friend WithEvents Splitter As System.Windows.Forms.Label + Friend WithEvents ManagedThreadList As System.Windows.Forms.ListView + Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container + Me.ProcessList = New System.Windows.Forms.ListBox + Me.LabelThread = New System.Windows.Forms.Label + Me.LabelProcess = New System.Windows.Forms.Label + Me.ThreadList = New System.Windows.Forms.ListView + Me.LabelThreadName = New System.Windows.Forms.Label + Me.DisplayTimer = New System.Windows.Forms.Timer(Me.components) + Me.LaunchThread = New System.Windows.Forms.Button + Me.Splitter = New System.Windows.Forms.Label + Me.ManagedThreadList = New System.Windows.Forms.ListView + Me.SuspendLayout() + ' + 'ProcessList + ' + Me.ProcessList.ItemHeight = 16 + Me.ProcessList.Location = New System.Drawing.Point(16, 40) + Me.ProcessList.Name = "ProcessList" + Me.ProcessList.Size = New System.Drawing.Size(120, 292) + Me.ProcessList.Sorted = True + Me.ProcessList.TabIndex = 0 + ' + 'LabelThread + ' + Me.LabelThread.Location = New System.Drawing.Point(168, 8) + Me.LabelThread.Name = "LabelThread" + Me.LabelThread.Size = New System.Drawing.Size(168, 24) + Me.LabelThread.TabIndex = 2 + Me.LabelThread.Text = "Win32 threads in process:" + ' + 'LabelProcess + ' + Me.LabelProcess.Location = New System.Drawing.Point(16, 8) + Me.LabelProcess.Name = "LabelProcess" + Me.LabelProcess.Size = New System.Drawing.Size(96, 24) + Me.LabelProcess.TabIndex = 3 + Me.LabelProcess.Text = "Processes" + ' + 'ThreadList + ' + Me.ThreadList.Location = New System.Drawing.Point(176, 40) + Me.ThreadList.Name = "ThreadList" + Me.ThreadList.Size = New System.Drawing.Size(600, 296) + Me.ThreadList.TabIndex = 4 + Me.ThreadList.View = System.Windows.Forms.View.Details + ' + 'LabelThreadName + ' + Me.LabelThreadName.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.8!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.LabelThreadName.Location = New System.Drawing.Point(336, 8) + Me.LabelThreadName.Name = "LabelThreadName" + Me.LabelThreadName.Size = New System.Drawing.Size(128, 24) + Me.LabelThreadName.TabIndex = 5 + Me.LabelThreadName.Text = "Thread name" + ' + 'DisplayTimer + ' + Me.DisplayTimer.Interval = 1000 + ' + 'LaunchThread + ' + Me.LaunchThread.Location = New System.Drawing.Point(16, 384) + Me.LaunchThread.Name = "LaunchThread" + Me.LaunchThread.Size = New System.Drawing.Size(120, 40) + Me.LaunchThread.TabIndex = 6 + Me.LaunchThread.Text = "Launch thread" + ' + 'Splitter + ' + Me.Splitter.BackColor = System.Drawing.SystemColors.ControlDarkDark + Me.Splitter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.Splitter.Font = New System.Drawing.Font("Microsoft Sans Serif", 7.8!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Splitter.Location = New System.Drawing.Point(16, 360) + Me.Splitter.Name = "Splitter" + Me.Splitter.Size = New System.Drawing.Size(760, 3) + Me.Splitter.TabIndex = 7 + ' + 'ManagedThreadList + ' + Me.ManagedThreadList.Location = New System.Drawing.Point(176, 384) + Me.ManagedThreadList.Name = "ManagedThreadList" + Me.ManagedThreadList.Size = New System.Drawing.Size(600, 296) + Me.ManagedThreadList.TabIndex = 8 + Me.ManagedThreadList.View = System.Windows.Forms.View.Details + ' + 'MainForm + ' + Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15) + Me.ClientSize = New System.Drawing.Size(800, 700) + Me.Controls.Add(Me.ManagedThreadList) + Me.Controls.Add(Me.Splitter) + Me.Controls.Add(Me.LaunchThread) + Me.Controls.Add(Me.LabelThreadName) + Me.Controls.Add(Me.ThreadList) + Me.Controls.Add(Me.LabelProcess) + Me.Controls.Add(Me.LabelThread) + Me.Controls.Add(Me.ProcessList) + Me.Name = "MainForm" + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Thread monitor" + Me.ResumeLayout(False) + + End Sub + +#End Region + + Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load + + 'Setup thread display + With Me.ThreadList + .Columns.Add("Id", 50, HorizontalAlignment.Right) + .Columns.Add("Priority", 100, HorizontalAlignment.Left) + .Columns.Add("State", 80, HorizontalAlignment.Left) + .Columns.Add("Wait reason", 120, HorizontalAlignment.Left) + .Columns.Add("Time in app", 100, HorizontalAlignment.Left) + .Columns.Add("Total time", 100, HorizontalAlignment.Left) + End With + + 'Setup managed thread display + With Me.ManagedThreadList + .Columns.Add("Id", 50, HorizontalAlignment.Right) + .Columns.Add("Name", 150, HorizontalAlignment.Left) + .Columns.Add("Priority", 100, HorizontalAlignment.Left) + .Columns.Add("State", 120, HorizontalAlignment.Left) + .Columns.Add("Background?", 100, HorizontalAlignment.Left) + .Columns.Add("Pooled?", 80, HorizontalAlignment.Left) + End With + + 'Show processes + UpdateProcessDisplay() + 'Show Win32 threads for first process + Me.ProcessList.SetSelected(0, True) + 'Set thread displays to update regularly + Me.DisplayTimer.Interval = 1000 + Me.DisplayTimer.Enabled = True + + End Sub + + Private Sub ProcessList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProcessList.SelectedIndexChanged + + 'Display threads for process chosen by end-user + UpdateWin32ThreadDisplay(DirectCast(ProcessList.SelectedItem, Process).Id) + + End Sub + + Private Sub LaunchThread_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LaunchThread.Click + + Dim TempThread As New Thread(New ThreadStart(AddressOf FactorialCalc.Factorial)) + 'User wants new thread - launch and add to collection + With TempThread + .Name = "User thread " & UserThreads.Count.ToString + .Priority = ThreadPriority.BelowNormal + UserThreads.Add(TempThread, .GetHashCode.ToString) + .Start() + End With + + End Sub + + Private Sub DisplayTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DisplayTimer.Tick + + 'Re-display threads for currently-selected process + UpdateUserThreadDisplay() + UpdateWin32ThreadDisplay(DirectCast(ProcessList.SelectedItem, Process).Id) + + End Sub + + Private Sub UpdateProcessDisplay() + Dim MachineProcesses() As Process + + 'Retrieve, store and display processes on this machine + MachineProcesses = Process.GetProcesses() + With Me.ProcessList + .DataSource = MachineProcesses + .DisplayMember = "ProcessName" + End With + + End Sub + + Private Sub UpdateWin32ThreadDisplay(ByVal SelectedProcessId As Integer) + Dim SelectedProcess As Process + Dim ThisThread As ProcessThread, LV_item As ListViewItem + + 'Get Win32 threads for this process and display them + SelectedProcess = Process.GetProcessById(SelectedProcessId) + LabelThreadName.Text = SelectedProcess.ProcessName + + With Me.ThreadList + .BeginUpdate() + .Items.Clear() + + 'Iterate through every Win32 thread in this process + For Each ThisThread In SelectedProcess.Threads + + Try + 'Add thread id + LV_item = New ListViewItem(ThisThread.Id.ToString) + 'Add thread details + With LV_item.SubItems + 'Thread priority + .Add(ThisThread.PriorityLevel.ToString) + 'Thread state + .Add(ThisThread.ThreadState.ToString) + 'Reason for thread wait + If ThisThread.ThreadState = Diagnostics.ThreadState.Wait Then + .Add(ThisThread.WaitReason.ToString) + Else + .Add(vbNullString) + End If + 'Thread time in app + .Add(ThisThread.UserProcessorTime.TotalMilliseconds.ToString) + 'Thread time in OS + .Add(ThisThread.TotalProcessorTime.TotalMilliseconds.ToString) + End With + 'Display the thread + .Items.Add(LV_item) + + Catch Exc As InvalidOperationException + 'Thread's disappeared - ignore + + End Try + + Next ThisThread + + .EndUpdate() + End With + + End Sub + + Private Sub UpdateUserThreadDisplay() + Dim ThisThread As Threading.Thread, LV_item As ListViewItem + + 'Iterate through managed threads for current process + With Me.ManagedThreadList + .BeginUpdate() + .Items.Clear() + + 'Iterate through every thread in this process + For Each ThisThread In UserThreads + + If ThisThread.IsAlive Then + + Try + 'Add thread id + LV_item = New ListViewItem(ThisThread.GetHashCode.ToString) + 'Add thread details + With LV_item.SubItems + 'Add thread name + .Add(ThisThread.Name) + 'Thread priority + .Add(ThisThread.Priority.ToString) + 'Thread state + .Add(ThisThread.ThreadState.ToString) + 'Thread is alive? + .Add(ThisThread.IsAlive.ToString) + 'Background thread? + .Add(ThisThread.IsBackground.ToString) + 'Threadpool thread? + .Add(ThisThread.IsThreadPoolThread.ToString) + End With + 'Display the thread + .Items.Add(LV_item) + + Catch Exc As Threading.ThreadStateException + 'Thread's disappeared - ignore + UserThreads.Remove(ThisThread.GetHashCode.ToString) + + End Try + + Else + + 'Thread's dead - remove from collection + UserThreads.Remove(ThisThread.GetHashCode.ToString) + + End If + + Next ThisThread + + .EndUpdate() + End With + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.sln b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.sln new file mode 100644 index 0000000..5159631 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadMonitor", "ThreadMonitor.vbproj", "{D7CF35FF-B087-4604-8B22-67DB44DC7B50}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Debug.ActiveCfg = Debug|.NET + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Debug.Build.0 = Debug|.NET + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Release.ActiveCfg = Release|.NET + {D7CF35FF-B087-4604-8B22-67DB44DC7B50}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.suo b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.suo new file mode 100644 index 0000000..5171f36 Binary files /dev/null and b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.suo differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.vbproj b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.vbproj new file mode 100644 index 0000000..44d96b7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.vbproj @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.vbproj.user b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.vbproj.user new file mode 100644 index 0000000..29c78d4 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadMonitor/ThreadMonitor.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadMonitor/obj/Debug/ThreadMonitor.MainForm.resources b/Source/VisualStudio2003/Chapter14/ThreadMonitor/obj/Debug/ThreadMonitor.MainForm.resources new file mode 100644 index 0000000..f1a09c6 Binary files /dev/null and b/Source/VisualStudio2003/Chapter14/ThreadMonitor/obj/Debug/ThreadMonitor.MainForm.resources differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadSynch/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter14/ThreadSynch/AssemblyInfo.vb new file mode 100644 index 0000000..3054d09 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadSynch/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadSynch/CountMonitor.vb b/Source/VisualStudio2003/Chapter14/ThreadSynch/CountMonitor.vb new file mode 100644 index 0000000..1ccdc72 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadSynch/CountMonitor.vb @@ -0,0 +1,86 @@ +Option Strict On +Imports System.Threading + +Module CountMonitor + + Sub Main() + Dim CountTest As New CountCoordinator(5) + Console.ReadLine() + End Sub + +End Module + +Class CountCoordinator + + Private Const MAX_COUNT As Integer = 99 + Private m_Counter As Integer = 0 + + Public Sub New(ByVal NumberOfCounters As Integer) + Dim EachWorker As Integer, NewThread As Thread, Worker As CountWorker + + 'Show starting conditions + Console.WriteLine("Count started at {0} with max value of {1}.", _ + CStr(Me.CurrentCount), CStr(Me.MaxCount)) + Console.WriteLine("{0} worker threads are doing the counting.", _ + CStr(NumberOfCounters)) + 'Start specified number of worker threads + For EachWorker = 1 To NumberOfCounters + Worker = New CountWorker(Me, EachWorker) + NewThread = New Thread(AddressOf Worker.IncrementCount) + NewThread.Start() + Next EachWorker + + End Sub + + Public Property CurrentCount() As Integer + Get + Return m_Counter + End Get + Set(ByVal Value As Integer) + m_Counter = Value + End Set + End Property + + Public ReadOnly Property MaxCount() As Integer + Get + Return MAX_COUNT + End Get + End Property + +End Class + +Class CountWorker + Private m_Coordinator As CountCoordinator + Private m_WorkerId As Integer + + Public Sub New(ByVal Coordinator As CountCoordinator, ByVal WorkerId As Integer) + m_Coordinator = Coordinator + m_WorkerId = WorkerId + End Sub + + Public Sub IncrementCount() + + 'Increment shared counter until equal to maximum allowed + With m_Coordinator + + Do While .CurrentCount < .MaxCount + 'SyncLock (m_Coordinator) + Select Case .CurrentCount + Case Is < (.MaxCount - 10) + Thread.Sleep(0) + .CurrentCount += 10 + Case Is < .MaxCount + Thread.Sleep(0) + .CurrentCount += 1 + Case Else + End Select + 'End SyncLock + Console.WriteLine("Worker {0} current count {1}", _ + CStr(m_WorkerId), CStr(.CurrentCount)) + Loop + + End With + + End Sub + +End Class diff --git a/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.sln b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.sln new file mode 100644 index 0000000..af0185a --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.sln @@ -0,0 +1,21 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "ThreadSynch", "ThreadSynch.vbproj", "{970BC01E-8AA4-445D-B714-C5C376206C09}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {970BC01E-8AA4-445D-B714-C5C376206C09}.Debug.ActiveCfg = Debug|.NET + {970BC01E-8AA4-445D-B714-C5C376206C09}.Debug.Build.0 = Debug|.NET + {970BC01E-8AA4-445D-B714-C5C376206C09}.Release.ActiveCfg = Release|.NET + {970BC01E-8AA4-445D-B714-C5C376206C09}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.suo b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.suo new file mode 100644 index 0000000..4e20daa Binary files /dev/null and b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.suo differ diff --git a/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.vbproj b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.vbproj new file mode 100644 index 0000000..0f017c1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.vbproj.user b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.vbproj.user new file mode 100644 index 0000000..ae74d43 --- /dev/null +++ b/Source/VisualStudio2003/Chapter14/ThreadSynch/ThreadSynch.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/Heartbeat/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter15/Heartbeat/AssemblyInfo.vb new file mode 100644 index 0000000..83b7225 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/Heartbeat/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vb b/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vb new file mode 100644 index 0000000..f4660be --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vb @@ -0,0 +1,20 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting.Messaging + +Public Class Heartbeat : Inherits MarshalByRefObject + Public Event HeartbeatLocal(ByVal LocalComponent As String) + Public Event HeartbeatRemote(ByVal LocalMonitor As String, ByVal StatusReport As String) + + _ + Public Sub Heartbeat(ByVal LocalComponent As String) + RaiseEvent HeartbeatLocal(LocalComponent) + End Sub + + _ + Public Sub RemoteHeartbeat(ByVal LocalMonitor As String, ByVal StatusReport As String) + RaiseEvent HeartbeatRemote(LocalMonitor, StatusReport) + End Sub + +End Class \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vbproj b/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vbproj new file mode 100644 index 0000000..cf52775 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vbproj @@ -0,0 +1,97 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vbproj.user b/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vbproj.user new file mode 100644 index 0000000..9715303 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/Heartbeat/Heartbeat.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/HeartbeatClient/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter15/HeartbeatClient/AssemblyInfo.vb new file mode 100644 index 0000000..2c8b8da --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/HeartbeatClient/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vb b/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vb new file mode 100644 index 0000000..435b7d7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vb @@ -0,0 +1,48 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting +Imports Monitoring +Imports System.Threading + +Module Client + Private Const MY_ID As String = "Client" + Private Delegate Sub HeartbeatThread(ByVal HeartbeatInterval As Int32) + Private m_StopHeartbeats As Boolean = False + + Sub Main() + + Console.WriteLine("Starting client") + Dim HT As New HeartbeatThread(AddressOf Heartbeats) + Dim ThreadResult As IAsyncResult = HT.BeginInvoke(2, Nothing, Nothing) + + Console.WriteLine("Press 'Enter' to terminate client...") + Console.ReadLine() + + Console.WriteLine("Terminating client") + m_StopHeartbeats = True + HT.EndInvoke(ThreadResult) + + End Sub + + Private Sub Heartbeats(ByVal HeartbeatInterval As Int32) + + 'Find local monitor + Console.WriteLine("Finding local monitor") + Dim Listener As New Heartbeat + Listener = CType(Activator.GetObject(GetType(Heartbeat), _ + "tcp://localhost:8080/Heartbeat.dll"), Heartbeat) + + 'Send regular heartbeats to local monitor + Do While m_StopHeartbeats = False + Listener.Heartbeat(MY_ID) + Console.WriteLine("Heartbeat sent to local monitor") + Thread.Sleep(HeartbeatInterval * 1000) + Loop + + 'Terminate heartbeat thread + Console.WriteLine("Stopping heartbeats") + + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vbproj b/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vbproj new file mode 100644 index 0000000..fe77add --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vbproj @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vbproj.user b/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vbproj.user new file mode 100644 index 0000000..100994d --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/HeartbeatClient/HeartbeatClient.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/HeartbeatMonitor.sln b/Source/VisualStudio2003/Chapter15/HeartbeatMonitor.sln new file mode 100644 index 0000000..6d6eadf --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/HeartbeatMonitor.sln @@ -0,0 +1,48 @@ +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "LocalMonitor", "LocalMonitor\LocalMonitor.vbproj", "{0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}" + ProjectSection(ProjectDependencies) = postProject + {938247CE-2129-436B-9133-48AF121B1E0A} = {938247CE-2129-436B-9133-48AF121B1E0A} + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Heartbeat", "Heartbeat\Heartbeat.vbproj", "{938247CE-2129-436B-9133-48AF121B1E0A}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "HeartbeatClient", "HeartbeatClient\HeartbeatClient.vbproj", "{9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}" + ProjectSection(ProjectDependencies) = postProject + {938247CE-2129-436B-9133-48AF121B1E0A} = {938247CE-2129-436B-9133-48AF121B1E0A} + EndProjectSection +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RemoteMonitor", "RemoteMonitor\RemoteMonitor.vbproj", "{1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}" + ProjectSection(ProjectDependencies) = postProject + {938247CE-2129-436B-9133-48AF121B1E0A} = {938247CE-2129-436B-9133-48AF121B1E0A} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Debug.ActiveCfg = Debug|.NET + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Debug.Build.0 = Debug|.NET + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Release.ActiveCfg = Release|.NET + {0C431FCE-CEAA-4DD1-B39C-B7D208FEED47}.Release.Build.0 = Release|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Debug.ActiveCfg = Debug|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Debug.Build.0 = Debug|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Release.ActiveCfg = Release|.NET + {938247CE-2129-436B-9133-48AF121B1E0A}.Release.Build.0 = Release|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Debug.ActiveCfg = Debug|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Debug.Build.0 = Debug|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Release.ActiveCfg = Release|.NET + {9CA4D5F1-4EE6-4EFC-AA25-37BDF22F2A06}.Release.Build.0 = Release|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Debug.ActiveCfg = Debug|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Debug.Build.0 = Debug|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Release.ActiveCfg = Release|.NET + {1F37FA75-2C1B-4BA3-A02D-2B2680C6EBE4}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/Source/VisualStudio2003/Chapter15/HeartbeatMonitor.suo b/Source/VisualStudio2003/Chapter15/HeartbeatMonitor.suo new file mode 100644 index 0000000..adc7a9f Binary files /dev/null and b/Source/VisualStudio2003/Chapter15/HeartbeatMonitor.suo differ diff --git a/Source/VisualStudio2003/Chapter15/LocalMonitor/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter15/LocalMonitor/AssemblyInfo.vb new file mode 100644 index 0000000..399c034 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/LocalMonitor/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.config b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.config new file mode 100644 index 0000000..ef56b34 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vb b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vb new file mode 100644 index 0000000..e57688c --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vb @@ -0,0 +1,65 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting +Imports System.Threading +Imports Monitoring + +Module Monitor + Private Const MY_ID As String = "LocalMonitor" + Private Delegate Sub HeartbeatThread(ByVal HeartbeatInterval As Int32) + Private m_StopHeartbeats As Boolean = False + Private m_StatusReport As String = "No heartbeats received" + Private WithEvents m_Listener As Heartbeat + + Sub Main() + + Console.WriteLine("Starting local monitor") + RemotingConfiguration.Configure("LocalMonitor.config") + + Console.WriteLine("Creating local listener") + m_Listener = New Heartbeat + RemotingServices.Marshal(m_Listener, "Heartbeat.dll") + + Dim HT As New HeartbeatThread(AddressOf Heartbeats) + Dim ThreadResult As IAsyncResult = HT.BeginInvoke(10, Nothing, Nothing) + + Console.WriteLine("Now listening - press 'Enter' to terminate local monitor...") + Console.ReadLine() + + Console.WriteLine("Local monitor terminating") + m_StopHeartbeats = True + HT.EndInvoke(ThreadResult) + + RemotingServices.Disconnect(m_Listener) + m_Listener = Nothing + + End Sub + + Private Sub Heartbeats(ByVal HeartbeatInterval As Int32) + + 'Find remote monitor + Console.WriteLine("Finding remote monitor") + Dim Listener As New Heartbeat + Listener = CType(Activator.GetObject(GetType(Heartbeat), _ + "tcp://localhost:8081/Heartbeat.dll"), Heartbeat) + + 'Send regular heartbeats to remote monitor + Do While m_StopHeartbeats = False + Listener.RemoteHeartbeat(MY_ID, m_StatusReport) + Console.WriteLine("Heartbeat sent to remote monitor") + Thread.Sleep(HeartbeatInterval * 1000) + Loop + + 'Terminate heartbeat thread + Console.WriteLine("Stopping heartbeats") + + End Sub + + Private Sub m_Listener_HeartbeatLocal(ByVal LocalComponent As String) Handles m_Listener.HeartbeatLocal + 'Listen for regular heartbeats from local component + Console.WriteLine("Heartbeat received from " & LocalComponent) + m_StatusReport = "Last heartbeat received from " & LocalComponent & " at " & Format$(Now, "hh:mm:ss") + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vbproj b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vbproj new file mode 100644 index 0000000..cc552f7 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vbproj @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vbproj.user b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vbproj.user new file mode 100644 index 0000000..a4bbe1c --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/LocalMonitor/LocalMonitor.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/LocalMonitor/bin/LocalMonitor.config b/Source/VisualStudio2003/Chapter15/LocalMonitor/bin/LocalMonitor.config new file mode 100644 index 0000000..ef56b34 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/LocalMonitor/bin/LocalMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/RemoteMonitor/AssemblyInfo.vb b/Source/VisualStudio2003/Chapter15/RemoteMonitor/AssemblyInfo.vb new file mode 100644 index 0000000..a1564e1 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/RemoteMonitor/AssemblyInfo.vb @@ -0,0 +1,32 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' General Information about an assembly is controlled through the following +' set of attributes. Change these attribute values to modify the information +' associated with an assembly. + +' Review the values of the assembly attributes + + + + + + + + + +'The following GUID is for the ID of the typelib if this project is exposed to COM + + +' Version information for an assembly consists of the following four values: +' +' Major Version +' Minor Version +' Build Number +' Revision +' +' You can specify all the values or you can default the Build and Revision Numbers +' by using the '*' as shown below: + + diff --git a/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.config b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.config new file mode 100644 index 0000000..07bfeb3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vb b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vb new file mode 100644 index 0000000..3669571 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vb @@ -0,0 +1,34 @@ +Option Strict On + +Imports System +Imports System.Runtime.Remoting +Imports Monitoring + +Module RemoteMonitor + Private WithEvents m_Listener As Heartbeat + + Sub Main() + + Console.WriteLine("Starting remote monitor") + RemotingConfiguration.Configure("RemoteMonitor.config") + + Console.WriteLine("Creating remote listener") + m_Listener = New Heartbeat + RemotingServices.Marshal(m_Listener, "Heartbeat.dll") + + Console.WriteLine("Now listening - press 'Enter' to terminate remote monitor...") + Console.ReadLine() + + Console.WriteLine("Remote monitor terminating") + RemotingServices.Disconnect(m_Listener) + m_Listener = Nothing + + End Sub + + Private Sub m_Listener_HeartbeatRemote(ByVal LocalMonitor As String, ByVal StatusReport As String) Handles m_Listener.HeartbeatRemote + 'Listen for regular heartbeats from local monitor + Console.WriteLine("Status report received from " & LocalMonitor) + Console.WriteLine(StatusReport) + End Sub + +End Module diff --git a/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vbproj b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vbproj new file mode 100644 index 0000000..6b4a179 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vbproj @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vbproj.user b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vbproj.user new file mode 100644 index 0000000..1eaa4fe --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/RemoteMonitor/RemoteMonitor.vbproj.user @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Source/VisualStudio2003/Chapter15/RemoteMonitor/bin/RemoteMonitor.config b/Source/VisualStudio2003/Chapter15/RemoteMonitor/bin/RemoteMonitor.config new file mode 100644 index 0000000..07bfeb3 --- /dev/null +++ b/Source/VisualStudio2003/Chapter15/RemoteMonitor/bin/RemoteMonitor.config @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/contributing.md b/contributing.md new file mode 100644 index 0000000..f6005ad --- /dev/null +++ b/contributing.md @@ -0,0 +1,14 @@ +# Contributing to Apress Source Code + +Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. + +## How to Contribute + +1. Make sure you have a GitHub account. +2. Fork the repository for the relevant book. +3. Create a new branch on which to make your change, e.g. +`git checkout -b my_code_contribution` +4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. +5. Submit a pull request. + +Thank you for your contribution! \ No newline at end of file