ADODBCould not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly

烂漫一生 提交于 2019-12-28 12:18:14

问题


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:\WINDOWS\assembly\GAC\ADODB\7.0.3300.0__b03f5f7f11d50a3a\ADODB.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!


回答1:


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




回答2:


Solved:

Solution Explorer --> Show all files (Menu Item) --> Referances --> Adodb -->(properties) -->Embed Interop Types --> False.




回答3:


See what I found on this question here. I referenced yours, but still couldn't get the ADODB to work.

Little one to add:

SolutionExplorer --> View All Files. For ADODB: - Embed... = False; - Copy Local = True.




回答4:


Got the same problem in VS 2013, and the solution for that is that you go to References and select ADODB, on properties you will see Embed Interof types = True then change it to false.




回答5:


Okay, I figured how to do this:

Presentation.Category categorySvc = new Presentation.Category();
ADODB.Recordset categories = categorySvc.ListAll("BE", "DUE", "EN", 128);
categories.MoveFirst();
while(!categories.EOF)
{
    var fields = ((dynamic)categories).Fields;
    for (int i = 0; i < fields.Count; i++)
    {
        var field = fields[i];
        var name = field.Name;
        var value = field.Value;
        // ...
    }
    categories.MoveNext();
}



回答6:


I got this problem clearing temporary file(VS 2017). Solution for this exception you need to change Solution Explorer > References > adodb > "Then Right click and choose properties" > Embed Interop Types, set "True" to "False"



来源:https://stackoverflow.com/questions/5666265/adodbcould-not-load-type-adodb-fieldstointernalfieldsmarshaler-from-assembly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!