random server error when using OCX in web page

N

Neal Bade

We are trying to use our OCX control in a web page in order to create
a web interface to our label printing application. Seemingly randomly,
calls to certain methods of the OCX will cause a server crash. We have
been trying to debug this for several weeks and cannot figure out what
the problem is.

We wrote a test app in C# that uses the same OCX control and calls
the same methods as the ASP page. We let it run over the weekend.
It ran through over 800,000 iterations without any problems.
This leads us to believe that the OCX is probably OK.

The crash seems completely random. It may work several times then
crash. Any ideas or helpful hints would be greatly appreciated.


Here is the error reported by ASP.NET:

Server Error in '/EASYLABELNetPrintServer' Application.
--------------------------------------------------------------------------------

Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
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.AccessViolationException: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[AccessViolationException: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.]
System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData) +438
ELABELINFOLib.ELabelInfoClass.set_FormatName(String ) +0
PintPreview.Page_Load(Object sender, EventArgs e) +464
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET
Version:2.0.50727.832


Here is the ASP code:

Partial Class PintPreview
Inherits System.Web.UI.Page
Dim format As String
Dim previewPanel As Panel = New Panel()
Dim variablePanel As Panel = New Panel()
Dim printRequestPanel As Panel = New Panel()
Const PREVIEWPANELID As String = "Format Preview Image"
Const PREVIEWUPDATEBTNID As String = "PreviewUpdateBtn"
Dim EZBatch As ELABELOCXLib.ELabelBatch
Dim EZLabelInfo As ELABELINFOLib.ELabelInfo
Dim requireFieldValidatorCtrl As RequiredFieldValidator
Dim physicalApplicationPath As String
Dim labelPrinterExisted As Boolean = True
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Page.Title = "EASYLABEL Net Print Server"
physicalApplicationPath = Request.PhysicalApplicationPath()
Try
If Not EZBatch Is Nothing Then
Marshal.ReleaseComObject(EZBatch)
EZBatch = Nothing
End If
If Not EZLabelInfo Is Nothing Then
Marshal.ReleaseComObject(EZLabelInfo)
EZLabelInfo = Nothing
End If
EZBatch = New ELABELOCXLib.ELabelBatch()
EZLabelInfo = New ELABELINFOLib.ELabelInfo()
Catch ex As Exception
Response.Write(ex.Message + vbCrLf + " Check if Easylabel ActiveX is
registered correctly.")
Return
End Try
If (EZBatch Is Nothing) Then
Return
End If
If (EZLabelInfo Is Nothing) Then
Return
End If
format = Request.QueryString("FileName")
If (format Is Nothing) Then
Response.Write("Format name is invalid!")
Return
End If
EZBatch.FormatName = format
EZBatch.ShowPreview = True
EZLabelInfo.FormatName = format ' ***** ERROR occurs here *****
Dim fieldCounter As Int32 = EZLabelInfo.FieldCount
showFMTPReview(format)
displayVariableField(format)
addPrintRequestPanel()
HyperLink_backToFMTSelection.NavigateUrl = "formatView.aspx?Page=" +
Session("CurrentPage")
If (Session("Signon") = "True") Then
LoginStatus1.Visible = True
HyperLink_ChangePassword.Visible = True
Else
LoginStatus1.Visible = False
HyperLink_ChangePassword.Visible = False
End If
End Sub
 
B

bruce barker (sqlwork.com)

ther are two possible problems

1) its an sta ocx (pretty common). this means you need to set aspcompat on
the page using the control.

2) the ocx is using a messagebox/dialogbox to display an error, etc. there
is no fix for this other than updating the ocx to handle when it does not
have access to the desktop.


-- bruce (sqlwork.com)


Neal Bade said:
We are trying to use our OCX control in a web page in order to create
a web interface to our label printing application. Seemingly randomly,
calls to certain methods of the OCX will cause a server crash. We have
been trying to debug this for several weeks and cannot figure out what
the problem is.

We wrote a test app in C# that uses the same OCX control and calls
the same methods as the ASP page. We let it run over the weekend.
It ran through over 800,000 iterations without any problems.
This leads us to believe that the OCX is probably OK.

The crash seems completely random. It may work several times then
crash. Any ideas or helpful hints would be greatly appreciated.


Here is the error reported by ASP.NET:

Server Error in '/EASYLABELNetPrintServer' Application.
--------------------------------------------------------------------------------

Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
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.AccessViolationException: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:

[AccessViolationException: Attempted to read or write protected memory. This
is often an indication that other memory is corrupt.]
System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData) +438
ELABELINFOLib.ELabelInfoClass.set_FormatName(String ) +0
PintPreview.Page_Load(Object sender, EventArgs e) +464
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET
Version:2.0.50727.832


Here is the ASP code:

