RanRag RanRag - 1 month ago 10
C# Question

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

and the content of my
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)



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

C:\Users\Noob\csharp>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


This is the problem:

C:\Users\Noob\csharp>csc test.cs

You haven't added a reference to the DLL. You need something like:

C:\Users\Noob\csharp>csc test.cs /r:SnarlNetwork.dll

(or whatever the assembly is called).

Alternatively, if you haven't got it as a separate library, just compile both files:

C:\Users\Noob\csharp>csc test.cs SnarlNetwork.cs

If you haven't compiled an assembly but want to, you can use:

csc /target:library /out:SnarlNetwork.dll SnarlNetwork.cs

csc Test.cs /r:SnarlNetwork.dll

(In fact, specifying the output file is unnecessary in this particular case, but it's still clearer...)