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'.
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 library in your project.
Following are the steps to add the reference of WindowsBase library in your project.
1. Right click on the Project inside Solution Explorer window and click on Add and then Reference from the context menu.
2. Inside the Reference Manager Dialog window, expand the Assemblies options on Left side and look for WindowsBase and check (select) the CheckBox and click on OK.
3. Finally, re-build your project and run it. You will not receive the error again.