Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
792 views
in Technique[技术] by (71.8m points)

activex - ADODBCould not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly

I'm trying to read an ADOBD.Recordset object like this (my first time, so pardon my "noobness" :D):

Presentation.Category categorySvc = new Presentation.Category();
ADODB.Recordset categories = categorySvc.ListAll("BE", "DUE", "EN", 128);
foreach (var category in categories.Fields) // here is where I get the exception
{
   // ...
}

The ListAll call works fine - I get the Recordset with some data which I confirm that by doing a QuickWatch on the object. But when the code reach the categories.Fields I get the following exception:

Could not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly 'TestCOMCalls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

I googled this error (or just by 'ADODB.FieldsToInternalFieldsMarshaler' and couldn't find anything that would help me with issue).

I wonder, am I missing a reference? Besides the normal references I have added this one to my project:

ADODB Microsoft ActiveX Data Objects 2.5 Library C:WINDOWSassemblyGACADODB7.0.3300.0__b03f5f7f11d50a3aADODB.dll

Like I said, I've never done this before but by googling a bit I was able to see some people doing this (foreach on the object.Fields) and it seem to work for them.

Any help or direction is greatly appreciated :)

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It's on the individual references - not in the project properties. In the solution explorer window, open "References" (under the project), and click on the reference in question. The properties window will have an option for Embed Interop Types (for each reference).

In Visual BAsic 2010:

To turn off Embed Interop Types:

Project menu > Show All Files, Solution Explorer: > References: > ADODB > Embed Interof types = False. Microsoft.Office.Interop.Access > Embed Interof types = False

You will now be able to publish and also ADODB will appear in the: Project Menu > Project Properties… Publish TAB > Application Files


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...