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:
> 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
> > 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