- You have an application that is built by using a .NET Framework 4.0-based project in Microsoft Visual Studio.
- This application has a Microsoft Visual Basic 6.0 ActiveX control.
- This control references a Microsoft Office primary interop assembly file. For example, an office.dll file.
- You re-target the project to the .NET Framework 4.5.x in Visual Studio.
In this scenario, when you build the project, this build program cannot load the interop assembly for the control. Additionally, you receive an error message that resembles the following:
Note This issue only occurs on the computer that has the .NET Framework 4.0, the .NET Framework 4.5 or the .NET Framework 4.5.1, and the Microsoft Office product installed.
The .NET Framework 4.0 needs certain assemblies to be loaded when you resolve types from a type library which references a primary interop assembly. However, that was not the case in the .NET Framework 2.0. The ActiveX importer did not change behavior between the .NET Framework 2.0 and the Framework 4.0. This design change prevents generation of the interop assemblies. Therefore, when ActiveX importer runs in Visual Studio, the importer cannot resolve and preload all references for this ActiveX control.
- Find the required Office assembly in the Global Assembly Cache (GAC).
- Select the path of the office version that is mentioned in the error message. It will be something like C:\Windows\assembly\GAC\office\18.104.22.168__71e9bce111e9429c.
- Run the following command from the Visual Studio command prompt to generate the new interop assemblies:
aximp <Name of Ocx> /out: <Interop assembly name> /rcw: <C:\Windows\assembly\GAC\office\22.214.171.124__71e9bce111e9429c\office.dll>
- Add the generated interop assemblies to your Visual Studio project by using the "Add References" feature.
Note If Office primary interop assembly is not installed on the computer, the AxImp.exe tool still can resolve the types without any assistance, even when it runs from the Visual Studio build process.
ID članka: 2956788 - Poslednji pregled: 14.05.2014. - Verzija: 1