My Project Contain call to SetSession ManyTime SomeTime it's Crashing. Please any one can help me.
Here section code:
public Function SetSession(sSessionName As String) As Boolean
Dim intCount As Integer
'Call Refresh
SetSession = False
Dim oSessions As ExtaSessions = Nothing
Dim oSession As ExtraSession = Nothing
moSession = Nothing
oSessions=TryCast(moSystem.Sessions,ExtraSessions)
moSession=TryCast(oSessions.Item(sSessionName),ExtraSession)'=> Crashing in this line
If Information.Err().Number <> 0 Then
For intcount = 1 To oSessions.Count
oSession = TryCast(oSessions.Item(intCount), ExtraSession)
if oSession.Name = sSessionName then
moSession = oSession
Exit for
End if
NExt
End if
if moSession is Nothing then
Exit Function End If
SetSession = True
End Function
In following attachment PrintScreen for Exception
Finnaly I fix my problem
before change:
Dim oSessions As ExtaSessions = Nothing
Dim oSession As ExtraSession = Nothing
moSession = Nothing
oSessions=TryCast(moSystem.Sessions,ExtraSessions)
moSession=TryCast(oSessions.Item(sSessionName),ExtraSession)
after change:
Dim oSessions As EXTRA.ExtraSessions
Dim oSession As EXTRA.ExtraSession
moSession = Nothing
moSystem = New Extra.ExtraSystem
Try
oSessions = DirectCast(moSystem.Sessions,EXTRA.ExtraSessions)
moSession = DirectCast(oSessions.Item(sSessionName),EXTRA.ExtraSession)
Catch ex As Exception
Interaction.MsgBox(ex)
End Try
I just Init moSystem to Extra.ExtraSystem
and i changed ExtaSessions to EXTRA.ExtraSessions
and DirectCast to trycast and it's work 100%
thx :)
Related
I have built this VBA function but I'm getting the below error (see the next screenshot) in the below portion of the code:
Set RstUserAccess.ActiveConnection = Nothing
RstUserAccess.Close
Public Sub UserLogoutDetail(UserEmail As String)
Dim MySQL As String
Dim RstUserAccess As New ADODB.Recordset
Dim CmdUserAccess As New ADODB.Command
Dim i As Integer
'Setup the command
Set CmdUserAccess.ActiveConnection = fGetConn
CmdUserAccess.CommandType = adCmdText
MySQL = "UPDATE User_Access_TABLE SET EXIT_DATA = #" & Now & "# WHERE (((ID)=" & GetID_ToUpdate(UserEmail) & "))"
CmdUserAccess.CommandText = MySQL
RstUserAccess.CursorLocation = adUseClient
RstUserAccess.CursorType = adOpenDynamic
RstUserAccess.LockType = adLockOptimistic
'Open the connection
RstUserAccess.Open CmdUserAccess
Set RstUserAccess.ActiveConnection = Nothing
RstUserAccess.Close
'Cleanup
If CBool(CmdUserAccess.State And adStateOpen) = True Then
Set CmdUserAccess = Nothing
End If
If CBool(fGetConn.State And adStateOpen) = True Then
CloseConn
End If
End Sub
Error message
Do you have any suggestion?
Thanks
I have tried to change my code many times
I have a pretty simple code snippet here that is causing me a lot of problems. I also want to mention that using statements should be used, but the code was not originally authored by me. I'll likely fix this at some point
Dim dbShippableOpenOrders As New sqlCommand(sqlText, objConn)
Dim rsShippableOpenOrders As sqlDataReader = dbShippableOpenOrders.executeReader
...
If IsDBNull(rsShippableOpenOrders("cost")) Then
cost = 0
Else
cost = rsShippableOpenOrders("cost")
End If
I can't seem to figure out why this code is producing the following error message:
Conversion overflows.
Description: An unhandled exception occurred
during the execution of the current web request. Please review the
stack trace for more information about the error and where it
originated in the code.
Exception Details: System.OverflowException: Conversion overflows.
Source Error:
Line 355: End If
Line 356:
Line 357: If IsDBNull(rsShippableOpenOrders("cost")) Then
Line 358: cost = 0
Line 359: Else
Try the following:
Dim cost As Decimal = 0
Dim dbShippableOpenOrders As New SqlCommand(sqlText, objConn)
Dim rsShippableOpenOrders As SqlDataReader = dbShippableOpenOrders.ExecuteReader()
If rsShippableOpenOrders.HasRows Then
While rsShippableOpenOrders.Read()
If rsShippableOpenOrders("cost") IsNot Nothing AndAlso Not IsDBNull(rsShippableOpenOrders("cost")) Then
cost = CDec(rsShippableOpenOrders("cost"))
Else
cost = 0
End If
End While
End If
Here's a sample method:
Public Sub GetDataTblProduct(connectionStr As String)
Dim sqlText As String = "Select * from Product"
Dim cost As Decimal = 0
Using con As SqlConnection = New SqlConnection(connectionStr)
'open
con.Open()
Using dbShippableOpenOrders As SqlCommand = New SqlCommand(sqlText, con)
Using rsShippableOpenOrders As SqlDataReader = dbShippableOpenOrders.ExecuteReader
If rsShippableOpenOrders.HasRows Then
While rsShippableOpenOrders.Read()
If rsShippableOpenOrders("cost") IsNot Nothing AndAlso Not IsDBNull(rsShippableOpenOrders("cost")) Then
cost = CDec(rsShippableOpenOrders("cost"))
Else
cost = 0
End If
'Debug.WriteLine("cost: " & cost)
End While
End If
End Using
End Using
End Using
End Sub
This is baffling me. On a new server (Windows Server 2016) my images seem to be loading in synchronously. The browser is attempting to download them all at the same time, but something is stopping the image from loading until the previous one has finished. The time to first byte increases as each image is attempted to be loaded.
EDIT: I have posted my imagehandler code below, but you can see the problem exists when loading .jpg in its native format (see screenshot about half way down).
EDIT 2: I have disabled http/2 and added a screenshot.
My SVG image handler code (problem exists with image.ashx also):
Dim freshness As TimeSpan = New TimeSpan(1, 0, 0, 0)
Dim now As DateTime = DateTime.Now
Response.Cache.SetExpires(now.Add(freshness))
Response.Cache.SetMaxAge(freshness)
Response.Cache.SetCacheability(HttpCacheability.Public)
Response.Cache.SetValidUntilExpires(True)
Response.Cache.VaryByParams("colour") = True
Response.Cache.VaryByParams("colour2") = True
Response.Cache.VaryByParams("svg") = True
Response.Cache.VaryByParams("rnd") = True
Response.Cache.VaryByHeaders("rnd") = True
Response.Cache.VaryByHeaders("Type") = True
Dim sSVG As String = Request.QueryString("svg").Split("-")(0)
If sSVG = String.Empty Then
Try
sSVG = Request.ServerVariables("SCRIPT_NAME").Split("-")(0)
Catch ex As Exception
sSVG = "svg"
End Try
End If
Dim xDoc As XDocument = XDocument.Load(Server.MapPath("\images\icons\svg\" & sSVG & ".svg"))
Dim sColour As String = "FFFFFF"
Dim sColour2 As String = "FFFFFF"
Dim sXML As String = xDoc.Document.ToString
If Request.QueryString("Colour") <> String.Empty Then
sColour = Request.QueryString("Colour")
Else
Try
sColour = sSVG.Split("-")(1)
Catch ex As Exception
End Try
End If
If Request.QueryString("Colour2") <> String.Empty Then
sColour2 = Request.QueryString("Colour2")
Else
Try
sColour = sSVG.Split("-")(2)
Catch ex As Exception
End Try
End If
sXML = sXML.Replace("COLOUR2", sColour2)
sXML = sXML.Replace("COLOUR", sColour)
Response.Headers.Add("Vary", "Accept-Encoding")
Response.ContentType = "image/svg+xml"
Response.Write(sXML)
HTTP/2 disabled:
I got this error when I click on SAVE button inside the save button is
The error is
"Object reference not set to an instance of an object"
Protected Sub btnWizardFinish_Click(sender As Object, e As EventArgs)
If (rdoAprovalList.SelectedIndex = 1) Then
SaveConsideration(4)
Else
SaveConsideration(1)
End If
End Sub
and this is save sub that contain to save and update a value in DocumentStatusID field in Database
Private Sub SaveConsideration(ByVal DocumentStatusID As Integer)
Dim Conn As New SqlConnection(strConn)
Dim cmd As New SqlCommand
Try
If ((txtProducerID.Text.Trim.Length = 9)) Then
cmd.Connection = Conn
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "spConsiderationSaving"
cmd.Parameters.AddWithValue("#libDocumentID", txtProducerID.Text)
cmd.Parameters.AddWithValue("#ProducerComments", txtProducerComment.Text)
cmd.Parameters.AddWithValue("#DocumentStatusID", DocumentStatusID)
cmd.Parameters.AddWithValue("#ConProduceThai", chkConproduceThai.Checked)
cmd.Parameters.AddWithValue("#ConProducePolicy", chkConProducePolicy.Checked)
cmd.Parameters.AddWithValue("#ConProduceIP", chkConProduceIP.Checked)
cmd.Parameters.AddWithValue("#ConProduceDanger", chkConProduceDanger.Checked)
cmd.Parameters.AddWithValue("#ConProducePeople", chkConproducePeople.Checked)
cmd.Parameters.AddWithValue("#ConProduceManage", chkConProduceManage.Checked)
cmd.Parameters.AddWithValue("#ConProduceMade", chkConProduceMade.Checked)
Conn.Open()
Dim ResponseText As Integer = DirectCast(cmd.ExecuteScalar, Int32).ToString
If (ResponseText = 1) Then
lblResponseResult.Text = "<img src='../images/icons/message-boxes/confirmation.png' /> บันทึกลงฐานข้อมูลเรียบร้อยแล้ว"
If (DocumentStatusID = 3) Then 'Goto next step
AlertRedirects("redirect", pnlHint.ClientID, 3, "Verification.aspx")
Else
AlertBoxs("alert", pnlHint.ClientID, 2)
End If
End If
Else
Dim sb As New System.Text.StringBuilder()
sb.Append("<script type = 'text/javascript'>")
sb.Append("window.onload=function(){")
sb.Append("javascript:history.back();return false;")
sb.Append("};")
sb.Append("</script>")
ClientScript.RegisterClientScriptBlock(Me.GetType(), "back", sb.ToString())
End If
Catch ex As Exception
Response.Write("Error Save: " & ex.Message)
Finally
Conn.Close()
End Try
End Sub
I think it's a problem with reference to something
what is the error please specify that. the code which you posted in that is seems two syntax mistakes
Dim ResponseText As Integer = DirectCast(cmd.ExecuteScalar, Int32).ToString
If (ResponseText = 1)
you are assigning ResponseText a string value which is an integer
and second is if condition there should be double equals like If (ResponseText == 1) because it's not assignment single equals used for assignment
I have found a function which invokes Microsoft.DirectX.AudioVideoPlayback to get the length of a video file.
Here is that code:
`Private Function GetVideoInformation(ByVal videoFilePath As String) As VideoInfo
Try
If My.Computer.FileSystem.FileExists(videoFilePath) Then
Dim videoToGetInfoOn As Microsoft.DirectX.AudioVideoPlayback.Video
videoToGetInfoOn = New Microsoft.DirectX.AudioVideoPlayback.Video(videoFilePath)
Dim atpf As Double = videoToGetInfoOn.AverageTimePerFrame
Dim vidSize As New Size
vidSize = videoToGetInfoOn.Size
Dim thisVideoInfo As New VideoInfo
thisVideoInfo.videoWidth = vidSize.Width
thisVideoInfo.videoHeight = vidSize.Height
thisVideoInfo.videoDuration = videoToGetInfoOn.Duration
If videoToGetInfoOn.Duration > 0 Then
defaultLength = videoToGetInfoOn.Duration
End If
If atpf > 0 Then
thisVideoInfo.videoFps = 1 / atpf
Else
thisVideoInfo.videoFps = 0
End If
Return thisVideoInfo
Else
Throw New Exception("Video File Not Found" & vbCrLf & vbCrLf & videoFilePath)
Return Nothing
End If
Catch ex as Exception
msgbox(ex.message)
End Try
End Function`
I have a timer that calls this function once on 2 seconds to check many videos, and the app works fine for the first 10 videos or so. After that, it throws
"Error in application"
message instead.
In general, things from DirectShow/DirectX MUST be disposed of in the way the docs require or this sort of thing happens. Here, you are creating videoToGetInfoOn objects but never releasing them.
You need to explicitly release all the resources you and it allocated with videoToGetInfoOn = Nothing before your procedure exits. Try that.
I will add that MediaInfo.DLL can be used to get everything from a media file without the overhead of Dx. There is a commandline version that you might be able to read from reading stdout.
I got it working.
The code needs a dispose method.
Here is the final code:
`Private Function GetVideoInformation(ByVal videoFilePath As String) As VideoInfo
Try
If My.Computer.FileSystem.FileExists(videoFilePath) Then
Dim videoToGetInfoOn As Microsoft.DirectX.AudioVideoPlayback.Video
videoToGetInfoOn = New Microsoft.DirectX.AudioVideoPlayback.Video(videoFilePath)
Dim atpf As Double = videoToGetInfoOn.AverageTimePerFrame
Dim vidSize As New Size
vidSize = videoToGetInfoOn.Size
Dim thisVideoInfo As New VideoInfo
thisVideoInfo.videoWidth = vidSize.Width
thisVideoInfo.videoHeight = vidSize.Height
thisVideoInfo.videoDuration = videoToGetInfoOn.Duration
If videoToGetInfoOn.Duration > 0 Then
defaultLength = videoToGetInfoOn.Duration
End If
If atpf > 0 Then
thisVideoInfo.videoFps = 1 / atpf
Else
thisVideoInfo.videoFps = 0
End If
videoToGetInfoOn.Dispose() 'this line here needed to be added
Return thisVideoInfo
Else
Throw New Exception("Video File Not Found" & vbCrLf & vbCrLf & videoFilePath)
Return Nothing
End If
Catch ex as Exception
msgbox(ex.message)
End Try
End Function`