Note that there are some explanatory texts on larger screens.

plurals
  1. POInconsistent Behavior From Declared DLL Function
    primarykey
    data
    text
    <p>Why might my <code>GetRawData</code> declared function return a correct value when called from my VB.NET application, but return zero when called from my ASP.NET page?</p> <p>The code is exactly the same except for class type difference (Form / Page) and calling event handler (Form1_Load, Page_Load).</p> <p>Note: In the actual code, #DLL# and #RAWDATAFILE# are both absolute filenames to my DLL and raw data file respectively.</p> <p>Note: The DLL file was not created by Visual Studio.</p> <p><strong>Form1.vb</strong></p> <pre><code>Public Class Form1 Declare Auto Function GetRawData Lib "#DLL#" (ByVal filename() As Byte, _ ByVal byteArray() As Byte, _ ByVal length As Int32) As Int32 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load Dim buffer(10485760) As Byte Dim msg As String, length As Integer = 10485760 Dim filename As String = "#RAWDATAFILE#" length = GetRawData(Encoding.Default.GetBytes(filename), buffer, length) </code></pre> <p><strong>Default.aspx.vb</strong></p> <pre><code>Partial Public Class _Default Inherits System.Web.UI.Page Declare Auto Function GetRawData Lib "#DLL#" (ByVal filename() As Byte, _ ByVal byteArray() As Byte, _ ByVal length As Int32) As Int32 Protected Sub Page_Load(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Load Dim buffer(10485760) As Byte Dim msg As String, length As Integer = 10485760 Dim filename As String = "#RAWDATAFILE#" length = GetRawData(Encoding.Default.GetBytes(filename), buffer, length) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload