I have been recently having trouble with a run-time error:-
Could not load type 'ADODB.FieldsToInternalFieldsMarshaler' from assembly my_assembly
which I am endeavouring to correct with the advice given here, here and here. But doing this (setting Embed Interop Types=false
, Copy Local=true
, and Isolated=false
) has caused numerous compilation error messages:-
Option Strict On disallows implicit conversions from 'ADODB.Recordset' to 'ADODB.Recordset'
These occur when a recordset is passed as a ByRef
parameter.
The suggested cure...
CType(my_record_set, ADODB.Recordset)
results in another error of the same type, which will presumably require an infinite number of CTypes to cure. However, the Daily-WTF nature of the error message and the fact this compiled perfectly well before making the project-related changes leads me to the conclusion that the code isn't really the problem; it is something to do with this work-round.
So does anyone know what the problem is with the work-round, or how to fix the compilation errors the suggested solution causes?
EDIT The code where the error manifests itself:-
Dim record_set As ADODB.Recordset = Nothing
query_string = "some sql-server query"
db_error = Database.DoQuery(query_string, record_set) ' Error in this line
where the database class has
Public MustOverride Function DoQuery(
ByVal query_string As String, _
ByRef record_set As ADODB.Recordset) As DATABASE_ERRORS
and the particular override is:-
Public Overrides Function DoQuery(
ByVal query_string As String, _
ByRef record_set As ADODB.Recordset) As DATABASE_ERRORS
record_set = New ADODB.Recordset
record_set.CursorLocation = ADODB.CursorLocationEnum.adUseClient
record_set.Open(query_string,
database_connection,
ADODB.CursorTypeEnum.adOpenStatic,
,
ADODB.CommandTypeEnum.adCmdText)
End Function
(Error handling omitted for brevity).