草庐IT

Type_system

全部标签

c# - “System.DateTime”不是有效的 Windows 运行时参数类型

我使用的是C#类,它在我的Windows应用商店应用程序(C#)中运行良好。但是当我尝试在Windows运行时组件中使用它时,出现以下错误:Calculator.Calculate(System.DateTime)'hasparameter'dateTime'oftype'System.DateTime'.'System.DateTime'isnotavalidWindowsRuntimeparametertype.类中的示例对象:publicDateTimeCalculate(DateTimedateTime){intdayNumberOfDateTime=ExtractDayNum

c# - DropCreateDatabaseIfModelChanges EF6 导致 System.InvalidOperationException : The model backing the context has changed

迁移到EntityFramework6后,我在构建服务器上执行单元测试时遇到错误。我正在使用DropCreateDatabaseIfModelChanges初始化程序。当我将其更改为MigrateDatabaseToLatestVersion时一切正常,但我想坚持使用之前的初始化程序。我得到的错误是:System.InvalidOperationException:System.InvalidOperationException:Themodelbackingthe'AppContext'contexthaschangedsincethedatabasewascreated.Consi

c# - 为什么这会呈现为 "System.Web.Mvc.SelectListItem"的列表?

我正在尝试使用从属性中提取的值来填充DropDownList,而我现在的最终结果是一个只有“System.Web.Mvc.SelectListItem”的列表。我确定我在这里省略了一些小步骤,但我终究无法弄清楚它是什么。生成列表的属性GET:publicIEnumerableAllFoo{get{varfoo=fromginBarorderbyg.nameselectnewSelectListItem{Value=g.fooid.ToString(),Text=g.name};returnfoo.AsEnumerable();}}Controller代码:publicActionRes

c# - 如何解决 '...is a ' type', which is not valid in the given context'? (C#)

以下代码会产生错误:Error:'CERas.CERAS'isa'type',whichisnotvalidinthegivencontext为什么会出现这个错误?usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;namespaceWinApp_WMI2{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){

c# - 没有无参数构造函数的类型的 Activator.CreateInstance(Type)

这个问题在这里已经有了答案:CreatinginstanceoftypewithoutdefaultconstructorinC#usingreflection(4个答案)关闭9年前。阅读工作中的现有代码,我想知道这怎么能行得通。我在程序集中定义了一个类:[Serializable]publicclassA{privatereadonlystring_name;privateA(stringname){_name=name;}}在另一个程序集中:publicvoidf(Typet){objecto=Activator.CreateInstance(t);}和那个简单的调用f(typeo

c# - 如何解决错误 :the type does not appear to implement microsoft. practices.servicelocation.iservicelocator?

我是MVC的新手,我正在关注“AdamFreeman的PROASP.NETMVC4”。我目前正在研究它的第6章。我正在学习如何使用MVC4中的Ninject进行依赖注入(inject)。我已经按照书中的描述创建了应用程序。现在我不明白为什么会出现以下错误:该类型似乎没有实现microsoft.practices.servicelocation.iservicelocator这是我的Controller代码:publicclassHomeController:Controller{privateProduct[]products={newProduct{Name="Kayak",Cate

c# - 错误 : Cannot implicitly convert type 'void' to 'System.Collections.Generic.List'

我正在尝试使用该控件从.ascx设置我的.ascx控件的属性。所以在我的一个包含此控件的.aspx中,我有以下代码试图设置我的嵌入式.ascx的ItemsList属性:Itemitem=GetItem(itemID);myUsercontrol.ItemList=newList().Add(item);我尝试设置的.ascx中的属性如下所示:publicListItemsList{get{returnthis.itemsList;}set{this.itemsList=value;}}错误:无法将类型“void”隐式转换为“System.Collections.Generic.List

c# - x :Type not found in user control library

我正在尝试在WPF用户控件库项目中创建一个ResourceDictionary。当我添加以下样式时:我收到一条错误消息:Thetype'x:Type'wasnotfound.Verifythatyouarenotmissinganassemblyreferenceandthatallreferencedassemblieshavebeenbuilt.我将x声明为:xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"当我在WPF应用程序项目中而不是在UserControl库项目中创建资源字典时,这会起作用。知道为什么吗?

c# - .Net 4.0 System.Web.Security.MembershipProvider 引用不明确?

我最近将我的BlogEngine.Net安装升级到1.6和.Net4.0,但是,我在执行升级时没有构建BlogEngine.Core。但是,当我现在尝试构建BlogEngine.Core项目时,编译失败,因为它无法加载(System.Web.Security.)MembershipProvider的符号。我认为这是一个.Net/C#/user问题,而不是BlogEngine问题。该项目引用了System.Web库,类文件(继承自MembershipProvider)包含一个用于System.Web.Security的Using。启用ReSharper后,IntelliSense会指示混

c# - 如何执行非阻塞 System.Beep()?

在C#中,我可以执行Console.Beep()。但是,如果您将持续时间指定为1000或1秒,则在该秒过去之前,它不会执行下一行代码。有没有什么方法可以以非阻塞方式执行Console.Beep(),这样它会继续发出哔哔声,并在发出哔哔声的同时继续执行下面的代码? 最佳答案 您可以在单独的线程中运行它。newThread(()=>Console.Beep()).Start();我今天早上醒来发现对这个答案的评论如潮。所以我想我会加入一些其他的想法。通过使用以下方法,也可以在线程池上运行线程来实现上述目标。Actionbeep=Cons