草庐IT

access-modifiers

全部标签

c# - OLEDB 连接到 Access 数据库 (accdb)

我想为练习制作一个简单的应用程序,因此连接到像Access(.accdb)这样的简单数据库可能会很好我的程序是这样的:usingSystem;usingSystem.Collections.Generic;usingSystem.Data;usingSystem.Data.OleDb;usingSystem.Linq;usingSystem.Web;namespacemyProject.Account{publicclassDbManager{privateOleDbConnection_dbConnection;publicvoidOpenDbConnection(){_dbConn

c# - 无法使用 EFCore、EntityState.Modified : "Database operation expected to affect 1 row(s) but actually affected 0 row(s)." 编辑数据库条目

我将IdentityCore1.0与ASP.NETMVCCore1.0和EntityFrameworkCore1.0结合使用来创建一个简单的用户注册系统thisarticle作为起点,我正在尝试添加用户角色。我可以添加用户角色,但无法编辑它们。这是RolesController中的Edit操作:[HttpPost][ValidateAntiForgeryToken]publicIActionResultEdit(IdentityRolerole){try{_db.Roles.Attach(role);_db.Entry(role).State=Microsoft.EntityFrame

c# - "Access to the path ... is denied"(.NET C#)

我一直在将一个小的XML数据文件保存到外部驱动器,没问题。但后来我尝试使用ApplicationData文件夹和其他文件夹,甚至C:\但没有运气。我收到类似“访问路径“C:\”被拒绝”的错误。只是为了确认,文件已创建并使用当前代码正常读取到外部驱动器。我想这与安全和权限有关,但我没有发现任何有用的东西。如果您能在这方面为我指明正确的方向,请提前致谢!stringfipData=@"F:\IL2\SIIYM\SIIYMData.xml";//externaldriveok:-)//stringfipData=Environment.GetFolderPath(Environment.Sp

c# - 奇怪的 "Collection was modified after the enumerator was instantiated"异常

也许有人可以为我指出正确的方向,因为我对此一头雾水。我有一个函数可以简单地打印出类的LinkedList:LinkedListcomponents=newLinkedList();...privatevoidPrintComponentList(){Console.WriteLine("---ComponentList:"+components.Count+"entries---");foreach(Componentcincomponents){Console.WriteLine(c);}Console.WriteLine("------");}Component对象实际上有一个自定

c# - 避免 InvalidOperationException : Collection was modified? 的最佳实践

我经常需要这样的东西:foreach(Linelineinlines){if(line.FullfilsCertainConditions()){lines.Remove(line)}}这不起作用,因为我总是得到一个InvalidOperationException,因为Enumerator在循环期间被更改了。所以我将所有此类循环更改为以下内容:Listremove=newList();foreach(Linelineinlines){if(line.FullfilsCertainConditions()){remove.Add(line)}}foreach(Linelineinrem

C# : Modify a xml node

我有那个xml文件:Alarm1Desc103/07/201210:11AM1None我想将Alarm1的innertext修改为另一个值,所以我编写了实际上复制整个节点的代码。XmlDocumentxml=newXmlDocument();xml.Load("0.xml");XmlNodeListelements=xml.SelectNodes("//reminders");foreach(XmlNodeelementinelements){if(element.InnerText=="Alarm1"){XmlNodenewvalue=xml.CreateElement("MODIF

c# - 错误 : Cannot find all types required by the 'async' modifier. 您是否针对错误的框架版本,或缺少对程序集的引用?

我的电脑配置如下:Windows8VisualStudio2012.NETFramework4.5我的项目配置是:WP7.1银光4.0.NETFramework4.0CTPASYNC(已安装,使用async和await关键字)该项目是使用VS2010在Windows7机器上为WP7.1编写的。现在我已经将PC升级到Windows8并安装了VS2012。然而,该项目提示“async”修饰符。无法找到“async”修饰符所需的所有类型。您是针对错误的框架版本,还是缺少对程序集的引用?知道如何解决这个问题吗?谢谢! 最佳答案 有支持Sil

c# - 未经授权的访问异常 : Invalid cross-thread access in Silverlight application (XAML/C#)

C#相对较新,想尝试使用它来使用一些第三方Web服务API。这是XAML代码这是C#代码privatevoidButton_Click(objectsender,RoutedEventArgse){HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create("http://api.twitter.com/1/users/show/keykoo.xml");request.Method="GET";request.BeginGetResponse(newAsyncCallback(twitterCallback),request);}p

C# ASP.NET : how to access cache when no HttpContext. 当前是否可用(为空)?

期间Application_End()在Global.aspx中,HttpContext.Current为空。我仍然希望能够访问缓存-它在内存中,所以想看看我是否可以以某种方式引用它以将位保存到磁盘。问题-当HttpContext.Current为null时,有没有办法以某种方式引用内存中的缓存?也许我可以创建一个全局静态变量来存储指向缓存的指针,我可以根据HTTP请求更新它(伪:"static"=HttpRequest.Current)并通过Application_End()中的该指针检索对缓存的引用?有没有更好的方法在没有HttpRequest的情况下访问内存中的Cache?

c# - 系统.ComponentModel.Win32Exception : Access is denied Error

我正在使用C#代码启动和停止窗口服务,但出现此错误。System.ComponentModel.Win32Exception:Accessisdenied我的代码:publicvoidStartService(stringserviceName,inttimeoutMilliseconds){ServiceControllerservice=newServiceController(serviceName);try{TimeSpantimeout=TimeSpan.FromMilliseconds(timeoutMilliseconds);service.Start();service