草庐IT

application_name

全部标签

c# - XML 序列化错误 : 2 types both use the XML type name, 'Relationship',来自命名空间 ''

我在通过XML进行序列化时遇到问题,因为2个类使用一个类(尽管类不同!)称为关系。我尝试使用XML属性用另一个名称装饰其中的一个类,但它仍然给我以下错误:{"Types'SiteServer.Relationship'and'LocalServer.Relationship'bothusetheXMLtypename,'Relationship',fromnamespace''.UseXMLattributestospecifyauniqueXMLnameand/ornamespaceforthetype."}这是我的2个类(class),有人知道为什么吗??我使用了错误的属性吗?它似

c# - 禁用 "Name can be simplified"IDE0003 修复提示

即使在选项中禁用了检查,VisualStudio2017也会提示不必要的this限定符。它是这样的:(第一行是罪魁祸首,第二行是我希望this总是的样子。)将鼠标悬停在变灰的this上并单击灯泡会显示此建议的修复方法:我找不到完全禁用它的方法。有时我想要“不必要的”this限定符,有时我不想,所以我根本不希望VS对此发表评论。“无”是最不严重的选项,但它仍然显示这种恼人的不同颜色。是否有可能完全禁用此检查? 最佳答案 如果您知道其诊断ID(在本例中为“IDE0003”),则可以使用规则集文件来禁用任何分析关于References您项

c# - Thread.CurrentPrincipal.Identity.Name 在 WPF 中为空

编辑简单的问题是,我怎样才能让Thread.CurrentPrincipal.Identity.Name让当前用户在WPF中登录?结束编辑我正在尝试调用一个现有方法(不在任何类型的服务中;只是POCO中的一个方法)来检索当前用户:Thread.CurrentPrincipal.Identity.Name这段代码是由其他人编写的,并且(大概)与他的ASP.NETMVC项目一起工作。我正在尝试从WPF中调用相同的方法,但名称现在为空。我能做些什么吗? 最佳答案 将Thread.CurrentPrincipal设置为newWindowsP

c# - 响应消息的内容类型 application/xml;charset=utf-8 与绑定(bind)的内容类型不匹配 (text/xml; charset=utf-8)

我尝试使用独立应用程序使用WCFWeb服务。我可以使用InternetExplorer查看此服务,也可以在VisualStudio服务引用中查看。这是我遇到的错误Thecontenttypetext/html;charset=UTF-8oftheresponsemessagedoesnotmatchthecontenttypeofthebinding(text/xml;charset=utf-8).如何更改它以使用正确的内容类型?这是我的配置文件这是堆栈{System.ServiceModel.ProtocolException:Thecontenttypeapplication/xm

c# - 将 VB 转换为 C# - My.Application.Info.DirectoryPath

以下VB(VB.NET、VisualBasic)语句的最佳C#(csharp)等价物是什么:My.Application.Info.DirectoryPathMy.Computer.ClipboardMy.Computer.Audio.PlaySystemSound()My.Application.Shutdown() 最佳答案 应用程序.ExecutablePath系统.Windows.Forms.剪贴板系统.媒体.*应用程序.退出 关于c#-将VB转换为C#-My.Applicati

c# - 委托(delegate) : Method name expected error

我正在尝试让以下简单的委托(delegate)示例正常工作。根据我从中获取的一本书应该没问题,但我得到了一个Methodnameexpected错误。namespaceTestConsoleApp{classProgram{privatedelegatestringD();staticvoidMain(string[]args){intx=1;Dcode=newD(x.ToString());}}}有什么帮助吗? 最佳答案 删除():Dcode=newD(x.ToString);您想指定方法,而不是执行。

c# - "An assembly with the same simple name has already been imported"没有重复引用的错误

我收到以下错误:errorCS1704:Anassemblywiththesamesimplename'Interop.xxx.dll,Version=1.0.0.0,Culture=neutral,PublicKeyToken=nullhasalreadybeenimported.Tryremovingoneofthereferencesorsignthemtoenableside-by-side.我所看到的一切都表明我引用了两个同名的程序集,我需要删除其中一个。但是,我已经检查过并且只引用了一次。这也仅在我使用msbuild从我的开发箱上的命令行构建时发生。如果我通过VisualS

c# - 无法处理消息,因为内容类型 'application/json; charset=utf-8' 不是预期的类型 'text/xml; charset=utf-8'

我在通过ajaxjson调用WCF服务时收到上述响应。我的调用代码是:$(document).ready(function(){$.ajax({type:"POST",contentType:"application/json;charset=utf-8",url:"http://localhost:90/WebServices/UserService.svc/Calculate",data:"{}",timeout:10000,dataType:"json",success:function(response){alert(response)},error:function(xhr,

c# - Image.Save 崩溃 : {"Value cannot be null.\r\nParameter name: encoder"}

我正在尝试将图像保存到MemoryStream中,但在某些情况下会失败。代码如下:以下代码成功:Imageimg=Bitmap.FromStream(fileStream);MemoryStreamms=newMemoryStream();img.Save(ms,img.RawFormat);//Thissucceeds.以下代码失败:Imageimg=Bitmap.FromStream(fileStream);Imagethumb=img.GetThumbnailImage(thumbWidth,thumbHeight,null,System.IntPtr.Zero);MemoryS

c# - 具有路由属性的模糊 Controller 名称 : controllers with same name and different namespace for versioning

我正在尝试添加API版本控制,我的计划是为不同命名空间中的每个版本创建一个Controller。我的项目结构是这样的(注意:每个版本没有单独的区域)Controllers||---Version0||||-----ProjectController.cs||-----HomeController.cs||---Version1||-----ProjectController.cs|-----HomeController.cs我正在为路由使用RoutingAttribute。因此,Version0中的ProjectController具有路由功能namespaceMyProject.Co