In this article I will explain with an example, how to resolve the following error: The type 'System.IO.Packaging.Package' is defined in an assembly that is not referenced. You must add a reference to assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in IIS.
Error
The following error occurs when you make use of
OpenXml Packaging Library in .Net framework.
Solution
The solution to this error is to add the reference of WindowsBase dll inside the bin folder of the Website.
Following are the steps to add the reference of WindowsBase dll.
1. Open the File Explorer and navigate to the .NETFramework v4.0 folder of the Reference Assemblies folder using the following command.
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
2. Inside the v4.0 folder, find the WindowsBase dll as shown below.
3. After finding the dll, copy it.
4. Once the dll is copied, paste it inside the bin folder of your Website.
5. Finally, run the website and you will not receive the error again.