Link to home
Start Free TrialLog in
Avatar of Uma Angara
Uma Angara

asked on

Microsoft Office Interop word Dll error

I have an c# application created in VS2005(.Net Framework 2.0) using Microsoft Interop Word Dlls.
Now we are migrating this application to Windows 10 and while building the solution I get the below errorsUser generated imageUser generated imageUser generated imageUser generated image
Avatar of Olivier Marchetta
Olivier Marchetta
Flag of United Kingdom of Great Britain and Northern Ireland image

Do you have Microsoft Interop assemblies installed on the new Windows 10 image?
What is the Microsoft Office version on the new build?
you are referencing Word 12.0 (which is 2007). Which version does your new computer have? You need to redo your references to fit your actual version of Word. But be very cautious. If you are referencing a version newer than what users have, you are running for troubles!
i found a very useful comment to that issue at

   stackoverflow.com/questions/21013912/can-i-still-use-microsoft-office-interop-assemblies-with-office-2013/21018418


summarized it says:

Premium Interop Assemblies (PIA) are out-of-date and should be replaced by the "Embed Interop Types" ("No PIA") feature. since VS 2010 you will find it in the Properties window when you select a reference assembly. the new technique avoids your users having to install the PIAs on their system (and you to provide it with the setup).  just remove old reference assemblies and add them from the COM tab instead.

note, that there are some restraints if using old office features. the above link says:

Do note that a feature is lost, intentionally targeting an old version of Office that you don't actually have installed on your dev machine is more difficult. If that's a requirement then you still need the PIAs for that version, force the Embed Interop Types to True in the Properties window. Actually doing this is questionable, Microsoft has a hard time keeping new Office versions completely compatible with old versions. They've kept it up for 15 years now but it has been running out of steam. A worst-case scenario is targeting a newer version than you have installed on your machine, that's liable to make your program crash with very hard to diagnose exceptions like AccessViolationException.

Do note that you have to make small modifications to your code to allow it to work. The synthetic "XxxxClass" classes are not embedded, just the "Xxxx" interfaces. Simply remove the word "Class" from the new statement.

Sara
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.