none
Office 365 RRS feed

  • Question

  • My development system is a new computer which has Office 365 installed on it.  When I compile the application and port it over to my clients systems which are running microsoft office 2007 I they try to bring up a screen which has calls to Microsoft word document the application fails with the message.

    Unhandled exception has recurred

    Could not load file or assembly 'Microsoft.Office.Interop.word

    Version=15.0.0.0 the system cannot find the file specified.

    How do I resolve the issue

    Jerry


    Jerry Wade

    Tuesday, March 31, 2015 9:29 PM

Answers

  • Firstly, you need to develop with the lowest version that you are planning to support (2007, not 2013). You can still develop on a 2013 machine, but create the interop dll on a 2007 machine and copy it to your 2013 machine, where you can add a reference to that interop instead of adding a reference to the Word Object Model on the COM tab of the References dialog box. You might also want to make sure that "Specific Version" is set to false for that reference.

    Secondly, you need to make sure the interop dll is copied along with your executable.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, March 31, 2015 9:42 PM
  •  As Dmitry noticed, you need to use the interop library which corresponds to the lowest Office version you need to support to be sure that you use types, methods and properties available in the lowest Office version. Calling a new method or property introduced in later Office versions will throw an exception in the code. If you are sure that you don't call new properties and methods and use types available in all Office 2007 and up versions you can go with the latest interop library.

    Also you may consider embedding interop types into your assembly. Beginning with the .NET Framework 4, the common language runtime supports embedding type information for COM types directly into managed assemblies, instead of requiring the managed assemblies to obtain type information for COM types from interop assemblies. Because the embedded type information includes only the types and members that are actually used by a managed assembly, two managed assemblies might have very different views of the same COM type. Each managed assembly has a different Type object to represent its view of the COM type. The common language runtime supports type equivalence between these different views for interfaces, structures, enumerations, and delegates.

    Additionally, the embedded type information enables you to achieve version independence for your application. That is, your program can be written to use types from multiple versions of a COM library without requiring a specific PIA for each version. This is a common scenario for applications that use objects from Microsoft Office libraries. Embedding type information enables the same build of a program to work with different versions of Microsoft Office on different computers without the need to redeploy either the program or the PIA for each version of Microsoft Office.

    You just need to set the the Embed Interop Types property to true for the interop reference. See Walkthrough: Embedding Type Information from Microsoft Office Assemblies (C# and Visual Basic) for more information.


    Wednesday, April 1, 2015 7:33 AM

All replies

  • Firstly, you need to develop with the lowest version that you are planning to support (2007, not 2013). You can still develop on a 2013 machine, but create the interop dll on a 2007 machine and copy it to your 2013 machine, where you can add a reference to that interop instead of adding a reference to the Word Object Model on the COM tab of the References dialog box. You might also want to make sure that "Specific Version" is set to false for that reference.

    Secondly, you need to make sure the interop dll is copied along with your executable.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, March 31, 2015 9:42 PM
  •  As Dmitry noticed, you need to use the interop library which corresponds to the lowest Office version you need to support to be sure that you use types, methods and properties available in the lowest Office version. Calling a new method or property introduced in later Office versions will throw an exception in the code. If you are sure that you don't call new properties and methods and use types available in all Office 2007 and up versions you can go with the latest interop library.

    Also you may consider embedding interop types into your assembly. Beginning with the .NET Framework 4, the common language runtime supports embedding type information for COM types directly into managed assemblies, instead of requiring the managed assemblies to obtain type information for COM types from interop assemblies. Because the embedded type information includes only the types and members that are actually used by a managed assembly, two managed assemblies might have very different views of the same COM type. Each managed assembly has a different Type object to represent its view of the COM type. The common language runtime supports type equivalence between these different views for interfaces, structures, enumerations, and delegates.

    Additionally, the embedded type information enables you to achieve version independence for your application. That is, your program can be written to use types from multiple versions of a COM library without requiring a specific PIA for each version. This is a common scenario for applications that use objects from Microsoft Office libraries. Embedding type information enables the same build of a program to work with different versions of Microsoft Office on different computers without the need to redeploy either the program or the PIA for each version of Microsoft Office.

    You just need to set the the Embed Interop Types property to true for the interop reference. See Walkthrough: Embedding Type Information from Microsoft Office Assemblies (C# and Visual Basic) for more information.


    Wednesday, April 1, 2015 7:33 AM