Sunday, April 5, 2015
0 comments

microsoft.office.interop.word dll (2007/2010)issues/ c#.net[Could not load file or assembly 'Microsoft.Office.Interop.Word....]

12:09 PM
Sometime when we are going to host application to production server where only ms office 2007 DLL available from Development server where ms office newer than 2007 installed we get following

Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

This  could be solved by following way:
development server( working fine)
i am trying to populate the values for the word document using c#.am using microsoft.office.interop.word dll (version 12.0 related to word 2007) as a reference in my project. in my development server office 2007 is installed. am able to populate the values and save the document properly without any error.
Production Environment
getting object reference error. the one difference i see in this server is microsoft word 2010 is installed. i tried my level best but no luck.
*is this because word 2010 is installed in the production server?
*when i hosted the application in the other production server where word 2007 is installed.the application is working fine.

Solution:
That could be the issue, it looks like Office 2010 uses Version 14 of the dlls:http://www.microsoft.com/en-us/download/details.aspx?id=3508
Maybe try to use the 14 version in your dev server and see if that works, if so should be ok with production as well. otherwise see if the 2007 dll was copied into you bin, if not try to drop the 2007 version (v 12) into you application's bin and see if that works, could be the production application can't locate the dll in your bin and is then looking in the GAC, GAC would have 2010 version installed. If it's in your bin it might use that one first.

At Last Add DLL for MS word 2007 on your project(if references folder unavailable on project), Then right click on Project and Add DLL to Project.





0 comments:

 
Toggle Footer