Partial Class PintPreview
Inherits System.Web.UI.Page
Dim format As String
Dim previewPanel As Panel = New Panel()
Dim variablePanel As Panel = New Panel()
Dim printRequestPanel As Panel = New Panel()
Const PREVIEWPANELID As String = "Format Preview Image"
Const PREVIEWUPDATEBTNID As String = "PreviewUpdateBtn"
Dim EZBatch As ELABELOCXLib.ELabelBatch
Dim EZLabelInfo As ELABELINFOLib.ELabelInfo
Dim requireFieldValidatorCtrl As RequiredFieldValidator
Dim physicalApplicationPath As String
Dim labelPrinterExisted As Boolean = True
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Page.Title = "EASYLABEL Net Print Server"
physicalApplicationPath = Request.PhysicalApplicationPath()
Try
If Not EZBatch Is Nothing Then
Marshal.ReleaseComObject(EZBatch)
EZBatch = Nothing
End If
If Not EZLabelInfo Is Nothing Then
Marshal.ReleaseComObject(EZLabelInfo)
EZLabelInfo = Nothing
End If
EZBatch = New ELABELOCXLib.ELabelBatch()
EZLabelInfo = New ELABELINFOLib.ELabelInfo()
Catch ex As Exception
Response.Write(ex.Message + vbCrLf + " Check if Easylabel ActiveX is
registered correctly.")
Return
End Try
If (EZBatch Is Nothing) Then
Return
End If
If (EZLabelInfo Is Nothing) Then
Return
End If
format = Request.QueryString("FileName")
If (format Is Nothing) Then
Response.Write("Format name is invalid!")
Return
End If
EZBatch.FormatName = format
EZBatch.ShowPreview = True
EZLabelInfo.FormatName = format ' ***** ERROR occurs here *****
Dim fieldCounter As Int32 = EZLabelInfo.FieldCount
showFMTPReview(format)
displayVariableField(format)
addPrintRequestPanel()
HyperLink_backToFMTSelection.NavigateUrl = "formatView.aspx?Page=" +
Session("CurrentPage")
If (Session("Signon") = "True") Then
LoginStatus1.Visible = True
HyperLink_ChangePassword.Visible = True
Else
LoginStatus1.Visible = False
HyperLink_ChangePassword.Visible = False
End If
End Sub
 
N

Neal Bade

Thanks Bruce,

we already new about the aspcompat, but we did not know about the
messagebox/dialogbox issue. we will have to check our OCX code and
the support DLL that it calls.

Neal


"bruce barker (sqlwork.com)"
ther are two possible problems

1) its an sta ocx (pretty common). this means you need to set aspcompat on
the page using the control.

2) the ocx is using a messagebox/dialogbox to display an error, etc. there
is no fix for this other than updating the ocx to handle when it does not
have access to the desktop.


-- bruce (sqlwork.com)


Neal Bade said:
We are trying to use our OCX control in a web page in order to create
a web interface to our label printing application. Seemingly randomly,
calls to certain methods of the OCX will cause a server crash. We have
been trying to debug this for several weeks and cannot figure out what
the problem is.

We wrote a test app in C# that uses the same OCX control and calls
the same methods as the ASP page. We let it run over the weekend.
It ran through over 800,000 iterations without any problems.
This leads us to believe that the OCX is probably OK.

The crash seems completely random. It may work several times then
crash. Any ideas or helpful hints would be greatly appreciated.


Here is the error reported by ASP.NET:

Server Error in '/EASYLABELNetPrintServer' Application.
--------------------------------------------------------------------------------

Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
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.AccessViolationException: Attempted to read or
write protected memory. This is often an indication that other memory is
corrupt.

Source Error:

An unhandled exception was generated during the execution of the current
web
request. Information regarding the origin and location of the exception
can
be identified using the exception stack trace below.

Stack Trace:

[AccessViolationException: Attempted to read or write protected memory.
This
is often an indication that other memory is corrupt.]
System.RuntimeType.ForwardCallToInvokeMember(String memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData) +438
ELABELINFOLib.ELabelInfoClass.set_FormatName(String ) +0
PintPreview.Page_Load(Object sender, EventArgs e) +464
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.832;
ASP.NET
Version:2.0.50727.832


Here is the ASP code:

Partial Class PintPreview
Inherits System.Web.UI.Page
Dim format As String
Dim previewPanel As Panel = New Panel()
Dim variablePanel As Panel = New Panel()
Dim printRequestPanel As Panel = New Panel()
Const PREVIEWPANELID As String = "Format Preview Image"
Const PREVIEWUPDATEBTNID As String = "PreviewUpdateBtn"
Dim EZBatch As ELABELOCXLib.ELabelBatch
Dim EZLabelInfo As ELABELINFOLib.ELabelInfo
Dim requireFieldValidatorCtrl As RequiredFieldValidator
Dim physicalApplicationPath As String
Dim labelPrinterExisted As Boolean = True
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
Handles Me.Load
Page.Title = "EASYLABEL Net Print Server"
physicalApplicationPath = Request.PhysicalApplicationPath()
Try
If Not EZBatch Is Nothing Then
Marshal.ReleaseComObject(EZBatch)
EZBatch = Nothing
End If
If Not EZLabelInfo Is Nothing Then
Marshal.ReleaseComObject(EZLabelInfo)
EZLabelInfo = Nothing
End If
EZBatch = New ELABELOCXLib.ELabelBatch()
EZLabelInfo = New ELABELINFOLib.ELabelInfo()
Catch ex As Exception
Response.Write(ex.Message + vbCrLf + " Check if Easylabel ActiveX is
registered correctly.")
Return
End Try
If (EZBatch Is Nothing) Then
Return
End If
If (EZLabelInfo Is Nothing) Then
Return
End If
format = Request.QueryString("FileName")
If (format Is Nothing) Then
Response.Write("Format name is invalid!")
Return
End If
EZBatch.FormatName = format
EZBatch.ShowPreview = True
EZLabelInfo.FormatName = format ' ***** ERROR occurs here *****
Dim fieldCounter As Int32 = EZLabelInfo.FieldCount
showFMTPReview(format)
displayVariableField(format)
addPrintRequestPanel()
HyperLink_backToFMTSelection.NavigateUrl = "formatView.aspx?Page=" +
Session("CurrentPage")
If (Session("Signon") = "True") Then
LoginStatus1.Visible = True
HyperLink_ChangePassword.Visible = True
Else
LoginStatus1.Visible = False
HyperLink_ChangePassword.Visible = False
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top