Unresolved COMException : Incorrect syntax near '='.

Z

Zoury

Hi there! :O)

I trying to use a COM DLL (made in VB 6.0) from C#... and it hasn't been
working well for me this far.. :O/

I did a sample in VB 6.0 that used the DLL and it works great.. so now I'm
trying to do the exact same thing from C#...

But I get the following error when I call a function :
<error description>
An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in WindowsApplication19.exe

Additional information: Line 1: Incorrect syntax near '='.
</error description>



Here's the function signature from VB 6.0
'***
Public Sub LoadObjectByKey _
( _
ByRef p_objObject As Object, _
ByVal p_strTableName As String, _
ByVal p_strKey As String, _
ByVal p_varKeyValue As Variant, _
Optional ByVal p_varKey2 As Variant, _
Optional ByVal p_varKeyValue2 As Variant, _
Optional bUseCache As Boolean = True _
)
'***


That's how I call it from VB 6.0 :
'***
Dim oCst As CCustomer
Set oCst = New CCustomer

Call oArb.ObjectFactory.LoadObjectByKey(oCst, "customer", "cst_no",
"658-0663")
'***


Now here's my C# code :
//***
object oCst = (object)new CCustomerClass();
bool bUseCache = true;

oArb.ObjectFactory.LoadObjectByKey(ref oCst, "customer", "cst_no",
(object)"658-0663", null, null, ref bUseCache);
//***


I have a feeling that the problem is related with the Variant data type...
any thoughts about that?

The error message doesn't help at all.. there is no syntax error (the DLL
*has been* compiled) and there is no '=' on line 1 of the function...
 
Z

Zoury

I have a feeling that the problem is related with the Variant data type...
any thoughts about that?

Yep.. that was it.. I needed to pass System.Reflection.Missing.Value instead
of null.. :O)

I don't receive error anymore but the function doesn't seems to work... my
object stay empty..

thanks anyway
 

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