草庐IT

Bird_Name

全部标签

c# - WCF 服务引用 - 在客户端获取 "XmlException: Name cannot begin with the ' <' character, hexadecimal value 0x3C"

我有一个智能客户端应用程序通过WCF与其服务器进行通信。数据在客户端创建,然后通过服务发送以进行持久化。服务器和客户端通过共享dll使用相同的域类,我在VisualStudio中使用方便的“添加服务引用”功能来包装SvcUtil.exe并生成客户端和代理类。尝试调用该服务时出现以下错误:System.Xml.XmlExceptionoccurredMessage=Namecannotbeginwiththe'这特别麻烦,因为该服务一次可以运行数周而不会出现此错误,然后突然又没有警告地再次出现。我一直无法弄清楚是什么原因造成的。当它确实发生时,我将深入研究如何修复它并且通常不会想出比那些

c# - 初始化语法 : new ViewDataDictionary { { "Name", "Value"} }

我正在寻找一种将ViewDataDictionary传递给ASP.NETMVC中的部分View的方法,我想到了这种语法:newViewDataDictionary{{"Name","Value"}}我对这里的初始化语法有点困惑。谁能给我解释一下? 最佳答案 ViewDataDictionary工具IDictionary.IDictionary本质上是KeyValuePair的集合.你的ViewDataDictionary初始值设定项(外花括号)包含另一组表示KeyValuePair的花括号初始化程序。这可能的原因在thisanswe

c# - 如何在 Asp.Net MVC 4 中模拟 HttpContext.User.Identity.Name

我在Controller中有使用HttpContext的代码publicActionResultIndex(){varcurrentUser=HttpContext.User.Identity.Name;......}当尝试像这样使用NUnit编写测试时[Test]publicvoidCanDisplayRequest(){//Actvarresult=(ViewResult)_requestController.Index();//AssertAssert.IsInstanceOf(resut.Model);}测试将失败,因为它找不到HttpContext那么我如何模拟HttpCon

c# - 使用 LINQ 在列表中查找项目但得到 "Value cannot be null. Parameter name: source"

当使用LINQ从列表中获取数据时,我遇到了这个错误。如何解决?Valuecannotbenull.Parametername:sourcevarnCounts=fromsaleinsalselectnew{SaleID=sale.OrderID,LineItem=fromsliinsale.LineItemsgroupslibysli.ItemintoItemGroupselectnew{Item=ItemGroup.Key,Weeks=ItemGroup.Select(s=>s.Week)}};foreach(variteminnCounts){foreach(varitmssini

c# - Entity Framework 异常 : Invalid object name

我正在尝试使用CodeFirst方法创建数据库。当我运行以下代码时,出现以下异常。我定义的字段有什么问题吗?我们如何克服这个问题?异常:Anerroroccurredwhileupdatingtheentries.Seetheinnerexceptionfordetails.内部异常:"Invalidobjectname'dbo.Dinners'.注意:我的数据库中没有这样一张表(Dinners)。该代码应该创建表。我只是提供了连接字符串来标识服务器,如EFCodeFirst:CannotconnecttoSQLServer中所述.我应该更改连接字符串吗?连接字符串:stringcon

c# - 为什么我收到错误 CS0246 : The type or namespace name could not be found?

我正在使用SnarlC#API向snarl发送通知。现在我已经将上述url的内容保存在一个名为SnarlNetwork.cs的文件中,我的test.cs文件的内容是:usingSnarlNetworkProtocol;usingSystem;classtest{publicstaticvoidMain(String[]args){SNPsnarl_object=newSNP();stringhostname="localhost";stringhostport="9887";stringappName="Spotify";boolval=snarl_object.register(ho

c# - .NET 中的 "STRONG NAME"是什么?

这个问题在这里已经有了答案:关闭12年前。PossibleDuplicate:WhatisstrongnamingandhowdoIstrongnameabinary?其实我昨天去面试了。他们在那里问了我1个关于强名的问题。我无法猜到它是什么?请解释一下。谢谢。

c# - 系统参数异常 : The table type parameter must have a valid type name

我正在尝试将用户定义的表类型传递到C#中的查询中。类型定义为2列(组织和子组织)我的代码是这样的:DataSetds=newDataSet();try{DataTableFilteredOrgSubOrg=newDataTable("OrgSubOrgValueType");FilteredOrgSubOrg.Columns.Add("org",typeof(string));FilteredOrgSubOrg.Columns.Add("subOrg",typeof(string));FilteredOrgSubOrg.Rows.Add(org,orgsub);using(SqlCon

c# - HttpContext.Current.User.Identity.Name 如何知道存在哪些用户名?

这不一定是个问题,我只是好奇它是如何工作的。我有一个方法:publicstaticboolUserIsAuthenticated(){boolisAuthed=false;try{if(HttpContext.Current.User.Identity.Name!=null){if(HttpContext.Current.User.Identity.Name.Length!=0){FormsIdentityid=(FormsIdentity)HttpContext.Current.User.Identity;FormsAuthenticationTicketticket=id.Tick

c# - 调用lambda时 "DisplayClass"name是什么意思?

根据thisanswer当代码使用lambda方法内部的局部变量时,编译器将生成额外的类,这些类的名称可以例如c__DisplayClass1。例如下面的(完全没用的)代码:classProgram{staticvoidMain(){try{implMain();}catch(Exceptione){Console.WriteLine(e.ToString());}}staticvoidimplMain(){for(inti=0;i{Console.WriteLine(i);thrownewInvalidOperationException();});}}staticvoidinvok