I'm following a lab tutorial on .NET remoting and for that I need to create TcpChannel object. For that I have added using System.Runtime.Remoting namespace but it still gives me an error The type or namespace name 'TcpChannel' could not be found (are you missing a using directive or an assembly reference?)
I'm using Visual Studio 2015 Community Edition. I can't figure out what is causing this problem. I even googled it. Here's my code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Remoting;
namespace RemotingServer
{
class Program
{
static void Main(string[] args)
{
TcpChannel channel = new TcpChannel(8001);
}
}
}
The TcpChannel class is located in System.Runtime.Remoting.Channels.Tcp, so you have to get using that. Also check if you reference System.Runtime.Remoting.dll in your project.
Related
I try to use the following class in Unity
https://learn.microsoft.com/de-de/dotnet/api/system.security.cryptography.ecdiffiehellmancng?view=net-6.0
So my Code is simply:
using System;
using System.Collections;
using System.Text;
using UnityEngine;
using System.Security.Cryptography;
using System.IO;
public class SomeClass : MonoBehaviour
{
IEnumerator Start()
{
using (ECDiffieHellmanCng alice = new ECDiffieHellmanCng())
{ }
}
Unity responds like :
Assets\Scripts\TcpClientAsyncBehaviour.cs(27,16): error CS0246: The type or namespace name 'ECDiffieHellmanCng' could not be found (are you missing a using directive or an assembly reference?)
So i got the nugget File from here
https://www.nuget.org/packages/System.Security.Cryptography.Cng/6.0.0-preview.4.21253.7
made it a zip file and extracted the System.Security.Cryptography.Cng.dll from lib/netstandard2.0 and put it into unity.
Nothing changed.
I also tried the UnityNuget package but it refuses to install the nugget I would need.
I also tried to use an rsp File with the content -r:System.Security.dll and copied it into Unity still nothing.
Please help!
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Error CS0246 The type or namespace name 'Hardware' could not be found (are you missing a using directive or an assembly reference?) in visual c#
When we run this program in Visual Studio 2k19 in C# Console application There is problem showing :
Error CS0246 The type or namespace name 'Hardware' could not be found (are you missing a using directive or an assembly reference?)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OOP1
{
class Program
{
static void Main(string[] args)
{
Hardware hf = new Hardware(); // error in this line
Console.ReadLine();
}
}
}
--------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OOP1.com.inventoryMsystem
{
class Hardware : Product
{
public Hardware()
{
Console.WriteLine("Hardware");
}
}
}
----------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OOP1.com.inventoryMsystem
{
class Product
{
public Product()
{
Console.WriteLine("Product");
}
}
}
You are instantiating a reference to Hardware, which is a class you have created like so:
class Hardware : Product
{
public Hardware()
{
Console.WriteLine("Hardware");
}
}
However, the Program class, where you are referring to the Hardware class, is in a different namespace than your Hardware class. Program is in the OOP1 namespace, Hardware is in the OOP1.com.InventoryMsystem namespace. Therefore, your Program class does not really know what you are referring to.
To solve, add a Using statement to your Program class, to let this class 'find' your Hardware class thus:
using OOP1.com.InventoryMsystem
Your completed code for the Program class should look very similar to this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OOP1.com.InventoryMsystem;
namespace OOP1
{
class Program
{
static void Main(string[] args)
{
Hardware hf = new Hardware(); // No error now
Console.ReadLine();
}
}
}
I know that this question has been already asked, but I cannot find anything that can help solve my problem.
I want to connect my aspx page (Retete.aspx) to a Microsoft SQL database. I'm getting this error on Retete.aspx.cs:
Error 1 The type or namespace name 'GlobalClass' does not exist in the namespace 'ProiectSera' (are you missing an assembly reference?)
The error points to this line of code:
ProiectSera.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
Where ProiectSera is the project name, GlobalClass is the file where I make the operation on the db.
My using statements are:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProiectSera;
The Target Framework is set to .net-4.5.
What should I do to solve this error?
Update
My GlobalClass.cs is:
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.IO;
using ProiectSera;
using System.Data.Services;
namespace ProiectSera.App_Code
{
public static class GlobalClass
{
static public void Update(string _param1, string _param2)
{//function to update}
}
}
App_Code is a folder where GlobalClass.cs is. I tried and
ProiectSera.App_Code.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text); //
but I had the same error. And I put the GlobalClass.cs in the project's root. I also removed the .App_Code from namespace ProiectSera.App_Code
UPDATE1
My Retete.aspx.cs is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProiectSera;
using ProiectSera.App_Code;
namespace ProiectSera
{
public partial class Retete : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSave_Click(object sender, EventArgs e)
{
string intValRefTempSol;
string intValRefTempAer;
// intValRefTempSol = ValRefTempSol.Text;
// intValRefTempAer = ValRefTempAer.Text;
// ProiectSera.App_Code.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
}
}
}
Your GlobalClass is in the namespace ProiectSera.App_Code.
So the class name is ProiectSera.App_Code.GlobalClass
Make sure you don't have a ProiectSera class in the ProiectSera namespace also, otherwise if declaring using ProiectSera on top, it'll try to use it (as a general rule, don't name any class the same as your namespace).
If that still doesn't work, you may want to try using the global namespace:
global::ProiectSera.GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
and see if that works: if it doesn't, and GlobalClass is in the same project, then there's something else you haven't shown us
Update
The only other thing that comes to mind, if you are positive that both files are on the same project/assembly, is that GlobalClass.cs is not being actually compiled. Make sure the Build Action is set to Compile (you can see the build action right clicking on the GlobalClass.cs in the solution explorer and selecting Properties).
If you are using VS.NET:
Right click on the References folder on your project.
Select Add Reference.
Select the .NET tab (or select the Browse button if it is not a .NET Framework assembly).
Double-click the assembly containing the namespace in the error message.
Press the OK button.
Ensure the following...
That you have a project reference to ProiectSera from your web application, if it's in a separate library. If GlobalClass is in the web application project itself, you won't require this, but if GlobalClass is defined in a separate library in the same solution or elsewhere, then you're going to need to add a reference to that external library in your web application.
Ensure that ProiectSera should not be ProjectSera (if it's a typo).
Ensure that you have your ProiectSera using statement in place at the top (using ProiectSera;). Assuming that this is the correct namespace. Check the namespace of your GlobalClass class and use that using accordingly in the class that wishes to use its functionality.
Then, simply call this in your code, assuming that Update is a static method of GlobalClass.
GlobalClass.Update(ValRefTempSol.Text, ValRefTempAer.Text);
EDIT: given that you've now posted your GlobalClass code, you can see that the namespace for this class is ProiectSera.App_Code;. So you need to have that as your using statement in the other class using ProiectSera.App_Code;. And then call it via simply GlobalClass.Update, as mentioned above.
If you don't understand how namespacing works in C#, then I recommend you check this out (https://msdn.microsoft.com/en-us/library/dfb3cx8s.aspx).
I am learning ASP.NET by following one online tutorial (building web application). Problem is when I reuse tutor code I stuck on this error:
Error 1 The type or namespace name 'Uri' could not be found (are you missing a using directive or an assembly reference?)
I tried to include several namespaces (like System.Uri) and none of them worked. Does someone knows where's the problem and what do I need to do to solve the problem?
Here is code:
using System.Collections.Generic;
using System.Net;
using System.Linq;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Web;
using System.Web.Http;
using System.Net.Http;
using System.Data.Entity.Infrastructure;
using System.Uri;
public HttpResponseMessage Post(Friend friend)
{
if (ModelState.IsValid)
{
db.Friends.Add(friend);
db.SaveChanges();
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, friend);
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = friend.FriendId }));
return response;
}
else
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
}
You can't have using System.Uri;, since Uri is a class (and static import isn't allowed until Visual Studio 2015, which I suppose you are not using now, even in VS 2015, it would fail since Uri is not a static class)
Include:
using System;
and remove
using System.Uri;
from microsoft doc
http://msdn.microsoft.com/en-us/library/system.uri%28v=vs.110%29.aspx
the refence to include is System.dll This should be there by default. Check if you did not delete it by mistake.
I'm trying to add a reference to a project ("Geometry") that lives in another solution ("Bar Solution") into another solution ("Foo Solution"). Any project in Bar Solution (the home of the Geometry's source code) can import Geometry and use its features with no problem; however, when I add the DLL to Foo Solution, it imports fine, but the Object Browser shows it containing no namespaces or classes.
Has anyone experienced this problem or otherwise know of a solution? I can't find any information on SO or more generally, le Goog.
Object Browser of Foo Solution:
Bar's Solution Explorer:
Some code from Foo which is trying to use "Geometry":
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;
using Geometry; // Error: "The type or namespace name 'Geometry' could not be found
// (are you missing a using directive or an assembly reference?)"
namespace Lever
{
public partial class LeverGUI : Form
{
public LeverGUI()
{
InitializeComponent();
}
}
}