Search code examples
c#using

Using directive does not work in Visual Studio 2015 C#


In my C# Project for an Outlook AddIn I've the typical namespacing implemented with the using directive (done by IDE):

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

But when I use a method / namespace / struct (whatever) which should be in a namespace specified above, I receive an error:

Code Screenshot

I only can use fully qualified methods, like

System.Windows.Forms.MessageBox.Show("OK");

With, for example,

Forms.MessageBox.Show("NN");

I receive Error CS0103

What am I doing wrong?


Solution

  • as you may notice, you included

    using System.Windows.Forms;
    

    thus you don't need to add Forms for Messagebox you ll also notice that System.Windows.Forms is greyed out