Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

c# - Why am I getting error CS0246: The type or namespace name could not be found?

I am using Snarl C# API to send notifications to snarl.

Now I have saved the content of above url in a file named SnarlNetwork.cs and the content of my test.cs file are:

using SnarlNetworkProtocol;
using System;
class test
{
    public static void Main(String[] args)
    {
        SNP snarl_object = new SNP();
        string hostname = "localhost";
        string hostport = "9887";
        string appName = "Spotify";

        bool val = snarl_object.register(hostname, hostport, appName);

        if (val == true)
        {
            string title = "hello";
            string message = "world";
            string timeout = "5";
            bool newval = snarl_object.notify(hostname, hostport, appName, null, title, message, timeout);

            if (newval == true)
            {
                Console.WriteLine("sucessfull");

            }
        }
    }

}

Now when I try to compile my test.cs file using csc test.cs I get the following error:

C:UsersNoobcsharp>csc test.cs
Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.4926
for Microsoft (R) .NET Framework version 3.5
Copyright (C) Microsoft Corporation. All rights reserved.

test.cs(1,7): error CS0246: The type or namespace name 'SnarlNetworkProtocol' could not be found (are you missing a using directive or an assembly reference?)

So, what am I doing wrong here because according to me I am not missing any using directive.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I was using .NET Framework 4.5 but my new library had .NET Framework 4.5.2 and I got the same issue when I tried to build. I solved it by updating my project from 4.5 to 4.5.2 (same as my library).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...