Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Access Database Engine 2016 and using a c#.NET plugin that uses Microsoft.Office.Interop.Excel

mcoH3VZV
Advocate

Access Database Engine 2016 and using a c#.NET plugin that uses Microsoft.Office.Interop.Excel

mcoH3VZV
Advocate
Advocate

Hi,

 

I am having an issue with a c# plugin for opening/reading/and saving Excel files and a CAD requirement to install Access Database Engine 2016.

 

I am the developer and have a 2016 32-bit version of Excel downloaded. I deploy a software package in a .dll that others load in and use.

 

Lately, I have two users that have a 2019 64-bit version of office installed and suddenly, on Autocad startup, it required them to install Microsoft Access Database Engine 2016 64bit (I still only have a 2010 version installed). See attached for the error. If they don't install it, CAD will close.

 

After downloading, everything seemed fine, but when an excel file is opened through the software (using Microsoft.Office.Interop.Excel), it bombs out with another error - see attached.

 

So what is required is to go to the control panel and repair the 2019 office, and then the code runs fine. But then, when they close CAD and re-open, the same access database engine 2016 error pops back up (need to repair this to continue), and the two issues repeat constantly.

 

Does anyone have any ideas? Use something other than Microsoft.Office.Interop.Excel? Have all users keep 2016 32-bit office? Or upgrade Office on the deployment PC?

 

Thanks,

0 Likes
Reply
Accepted solutions (1)
366 Views
2 Replies
Replies (2)

norman.yuan
Mentor
Mentor
Accepted solution

It looks to me you have 2 different things:

 

1. you use MD Access Engine to access data in workbook/sheet of an *.xls/xlsx file. In this case, MS Excel is not required to run/to be installed.

 

2. You also automate Excel application via COM interop ( thus the reference to Microsoft.Office.Interop.Excel), which can also be used to access data in workbook/sheet.

 

It seems both give you troubles. If the only thing you need to do with the *.xlsx file is to access data from AutoCAD, you can choose one of aforementioned approaches so that you can eliminate troubles from one of them.

 

Now comes to the problems.

 

Firstly the error with Microsoft.Office.Interop.Excel. It is obvious: your plugin app has reference to 32-bit Excel COM interop, while the user uses 64-bit Excel. While pure .NET App would work with both 32/64 bit environment, the COM interop is very likely not, because it is just a .NET wrapper of COM server app (Excel, in your case), not a pure .NET app.

 

As for the MS Access engine error, I guess it is version issue, especially your app (computer) uses very old version of MS Access Engine. 

 

Again, if your app only need to access data in *.xlsx file, no need to do some Excel specific work (such as setting work sheet to particular format, manipulate cell formula..., then you can remove reference to Excel's COM interop and only use MD Access Engine to access/save data. In this case, you can update your app to use Access Engine 2016 ( the latest, I guess). Or, you can use Excel COM interop to access data (while bearing its slowness) and eliminate the use of Access Engine. Still, in this case, you still has to face the COM Interop being 32 or 64 bit.

 

IMO, at this stage of .NET development, using MS Access Engine with AutoCAD .NET programming could be one the worst technology combination to maintain/support.

 

If I were you, and the *.xlsx is only used as data source, I would not use Access Engine, nor Excel Com interop. Instead, I'd use OpenXml technology to  to get data in the sheet file. This could also do some sheet formatting. No Excel installation is required. OpenXml is open source, and there are a lot of third party tool based OpenXml available and many of them are freeware.

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes

mcoH3VZV
Advocate
Advocate

I decided to use OpenXml. I have a bit of code working without the error.

 

Thanks for the help.

0 Likes