![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Specified cast is not valid Hello, I have declared a Public Class MDIMenu that Inherits from System.Windows.Forms.Form. In the InitializeComponent Sub I declare it as a MdiContainer with this statement: Me.IsMdiContainer = True In my Sub Main I start my application by calling an instance of the MDIMenu class in this way: Dim frm As New MDIMenu Application.Run(frm) I get this error: Specified cast is not valid When I build or rebuild my solution I don't get no build error's and I can't trace the error further than the command Application.Run(frm). So can anyone give me a suggestion what could have gone wrong here? I already tried to make an other, simpler form to start with, but I get the same error. -- RW |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Specified cast is not valid "RW" <RW@xxxxxx> wrote in message news:5CBC9DF7-92CE-4E6F-B78E-FD12A193BD61@xxxxxx Quote: > Hello, > > I have declared a Public Class MDIMenu that Inherits from > System.Windows.Forms.Form. > > In the InitializeComponent Sub I declare it as a MdiContainer with this > statement: Me.IsMdiContainer = True > > In my Sub Main I start my application by calling an instance of the > MDIMenu > class in this way: > > Dim frm As New MDIMenu > Application.Run(frm) > > I get this error: Specified cast is not valid > > When I build or rebuild my solution I don't get no build error's and I > can't > trace the error further than the command Application.Run(frm). > > So can anyone give me a suggestion what could have gone wrong here? > > I already tried to make an other, simpler form to start with, but I get > the > same error. > (MDIMenu) to a System.Windows.Form. which is what Application.Run() wants is a form. http://msdn2.microsoft.com/en-us/lib...un(VS.71).aspx |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Specified cast is not valid Thanks Mr. Arnold, yes, I know what casting is. and I have declared the Public Class MDIMenu so that it inherits from System.Windows.Forms.Form, so my frm is a form. but even when I do it like this: Dim frm As System.Windows.Forms.Form = New MDIMenu Application.Run(frm) still gives the same error I even tried it with a regular form, not an inherited class, and it doesn't work. btw Option Strict is On -- RW "Mr. Arnold" wrote: Quote: > > "RW" <RW@xxxxxx> wrote in message > news:5CBC9DF7-92CE-4E6F-B78E-FD12A193BD61@xxxxxx Quote: > > Hello, > > > > I have declared a Public Class MDIMenu that Inherits from > > System.Windows.Forms.Form. > > > > In the InitializeComponent Sub I declare it as a MdiContainer with this > > statement: Me.IsMdiContainer = True > > > > In my Sub Main I start my application by calling an instance of the > > MDIMenu > > class in this way: > > > > Dim frm As New MDIMenu > > Application.Run(frm) > > > > I get this error: Specified cast is not valid > > > > When I build or rebuild my solution I don't get no build error's and I > > can't > > trace the error further than the command Application.Run(frm). > > > > So can anyone give me a suggestion what could have gone wrong here? > > > > I already tried to make an other, simpler form to start with, but I get > > the > > same error. > > > You do know what *cast* means don't you? You can't cast a Windows.Control > (MDIMenu) to a System.Windows.Form. which is what Application.Run() wants is > a form. > > http://msdn2.microsoft.com/en-us/lib...un(VS.71).aspx > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Specified cast is not valid Hey thanks, The complete code is this: Public Sub Main() Try m_CurrentUser = New ApplicationUser m_CurrentUser.NTLogin = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Substring(System.Security.Principal.WindowsIdentity.GetCurrent().Name.IndexOf("\") + 1).ToUpper() Dim p As New SQLParameter("@NTLogin", m_CurrentUser.NTLogin) Dim pl(0) As SQLParameter pl(0) = p Dim exm As New ExchangeManager Dim ds As DataSet = exm.GetDataSet("SQLStatements", "GetUser", pl) For Each dr As DataRow In ds.Tables(0).Rows With dr If CType(.Item("IsActive"), Boolean) Then m_CurrentUser.PK_Gebruiker = CType(.Item("PK_User"), Guid) m_CurrentUser.UserFirstName = ..Item("FirstName").ToString m_CurrentUser.UserLastname = ..Item("Lastname").ToString m_CurrentUser.UserEmail = .Item("EMail").ToString Else Throw New ApplicationException("User " & ..Item("FirstName").ToString & " " & .Item("Lastname").ToString & " is inactive!") End If End With Next If m_CurrentUser.UserEmail = System.String.Empty Then Throw New ApplicationException(m_CurrentUser.NTLogin & " is not a registred user!") End If Dim frm As New MDIMenu Application.Run(frm) frm.Text = "..." Catch ex As System.Exception If MessageBox.Show(ex.Message, "...", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) = DialogResult.OK Then Application.Exit() End If End Try End Sub -- RW "dlm@xxxxxx" wrote: Quote: > Hi, > > your code is OK and I would said that your error is somewhere else. Can remember that we had similar problems, but in another thread (splash window) and application reported invalid cast from that thread. It would be very interesting for me to see whole Main static function if possible. > > Best regards, > dlm@xxxxxx > Compare SQL Server, MySQL and Oracle for free - DBTyP.NET > www.bypsoft.com > > > > "RW" <RW@xxxxxx> schrieb im Newsbeitrag news:5CBC9DF7-92CE-4E6F-B78E-FD12A193BD61@xxxxxx Quote: > > Hello, > > > > I have declared a Public Class MDIMenu that Inherits from > > System.Windows.Forms.Form. > > > > In the InitializeComponent Sub I declare it as a MdiContainer with this > > statement: Me.IsMdiContainer = True > > > > In my Sub Main I start my application by calling an instance of the MDIMenu > > class in this way: > > > > Dim frm As New MDIMenu > > Application.Run(frm) > > > > I get this error: Specified cast is not valid > > > > When I build or rebuild my solution I don't get no build error's and I can't > > trace the error further than the command Application.Run(frm). > > > > So can anyone give me a suggestion what could have gone wrong here? > > > > I already tried to make an other, simpler form to start with, but I get the > > same error. > > > > > > -- > > RW |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Type cast | PowerShell | |||
| Cast from one generic IDictionary to another | .NET General | |||
| meaning of this cast ? | PowerShell | |||
| Verizon V-cast software | Vista General | |||
| Yellow cast issue... | Vista music pictures video | |||