i'm using Microsoft.Office.Interop.Word.Document
to generate the report document in server and download it for user.
Is it really good approach to do like this using Interop to perform word operations?. Is it thread safe?. are there any alternatives way you can suggest to perform word operation in server?. I googled lot, found Interop is not safe, you should have word installed in server to generate document etc all issues... But can you please tell me its correct approach or not?
Here is an official KB article explaining why it's a bad idea, and listing alternatives:
https://support.microsoft.com/en-us/kb/257757
No, it's not - for the reasons listed in that article.
Kind of. Because there are no threads in word API. Word API runs as STA (single-threaded-apartment), so all your API calls will run in one single thread of the word application.
First, check out the above article - it has a list of alternatives. There are also libraries which can generate word documents (especially in .docx xml format, there are not that many in the old .doc format).
Not only you should have it installed on server, but also the user who uses your website (which, in turn, uses Word). Read the article above - it's a licensing requirement.
It's a bad idea for production.