2011-06-17 94 views
0

我正在使用服務器端活動x控件進行分頁(http://activexperts.com/xmstoolkit/)。下面的代碼工作發現在Windows 2003服務器,但現在我們搬到了2008年的窗戶和我收到以下錯誤:.Net錯誤 - System.AccessViolationException:嘗試讀取或寫入受保護的內存

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at AXmsCtrl.PagerProtocolSnppClass.Clear() at _Default.Button1_Click(Object sender, EventArgs e) in D:\Apps\pagetest\Default.aspx.vb:line 15

我已經搜索並閱讀不同的線程,但我不能找到解決辦法。在此先感謝您的幫助。

下面是代碼:

Partial Class _Default 
    Inherits System.Web.UI.Page 
    Private objSnppProtocol As PagerProtocolSnpp = New PagerProtocolSnpp 
    Private objPagerMessage As PagerMessage = New PagerMessage 

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 
     Try 

      objPagerMessage.Clear() 
      objPagerMessage.Recipient = "12345" 
      objPagerMessage.Data = "Testing send page." 

      objSnppProtocol.Clear() 
      objSnppProtocol.Server = "111.111.11.11" 
      objSnppProtocol.ServerPort = System.Int32.Parse("446") 
      objSnppProtocol.ServerTimeout = 2000 

      objSnppProtocol.ProviderPassword = "2125551212 2125551212" 
      objSnppProtocol.LogFile = Server.MapPath("log.txt") 

      ' Send 
      objSnppProtocol.Send(objPagerMessage) 
      UpdateResult(objSnppProtocol.LastError, objSnppProtocol.ProviderResponse) 
     Catch exc As Exception 
      Response.Write("<br><font color='maroon'><strong>Paging ERROR:</strong></font><br>" & exc.ToString() & "<br>Trace: " & exc.StackTrace.ToString()) 
     End Try 
    End Sub 

    Private Sub UpdateResult(ByVal numResult As System.Int32, ByVal strResponse As String) 
     ctlResult.Text = numResult.ToString() & ": " & objSnppProtocol.GetErrorDescription(numResult) 
     ctlResponse.Text = strResponse 
    End Sub 
End Class 
+0

遠離匈牙利符號 - MS推薦人們在2003年停止:)不需要任何東西的'obj' - 現在一切都基本上是一個對象。使用名稱來表示其目的。恩。而不是objSnppProtocol使用snnpProtocol – 2011-06-17 01:39:26

+0

OMG ...我認爲訪問衝突已被棄用(永遠不會再被看到)異常。從未想到有一天我會發現.net中存在這樣的例外。對我來說這是一個悲傷的日子。 – 2011-06-17 01:42:59

+0

@Miguel - 他們基本上是除非你做一個不安全的操作,或處理非託管代碼。你仍然可以通過互操作,糟糕的編組等等 - 但是然後你跨越本機/託管代碼之間的界限。在這種情況下,它是一個ActiveX控件。 – 2011-06-17 03:39:11

回答

2

您的組件會在非託管代碼崩潰 - 與供應商聯繫。 - 你也試圖在64位系統上運行這個32位代碼?

+0

新的操作系統是64位。我們將聯繫供應商。 – rossboss 2011-06-17 12:09:26

+0

問題是在win 2008服務器上使用了錯誤的interop dll。當安裝活動x控件時,它會創建一個我們放置在網站bin文件夾中的互操作dll。問題是,當我的筆記本電腦(Windows Vista)安裝時,它會創建一個互操作的dll,不能在登臺服務器上工作(win 2008)。因此,基本上在win 2008登臺服務器上,來自示例站點文件夾的interop dll需要被複制到網站文件夾中。 – rossboss 2011-06-24 21:24:12

相關問題