.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Passing reference from C# to VB dll

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
529 Views, 4 Replies

Passing reference from C# to VB dll

Hi All,
I have written a Function in VB6.0 and made it as a dll. I have given this dll as a reference to a C# application. I have to pass an object to this VB dll as a parameter from C#. But i am getting error while passing the object. Here is the Coding

DemoProject.DemoClass DP = new DemoProject.DemoClass(); Autodesk.AutoCAD.Interop.Common.AcadObject Obj = e.DBObject;
DP.GetObjFromParent(ref Obj );

I am getting error at above line. Any help would be greatly appreciated. Thanks in advance.

Regards,
Basha
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

What does the VB DLL function look like? What type is the argument of the
function? What is the error? It seems that the VB DLL function does not
recognise the type DBObject in Autodesk.AutoCAD.DatabaseServices namespace
(of course).

Assume the VB DLL function's argument is a AcadObject type, like

Public Function GetObjFromParent(obj As AcadObject) As ....

End Function

Then you should pass an AcadObject, not DBObject. Since DBObject and Entity
object in Autodesk.AutoCAD.Database Services namespace have a property
"AcadObject", which returns Acad COM object "AcadObject", you could try
this:

Autodesk.AutoCAD.Interop.Common.AcadObject Obj = e.DBObject.AcadObject;



wrote in message news:5408074@discussion.autodesk.com...
Hi All,
I have written a Function in VB6.0 and made it as a dll. I have
given this dll as a reference to a C# application. I have to pass an object
to this VB dll as a parameter from C#. But i am getting error while passing
the object. Here is the Coding

DemoProject.DemoClass DP = new DemoProject.DemoClass();
Autodesk.AutoCAD.Interop.Common.AcadObject Obj = e.DBObject;
DP.GetObjFromParent(ref Obj );

I am getting error at above line. Any help would be greatly appreciated.
Thanks in advance.

Regards,
Basha
Message 3 of 5
Anonymous
in reply to: Anonymous

Hi Norman,

My function in VB look like below
Public Function GetObjFromParent(Fname as String, Obj As AcadObject)
' My Stuff
End Function

My function in C#.Net look like this

public void objAppended(object o, ObjectEventArgs e)
{
DemoProject.DemoClass DP= new DemoProject.DemoClass();
string Fname = "E:\\New Demo\\Demo.xml";
Autodesk.AutoCAD.Interop.Common.AcadObject Obj = e.DBObject.AcadObject;
DP.GetObjFromParent(ref Fname,ref Obj );
}
Error1: Cannot implicitly convert type 'object' to 'Autodesk.AutoCAD.Interop.Common.AcadObject'. An explicit conversion exists (are you missing a cast?).
Error2: No overload for method 'GetObjFromParent' takes '2' arguments

Hope this clearly explains my problem.

Regards,
Basha
Message 4 of 5
Anonymous
in reply to: Anonymous

Sorry for the minor mistake in my previous reply:

DBObject's AcadObject property is actually returns an object of "object"
type, not "AcadObject" type, although the property is named AcadObject. So,
you need explicitly cast it as AcadObject before assigning it to an
AcadObject variable:

Autodesk.AutoCAD.Interop.Common.AcadObject Obj =
(Autodesk.AutoCAD.Interop.Common.AcadObject) e.DBObject.AcadObject;

As for Error2, in your original post, the VB function has only one argument,
have you re-written the VB DLL but forgotten to update the reference?


wrote in message news:5409039@discussion.autodesk.com...
Hi Norman,

My function in VB look like below
Public Function GetObjFromParent(Fname as String, Obj As AcadObject)
' My Stuff
End Function

My function in C#.Net look like this

public void objAppended(object o, ObjectEventArgs e)
{
DemoProject.DemoClass DP= new DemoProject.DemoClass();
string Fname = "E:\\New Demo\\Demo.xml";
Autodesk.AutoCAD.Interop.Common.AcadObject Obj = e.DBObject.AcadObject;
DP.GetObjFromParent(ref Fname,ref Obj );
}
Error1: Cannot implicitly convert type 'object' to
'Autodesk.AutoCAD.Interop.Common.AcadObject'. An explicit conversion exists
(are you missing a cast?).
Error2: No overload for method 'GetObjFromParent' takes '2' arguments

Hope this clearly explains my problem.

Regards,
Basha
Message 5 of 5
Anonymous
in reply to: Anonymous

Hi Norman,
Thank you for your time. Actually i am passing two parameters, one is the string and the other is an object. In my original post i haven't specified the 1st argument. Now the first error was resolved but still i am getting the 2nd error.

Error2: No overload for method 'GetObjFromParent' takes '2' arguments

Thanks in Advance,

Regards,
Basha

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost