Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

How c# compiler search namespace? CS0118 error occurs.

$
0
0

I defined a class in Microsoft.Practices namespace in my project, which
referecs System.Xml.Linq.dll and System.Windows.Interactivity.dll files.

When using Expression class in System.Linq.Expressions namespace, the
project compile failure whith error message:
error CS0118: 'Microsoft.Expression' is a 'namespace' but is used like a 'type'

System.Windows.Interactivity.dll contains Microsoft.Expression.BlendSDK namespace,
which not used in my class, using alias can avoid this error. Microsoft.Practices
namespace conflicts with Microsoft.Expression.BlendSDK namespace. Does the compiler
search all *.dll files for a class to check namespace even not using that dll?

Is this a compiler bug? Or I missunderstand the compiler.

Thanks.

using System;
using System.Linq.Expressions;
//using EXP=System.Linq.Expressions.Expression;

namespace Microsoft.Practices
{
    class Program
    {
        static void Main(string[] args)
        {
            
        }

        //private static void ExpressionForm(EXP expression)
        private static void ExpressionForm(Expression expression)
        {
            if (expression.NodeType != ExpressionType.Call)
            {
                throw new InvalidOperationException("Invalid expression form passed");
            }
        }
    }
}




Viewing all articles
Browse latest Browse all 31927

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>