Search Persits Software Knowledge Base

 

Article PS080121168

Attempted to read or write protected memory error

Problem Description

When using a Persits component under .NET via an interop assembly, the following error is generated:

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.

Solution

This error usually means there is a version mismatch between the component itself (such as asppdf.dll) and the .NET interop assembly (such as ASPPDFLib.dll). For example, the server has version 1.5 of AspPDF installed, but the application uses the interop assembly shipped with version 1.6.

The problem can be fixed as follows:

Method 1 (recommended): Download the component in question from its respective web site and reinstall it. The component and interop assembly DLLs included in the installer are guaranteed to match each other.

Method 2: If reinstallation of the component is not possible, you should create a new interop assembly from the currently installed version of component dll using the command-line utility TLBIMP, and then use that assembly in your .NET application by placing it in the /Bin subdirectory. For example:

c:\>TLBIMP c:\path\asppdf.dll

Comments

This article applies to AspUpload, AspEmail, AspEncrypt, AspJpeg, AspPDF, AspUser, and AspGrid.

Created: 1/21/2008 4:58:00 PM
Last Modified: 1/21/2008 4:58:00 PM

Copyright © Persits Software, Inc. 1998 - 2010
For technical support, write to support@persits.com.