Message 1 of 11
MDAC 2.7 Breaks .NET COM Interop with AutoCAD?

Not applicable
12-10-2002
12:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I just installed MDAC 2.7 on a workstation with a C# application that uses
Data.OleDb namespace in ADO.NET. I did this, of course, because I got the
error message saying that I need MDAC version 2.6 or higher if I want to use
the Data namespace. Oddly enough, the required MDAC version does not come
with the .NET Framework. The workstation is Windows 2000, so it only had
version 2.5 on it. Microsoft says they recommend 2.7, so I installed 2.7
(talk about blind faith).
Now, this application doesn't want to connect to AutoCAD anymore. My method
of connection worked flawlessly before, but now it suddenly doesn't. I was
able to duplicate the problem on another very similar workstation.
And--stupid me--I decided to try installing MDAC 2.7 on my development
computer (which I found out later already has 2.7 on it because it is
installed with VS.NET). To add insult to injury, this workstation was
already working with ADO.NET and AutoCAD Interop... so I should have left it
alone. Now even it doesn't want to connect to AutoCAD, even from within the
VS.NET IDE. I've tried rolling back on my dev workstation, but that doesn't
help. I also tried just installing 2.6 instead of 2.7, but there is no
difference. I will try rolling back on the other workstations to see if
that helps, but in the end, I still need 2.6 or higher to run the database
stuff so I need to find a way to get 2.6 or higher working.
So I am basically stuck. I can't seem to find anything (mainly using
Google) about this, so I need help! The code to connect to AutoCAD is
pretty straight-forward and is as follows:
private AcadApplication GetAcadA()
{
try
{
AcadApplication app =
(AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
return app;
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
return null;
}
}
This used to work fine, but now I get a "Specified cast is not valid" when
running through the Marshal.GetActiveObject line. I've tried a few
different ways of getting AutoCAD, like saving it to an object field and
then casting it to app using "as" instead of (...), but nothing I've tried
works. I'm out of ideas.
Anyone have any hints?
Data.OleDb namespace in ADO.NET. I did this, of course, because I got the
error message saying that I need MDAC version 2.6 or higher if I want to use
the Data namespace. Oddly enough, the required MDAC version does not come
with the .NET Framework. The workstation is Windows 2000, so it only had
version 2.5 on it. Microsoft says they recommend 2.7, so I installed 2.7
(talk about blind faith).
Now, this application doesn't want to connect to AutoCAD anymore. My method
of connection worked flawlessly before, but now it suddenly doesn't. I was
able to duplicate the problem on another very similar workstation.
And--stupid me--I decided to try installing MDAC 2.7 on my development
computer (which I found out later already has 2.7 on it because it is
installed with VS.NET). To add insult to injury, this workstation was
already working with ADO.NET and AutoCAD Interop... so I should have left it
alone. Now even it doesn't want to connect to AutoCAD, even from within the
VS.NET IDE. I've tried rolling back on my dev workstation, but that doesn't
help. I also tried just installing 2.6 instead of 2.7, but there is no
difference. I will try rolling back on the other workstations to see if
that helps, but in the end, I still need 2.6 or higher to run the database
stuff so I need to find a way to get 2.6 or higher working.
So I am basically stuck. I can't seem to find anything (mainly using
Google) about this, so I need help! The code to connect to AutoCAD is
pretty straight-forward and is as follows:
private AcadApplication GetAcadA()
{
try
{
AcadApplication app =
(AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
return app;
}
catch (Exception e)
{
System.Diagnostics.Debug.WriteLine(e.Message);
return null;
}
}
This used to work fine, but now I get a "Specified cast is not valid" when
running through the Marshal.GetActiveObject line. I've tried a few
different ways of getting AutoCAD, like saving it to an object field and
then casting it to app using "as" instead of (...), but nothing I've tried
works. I'm out of ideas.
Anyone have any hints?