compilation error: The type is defined in an assembly that is not referenced

O

Omatase

Here is my code:

CDO.Message iMessage = new CDO.MessageClass();

string sFrom; string sDate;

iMessage.DataSource.Open(bstrURLItem,null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,"","");

Here is the compilation error:

The type 'ADODB.ConnectModeEnum' is defined in an assembly that is not
referenced. You must add a reference to assembly 'ADODB,
Version=7.0.3300.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'. C:\Documents and
Settings\davidbr\My
Documents\Visual Studio
2005\Projects\InformXY\InformXY\ExchangeEventSink.cs 45 25
InformXY

the error comes from argument number 3 on line:

iMessage.DataSource.Open(bstrURLItem,null,
ADODB.ConnectModeEnum.adModeRead,
ADODB.RecordCreateOptionsEnum.adFailIfNotExists,
ADODB.RecordOpenOptionsEnum.adOpenSource,"","");

I get a similar error on the 4th and 5th arguments.

Here are some things I have tried that didn't work:

couldn't cast to ADODB.ConnectModeEnum
couldn't use corresponding integer values

I am using C# 2.0. I copied the code directly from a project that works

fine in 1.1. I created interop dlls using tlbimp on some exchange dlls.

The iMessage object was instantiated from a namespace derived from one
dll and the enums wer in another. My only working idea is that I need
to make these interop dlls out of compatible versions of original
exchange dlls.

I imagine there may be a work around I can use here to tell it to use
the code as is even though it comes from a different assembly or to
force it to just use the integer counterparts for the enum values.
 
D

Dave Sexton

Hi Omatase,

See if there are any PIA (Primary Interop Assemblies) available for the
application before importing your own.

If you must import your own assemblies you might want to try the tlbimp
utility with the /reference switch so that the generated assemblies
reference each other. You must generate the assemblies in the correct
order. If you generated the assemblies with the appropriate references and
still get the error you are probably still missing type libraries that need
to be imported.

The last option would be to ditch CDO and ADO as they are legacy components
in the context of .NET. The .NET Framework provide intrinsic classes to
handle mail and data access.

- Dave Sexton
 

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

Top