Errors when creating a TextElement from ArcObjects

Discussion created by kpearson272 on Oct 31, 2013
Latest reply on Oct 31, 2013 by Neil
I am attempting to add some text in the layout view of ArcMap. I???m using the following line for the TextElement that I???ve found online from numerous places including ArcObjects Library Reference. Being new to ArcObjects, I'm not sure if I'm doing something wrong or if there is something else going on that I'm unaware of.

ITextElement textElement = new TextElementClass();

I'm receiving the following errors:

The type TextElementClass has no constructors defined
Interop type TextElementClass cannot be embedded. 

Full Code:

protected override void OnClick()
        IMxDocument mxDoc = ArcMap.Application.Document as IMxDocument;
        IMap map = mxDoc.FocusMap;
        IActiveView activeView = map as IActiveView;
        IPageLayout pageLayout = activeView as IPageLayout;

        if (activeView is IPageLayout)
            IGraphicsContainer graphContainer = pageLayout as IGraphicsContainer;
            ITextElement textElement = new TextElementClass(); 
            textElement.Text = "Test";
            IElement element = textElement as IElement;
            MessageBox.Show("This tool only functions in layout view");