What is the best way to connect Autocad 2007 & .NET
I am trying by following method
Try
Cadapp = GetObject(, "Autocad.Application")
Catch ex As Exception
Cadapp = CreateObject("Autocad.Application")
End Try
If Cadapp.Documents.Count > 0 Then
For i = 0 To Cadapp.Documents.Count
Cadapp.Documents.Close() '(False)
Next
End If
Caddoc = Cadapp.Documents.Add
Caddoc = Cadapp.ActiveDocument
Cadapp.Visible = True
& getting error "Unable to cast COM object of type 'Autodesk.AutoCAD.Interop.AcadApplicationClass' to interface type 'Autodesk.AutoCAD.Interop.AcadApplication'"
Thanks
Deepak
Hi Deepak,
The best way would be to implement a plugin using .Net that can be netloaded in AutoCAD.
You would not need to use COM in that case.
About the error, you can try the following two points :
1) Verify if your project uses the interop assemblies from the correct ObjectARX version.
2) Try connecting to AutoCAD 2007 using a specific progid as in this code snippet.
const string progID = "AutoCAD.Application.17";
Type acType = Type.GetTypeFromProgID(progID);
Regards,
Balaji