我正在尝试在C#程序的顶部定义一对类型别名。这是我想要做的一个简短的例子:
using System;
using System.Collections.Generic;
namespace Foo {
using TsvEntry = Dictionary<string, string>;
using Tsv = List<TsvEntry>;
}
当我尝试使用mcs 3.2.8.0编译它时,我得到以下错误消息:
foo.cs(6,19): error CS0246: The type or namespace name `TsvEntry'
我们在本地使用ADO 2019,我们有一个构建服务器,我们在其中构建一切。我有一个ASPNet网页,开发人员已经添加了第二个项目到SLN测试。
我得到了以下错误
XYZ.Tests\Properties\PexAssemblyInfo.cs(15,12): Error CS0246: The type or namespace name 'PexAssemblySettingsAttribute' could not be found (are you missing a using directive or an assembly reference?)
XYZ.Tests\
我正在运行Visual 2015和Windows8.1。我正在为一个控制台应用程序项目而挣扎。
该解决方案在Visual 2015中运行良好,但是当我尝试用mcs编译器编译它时,我会得到两个错误(Kattis代码测试使用)。找不到两个外部类。
我得到了以下错误:
Program.cs(28,13):错误CS0246:无法找到类型或名称空间名称Graph' could not be found. Are you missing an assembly reference? Program.cs(58,34): error CS0246: The type or namespac
我对C#相当陌生,尽管我尝试了许多补救措施,但我还是遇到了这个错误。我在用表格..。
错误声明:
错误CS0246无法找到类型或命名空间名称'Form1‘(您是缺少使用指令还是程序集引用?)
我的代码看起来是:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
您好,我正在使用unity包“移动动画集专业版v1.693。unity”用于unity字符移动当我在unity中导入包时一切正常,除了脚本文件,它给了我错误,我使用的是上一个unity版本的代码,这是代码 // (c)版权所有HutongGames,LLC 2010-2011。版权所有。 using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Transform)]
[Tooltip("Moves a Game Object t
我正在使用VS代码创建一个asp.net项目。这个问题是首先提出的,因为我需要使用AllowAnonymous操作过滤器。它给出了"The type or namespace name 'AllowAnonymousAttribute' could not be found.“的错误,所以我在开头添加了System.Web.Mvc;。它显示了error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web'你能给出什么建议吗
这是我之前问题的后续,我试着用BigIntegers代替ulong,但我肯定做错了什么。我是C#的新手,对Java很熟悉。这是我在转换方面最好的尝试:
using System;
namespace System.Numerics{
public class Factorial{
public static void Main(){
String InString = Console.ReadLine();
BigInteger num = 0;
BigInteger
我是一个统一的完全初学者,以及Visual 2022。
我试图制作一个2D游戏,并一直跟随本教程,。在25:11,我们将看到如何制作一个脚本来控制玩家的移动。在我准备使用Visual代码时,不再推荐VScode的统一调试器,不再使用函数。
为了解决这个问题,我切换到Visual 2022。我安装了“使用统一的游戏开发”和“.NET桌面开发”模块,并将Unity内的默认外部编辑器设置为VisualStudio2022。我还按照另一种形式的指示重新生成了.csproj文件。
尽管如此,我还是遇到了error CS0246: The type or namespace name 'Input
我希望使用字符串值创建类的实例。根据我在这里读到的:,它应该能工作!
public class Foo
{
public string prop01 { get; set; }
public int prop02 { get; set; }
}
//var assName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
var assName = System.Reflection.Assembly.GetExecutingAssembly().GetName().FullName;
我重命名了sln,csproj和namespace,但我得到了这三个错误,这是我在重命名之前没有的。 /App.razor(66,66): Error CS0246: The type or namespace name 'MainLayout' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
/obj/Debug/net5.0/Razor/App.razor.g.cs(155,155): Error CS1662: Cannot c
情况是这样的。我在Visual中创建一个新的类库项目,添加一些类。然后,在某个时候,我决定需要用System.Runtime.Serialization.DataContractAttribute标记某个类,并编写如下代码:
[DataContract]
public class MyDataContractClass {}
当我点击编译时,我会看到以下错误:
error CS0246:无法找到类型或命名空间名称'DataMember‘(您是缺少一个使用指令还是程序集引用?)
好的,问题是我忘记添加using指令来使类可见。我补充说
using System.Runtime.Ser
我正在尝试使用CICD从多项目.net解决方案构建单个cs项目,但在MSBuild中给出了错误。我正在使用boilerplate。下面是我的流水线的步骤:
在构建过程中,我得到了一些程序集引用错误,比如
Error CS0246: The type or namespace name 'Abp' could not be found (are you missing a using directive or an assembly reference?)
Error CS0246: The type or namespace name 'FullAudi
我试着制作一个弹药计数系统,里面有子弹的图像,当人物发射子弹时,子弹就消失了。我在跟踪
这似乎没问题,但现在我看到了这个错误:
资产\脚本\ GameFlow.cs (72,28):错误CS0246:无法找到类型或名称空间名称‘映像’(您是缺少指令还是程序集引用?)
我看不出这个问题。我想我可以通过添加"using UnityEngine.UI;“来解决问题,但问题依然存在。有人知道我怎么解决的吗?谢谢。
脚本中的代码是:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
List<Story>中有一个错误
无法找到类型或命名空间名称'List<>‘(您是缺少使用指令还是程序集引用?)(CS0246)项目
using System;
using project.Models;
namespace project.Models
{
public class Genre
{
public int GenreId { get; set; }
public string Name { get; set; }
public List<Story> Sto
我按照回购中的指示添加了google核心包,并根据文档添加了代码。
我收到以下错误:CS0246: The type or namespace name 'PlayAsyncOperation<,>' could not be found (are you missing a using directive or an assembly reference?)
此错误显示在_reviewManager.RequestReviewFlow();和_reviewManager.LaunchReviewFlow(_playReviewInfo)上。
知道会有什么问题吗?
我正在使用MVC 5开发一个应用程序,当我运行它时,我得到了这个错误
编译错误描述:在编译服务此请求所需的资源时发生错误。请查看以下具体错误详细信息,并适当修改源代码。
编译器错误消息: CS0246:无法找到类型或命名空间名称“模板”(您是缺少了使用指令还是程序集引用?)
源错误:
Line 28:
Line 29:
Line 30: public class _Page_Views_Emergence_Index_cshtml : System.Web.Mvc.WebViewPage<IEnumerable<template.model.em
我创建了以下类:
using System.Windows;
using System.Windows.Input;
using MyUtils.MyArgParser;
namespace MyUtils.MyImplement
{
public static class ImplementExitOnEscape
{
#region ImplementExitOnEscape
public static void Implement(Window window)
{
window.KeyDown +
全新的C#,并试图编写一个测试程序。但是,我得到了以下错误:
TypeTests.cs(30,41):错误CS0246:找不到类型或名称空间名称'book‘(您是缺少一个使用指令还是程序集引用?)C:\dev\gradebook\test\GradeBook.tests\GradeBook.tests.csproj TypeTests.cs(45,37):error CS0246:无法找到类型或名称空间名称“book”(您是缺少一个使用指令还是程序集引用?)C:\dev\gradebook\test\GradeBook.tests\GradeBook.tests.csproj Typ
在Mono基础上,有一个例子:
using System;
using System.Windows.Forms;
public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}
public HelloWorld ()
{
Text = "Hello Mono World";
}
}
我想知道如何在C#代码中添加自定义命名空间?例如,添加一个新的命名空间
考虑以下两种扩展方法:
using System;
using System.Collections.Generic;
using System.Linq;
public static class Extensions
{
public static bool Contains(this IEnumerable self, object obj)
{
foreach (object o in self)
{
if (Object.Equals(o, obj))
{
我将using System;放在第一行,但是当我试图在类方法中调用ConsoleColor时,它不会在intellisense中显示任何颜色选项。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace practice
{
class ConsoleColor
{
public void DisplayColor()
{
Console.ForegroundColor = Syste
我可以在本地构建我的分支,没有任何问题,但是当我试图通过团队基础构建时,我会得到两个错误。这些错误是在我最近添加到解决方案中的一个项目上生成的。
这些错误是:
EnvoyClient.cs(3,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) [c:\TF-Agents\Agent2017-002\_work\2\s\System\Envoy.Conne
我正在创建一个具有以下目录结构的小型应用程序:
GUI
- MainWindow.cs
Model
Resources
Utilities
Program.cs
MainWindow.cs位于GUI文件夹中,其命名空间为OrtizOL.BackupTimer.GUI,另一方面,Programs.cs位于根目录中,其名称空间为OrtizOL.BackupTimer。
BTMainWindow.cs文件:
using System;
using System.Drawing;
using System.Windows.Forms;
namespace OrtizOL.BackupTimer.GU
我是Linux、dotnet和postgres的新手。我正试图在C#中为数据库连接编写代码。但我错了
“无法找到类型或命名空间名称‘CS0246’(您是缺少使用指令还是程序集引用)。”
我使用的是ubuntu 14.04 64位,dnxcore版本5.0,postgresql,npgsql 3.1.0-alpha6 6。我在project.jason中将依赖项定义为"Npgsql":“3.1.0-alpha 6”。我的代码是,
using System;
using npgsql;
namespace testdbconn
{
public class tstdb
在c#中,如果我想添加其他系统名称空间,为什么需要调用每个命名空间?
例如,如果我想调用System.Text命名空间,必须使用:
using System;
using System.Text;
为什么我不能直接使用系统?
为什么我还必须使用System.Text调用?
为什么我不能仅仅通过使用系统来使用所有的系统名称空间?
为什么我们对所有的命名空间都使用System?的意思是 of system?
如果这个问题已经被问过了,很抱歉。我开始研究C#,并注意到C#不会自动导入嵌套名称空间。我不明白:
using System;
是否应该自动导入System名称空间中包含的所有类,对吗?所以我不需要写
using System.Windows.Form;
如果using Windows.Form还能工作,我会理解的。但是编译器无法解析它!那么,在它之前的using System;有什么意义呢?那么,为什么using System;不能自动导入System.Windows和System.Windows.Forms呢-如果这里的导入一词有误,很抱歉。也许迁移到全局命名空间是正确的术语。
我正在学习如何使用实体框架代码首先通过Azure移动应用程序服务创建我的数据库
但我有个错误,看起来
CS0246 C# The type or namespace name 'ForeignKeyAttribute'
could not be found (are you missing a using directive or an assembly reference?)
我已经使用了System.ComponentModel.DataAnnotations.Schema;,但它似乎不起作用。
我怎么才能解决这个问题?
====================
我很想知道如何使用指令很容易地找到。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Sockets;
using System.Threading;
继如何将数据推送到Algolia之后,尝试只使用SearchClient连接到algolia,已经在VS代码中安装了带有.NET CLI (dotnet Algolia.Search)的Algolia。
守则如下:
using System;
using System.Threading.Tasks;
using Algolia.Search;
using System.Net.Http;
using Newtonsoft.Json.Linq;
namespace Example
{
class Program
{
static async Task Main