Persits Software, Inc. Knowledge Base Articles

You must first call Open, OpenBinary or New error

Problem Description

When using AspJpeg under .NET via an interop assembly, the Open method generates the following error:

Exception Details: System.Runtime.InteropServices.COMException: You must first call Open, OpenBinary or New.

Solution

This error usually means there is a version mismatch between the component itself (aspjpeg.dll) and the .NET interop assembly (ASPJPEGLib.dll). For example, the server has version 1.4 of AspJpeg installed, but the application uses the interop assembly shipped with version 1.5.

The problem can be fixed as follows:

Method 1 (recommended): Download the latest version of AspJpeg from www.aspjpeg.com and install it on your server. The interop assembly included in the installer is guaranteed to match the component itself.

Method 2: If reinstallation of AspJpeg is not possible, you should create a new interop assembly from the currently installed version of aspjpeg.dll using the command-line utility TLBIMP, and then use that assembly in your .NET application:

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