I have created multiple ESRI addins, where the same code is used. I have created a class library, which I can reference rather than duplicating code. I have the following in my ESRI addin code which works fine

```
IMxDocument mxdoc = ArcMap.Application.Document as IMxDocument;

```

However if the same code is used in the class library, I am unable to build the dll. As the class library does not know about ArcMap, 

I have tried 

```
ESRI.ArcGIS.ArcMap.Application arcmapApp = new ESRI.ArcGIS.ArcMap.Application();
IMxDocument mxdoc = arcmapApp.Document as IMxDocument;

```

However when I run the code in my addin (that references my Class Library), i get the following error

[![enter image description here](https://i.stack.imgur.com/mvpFq.png)](https://i.stack.imgur.com/mvpFq.png)

What is the correct way of referencing ArcMap in a class library?