简体   繁体   English

''是命名空间,但用作类型

[英]'' is a Namespace but used as a Type

I have searched through many similar questions to this, none have had the answer for my own issues.. In an ASP.Net MVC application I have 2 projects, an ASP.NET Web Application (.Net Framework) and a Class library. 我搜索了许多与此类似的问题,但没有一个针对我自己的问题得到答案。.在ASP.Net MVC应用程序中,我有2个项目,一个ASP.NET Web应用程序(.Net Framework)和一个类库。
In a Controller in the Web App I am trying to instantiate an object of one of the classes in the Class library, however, I get the error that is the title of the post. 在Web App的Controller中,我试图实例化Class库中一个类的对象,但是,出现错误,即帖子标题。

This is the constructor part of the class I am trying to access.. 这是我尝试访问的类的构造函数。

namespace GoogleDirections
{
    public sealed class Geocoder : HttpWebService
    {
        public Geocoder(string key) : base(key)
        {
        }
}

And this is the call in the controller.. 这是控制器中的调用。

public double[] GetLatLong(string address)
{
    double[] latLng = new double[2];
    var geocoder = new Geocoder("xxxMyAPIKeyblahblahxx");
    return latLng;
}

The error is "'Geocoder' is a Namespace but used as a Type" 错误是“'Geocoder'是一个命名空间,但用作类型”

The controller has using statement using GoogleDirections; and references the Class library that contains the Geocoder class. 控制器具有using GoogleDirections; and references the Class library that contains the Geocoder class. using语句using GoogleDirections; and references the Class library that contains the Geocoder class. using GoogleDirections; and references the Class library that contains the Geocoder class.

Does anyone have a clue what I might have been missing? 有人知道我可能会缺少什么吗?

按照通信中的说明,尝试编写new GoogleDirections.Geocoder("YourKey")或Geocoder类所在的名称空间,但在此处可以将其标记为答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM