467,910 Members | 1,650 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,910 developers. It's quick & easy.

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

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.

Jul 21 '06 #1
  • viewed: 10071
Share:
1 Reply
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

<Om*****@gmail.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
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.

Jul 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Joachim | last post: by
reply views Thread by Mythran | last post: by
4 posts views Thread by Vish | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.