Re: Not first class in file
- From: "tshad" <tfs@xxxxxxxxxxxxxx>
- Date: Sun, 23 Jul 2006 22:38:15 -0700
"Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP@xxxxxxxxxxxxx> wrote in
message news:%23BlDc6mrGHA.5032@xxxxxxxxxxxxxxxxxxxxxxx
Tom,by
I find its "Better" to have each type have its own file. Naming each file
for what it contains. As its then immediately obvious what's in the file
looking at the file name. Plus you avoid this warning message.
So if you have 3 types (classes):
| CMailMessage
| EmailPoller (the offending Class)
| Project Installer.
You would have 3 files:|
| EmailPoller.vb
| ProjectInstaller.vb (which is created automatically).
CMailMessage.vb
As the message implies, the "designers" in VS expect the class to be first
type in a file... The Windows Service has a designer as it (EmailPoller)
inherits from ServiceBase which inherits from Component. Component has a
designer associated with it.
But why does it work OK in 2002 but not in 2003?
Tom
the
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"tshad" <tscheiderich@xxxxxxxxxxxxxxx> wrote in message
news:e6$zAUOrGHA.1796@xxxxxxxxxxxxxxxxxxxxxxx
|I have a problem with a VS 2003 project.
|
| This project was designed and works fine in VS 2003.
|
| But trying to open the project I get the following error.
| ************************************************************
| The class EmailPoller can be designed, but is not the first class in the
| file. Visual Studio requires that designers use the first class in the
| file. Move the class code so that it is the first class in the file and
try
| loading the designer again.
| **************************************************************
|
| Not sure why this is a problem. This is a Windows Service I am creating
| with 3 Classes:
|
| CMailMessage
| EmailPoller (the offending Class)
| Project Installer.
|
| There are 2 files:
|
| EmailPoller.vb
| ProjectInstaller.vb (which is created automatically).
|
| In the following code, do I just move the "Class CmailMessage" code to
| bottom of the source file?System.Data.SqlClient.SqlCommand
|
| If that is the case, why?
|
| I didn't have to do that in VS 2002.
|
| The first part of the EmailPoller.vb file is:
| **************************************************
| Imports System.ServiceProcess
| Imports System.Web.Mail
| Imports System.Data.SqlClient
| Imports System.IO
|
| Class CEmailMessage
| Public id As Integer
| Public strTo As String
| Public strCC As String
| Public strBCC As String
| Public strFrom As String
| Public strSubject As String
| Public strBody As String
| Public isHTML As Integer
| Public dateAttempted As Date
| Public status As Integer
| Public errMessage As String
| End Class
|
| Public Class EmailPoller
| Inherits System.ServiceProcess.ServiceBase
| Friend WithEvents cmd_get_poller_settings As
| System.Data.SqlClient.SqlCommand
| Friend WithEvents cmd_update_msg As System.Data.SqlClient.SqlCommand
| Friend WithEvents SqlSelectCommand1 As
| Const ATTEMPTED = 2add
| Const SENT = 3
| Dim strProgress As String
|
| #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
| 'LogInfo("Completed New()")
| End Sub
|
| 'UserService overrides dispose to clean up the component list.
| Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
| If disposing Then
| 'LogInfo("In Dispose()")
| If Not (components Is Nothing) Then
| components.Dispose()
| End If
| End If
| MyBase.Dispose(disposing)
| End Sub
|
| ' The main entry point for the process
| <MTAThread()> _
| Shared Sub Main()
| Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
| ' More than one NT Service may run within the same process. To
| ' another service to this process, change the following line toSystem.Data.SqlClient.SqlConnection
| ' create a second service object. For example,
| '
| ' ServicesToRun = New System.ServiceProcess.ServiceBase () {New
| Service1, New MySecondUserService}
| '
| ServicesToRun = New System.ServiceProcess.ServiceBase() {New
| EmailPoller()}
|
| System.ServiceProcess.ServiceBase.Run(ServicesToRun)
| 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 EmailQueueTimer As System.Timers.Timer
| Friend WithEvents SqlConnection1 As
| Friend WithEvents da_get_messages AsSystem.Data.SqlClient.SqlCommand()
| System.Data.SqlClient.SqlDataAdapter
| <System.Diagnostics.DebuggerStepThrough()> Private Sub
| InitializeComponent()
| Me.EmailQueueTimer = New System.Timers.Timer()
| Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection()
| Me.da_get_messages = New System.Data.SqlClient.SqlDataAdapter()
| Me.cmd_get_poller_settings = New
| Me.cmd_update_msg = New System.Data.SqlClient.SqlCommand()System.Data.ParameterDirection.ReturnValue,
| Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
| CType(Me.EmailQueueTimer,
| System.ComponentModel.ISupportInitialize).BeginInit()
|
| 'LogInfo("Init EmailQueueTimer")
| '
| 'EmailQueueTimer
| '
| Me.EmailQueueTimer.Enabled = True
| Me.EmailQueueTimer.Interval = 10000
| '
| 'LogInfo("Init SqlConnection1")
| 'SqlConnection1
| '
| Me.SqlConnection1.ConnectionString = "data source=VENUS;initial
| catalog=FTSolutions;password=web4pay;persist security i" & _
| "nfo=True;user id=ftsweb;workstation id=PROGRAMMER1;packet
| size=4096"
| '
| 'da_get_messages
| '
| Me.da_get_messages.SelectCommand = Me.SqlSelectCommand1
| '
| 'cmd_get_poller_settings
| '
| Me.cmd_get_poller_settings.CommandText =
| "dbo.[COM_GET_EMAIL_QUEUE_SETTINGS_SP]"
| Me.cmd_get_poller_settings.CommandType =
| System.Data.CommandType.StoredProcedure
| Me.cmd_get_poller_settings.Connection = Me.SqlConnection1
| Me.cmd_get_poller_settings.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
| System.Data.SqlDbType.Int, 4,
| False, CType(10, Byte), CType(0, Byte), "",System.Data.ParameterDirection.ReturnValue,
| System.Data.DataRowVersion.Current, Nothing))
| '
| 'cmd_update_msg
| '
| Me.cmd_update_msg.CommandText =
| "dbo.[COM_UPDATE_EMAIL_QUEUE_MSG_STATUS_SP]"
| Me.cmd_update_msg.CommandType =
| System.Data.CommandType.StoredProcedure
| Me.cmd_update_msg.Connection = Me.SqlConnection1
| Me.cmd_update_msg.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
| System.Data.SqlDbType.Int, 4,
| False, CType(10, Byte), CType(0, Byte), "",System.Data.ParameterDirection.ReturnValue,
| System.Data.DataRowVersion.Current, Nothing))
| Me.cmd_update_msg.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@id", System.Data.SqlDbType.Int, 4,
| System.Data.ParameterDirection.Input, False, CType(10, Byte), CType(0,
| Byte), "", System.Data.DataRowVersion.Current, Nothing))
| Me.cmd_update_msg.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@status",
System.Data.SqlDbType.TinyInt,
| 1, System.Data.ParameterDirection.Input, False, CType(3, Byte), CType(0,
| Byte), "", System.Data.DataRowVersion.Current, Nothing))
| Me.cmd_update_msg.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@date_attempted",
| System.Data.SqlDbType.DateTime, 8))
| Me.cmd_update_msg.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@error_message",
| System.Data.SqlDbType.VarChar, 100))
| '
| 'SqlSelectCommand1
| '
| Me.SqlSelectCommand1.CommandText =
| "dbo.[COM_GET_EMAIL_QUEUE_MESSAGES_SP]"
| Me.SqlSelectCommand1.CommandType =
| System.Data.CommandType.StoredProcedure
| Me.SqlSelectCommand1.Connection = Me.SqlConnection1
| Me.SqlSelectCommand1.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@RETURN_VALUE",
| System.Data.SqlDbType.Int, 4,
| False, CType(10, Byte), CType(0, Byte), "",System.Data.SqlDbType.Int,
| System.Data.DataRowVersion.Current, Nothing))
| Me.SqlSelectCommand1.Parameters.Add(New
| System.Data.SqlClient.SqlParameter("@quantity",
| 4, System.Data.ParameterDirection.Input, False, CType(10, Byte),CType(0,
| Byte), "", System.Data.DataRowVersion.Current, Nothing))As
| '
| 'EmailPoller
| '
| Me.CanPauseAndContinue = True
| Me.ServiceName = "EmailPoller"
| CType(Me.EmailQueueTimer,
| System.ComponentModel.ISupportInitialize).EndInit()
|
| End Sub
|
| #End Region
|
| Protected Overrides Sub OnStart(ByVal args() As String)
| 'LogInfo("EmailPoller Started")
| EmailQueueTimer.Start()
| End Sub
|
| Protected Overrides Sub OnStop()
| 'LogInfo("EmailPoller Stopped")
| EmailQueueTimer.Stop()
| End Sub
|
| Private Sub EmailQueueTimer_Elapsed(ByVal sender As System.Object,
ByVal
| e As System.Timers.ElapsedEventArgs) Handles EmailQueueTimer.Elapsed
| 'LogInfo("EmailPoller Timer Interval")
| PollAndSendEmail()
| End Sub
|
| Private Sub PollAndSendEmail()
| Try
| 'LogInfo("PollAndSend() Starting")
|
| Dim strSMTPServer, strSMTPUserID, strSMTPPwd As String
| Dim isHTML, intInterval, intMsgQuantity, intProcessMessages
| Integer
| Dim DR As SqlDataReader
|
| ' grab our poller/email settings from DB
| strProgress = "About to open connection"
| dbOpenConnection()
|
| strProgress = "About to execute the reader"
|
| ***************************************************
|
| Thanks,
|
| Tom
|
|
.
- Follow-Ups:
- Re: Not first class in file
- From: Jay B. Harlow [MVP - Outlook]
- Re: Not first class in file
- References:
- Not first class in file
- From: tshad
- Re: Not first class in file
- From: Jay B. Harlow [MVP - Outlook]
- Not first class in file
- Prev by Date: Re: Wounder why not the same BindingContext???
- Next by Date: Re: run form without this
- Previous by thread: Re: Not first class in file
- Next by thread: Re: Not first class in file
- Index(es):
Relevant Pages
|