草庐IT

is-there-an-environment-variable-

全部标签

c# - 在 C# 中抑制 "Member is never assigned to"警告

我有以下代码:ViewPortViewModel_Trochoid;publicViewPortViewModelTrochoid{get{return_Trochoid;}set{this.RaiseAndSetIfChanged(value);}}使用ReactiveUIINPC支持。编译器总是警告我Trochoid永远不会分配给并且永远为空。然而,由于RaiseAndSetIfChanged通过CallerMemberName支持执行的魔法,代码确实有效,但编译器是错误的。我如何干净地在我的代码中抑制这些警告? 最佳答案 Ho

c# - HttpClient : The uri string is too long

鉴于以下尝试将数据发布到生成PDF文件的Web服务,PDFrocket(顺便说一下,这很棒)。我收到错误消息无效的URI:uri字符串太长为什么有人会对POSTed数据强加任意限制?using(varclient=newHttpClient()){//Buildtheconversionoptionsvaroptions=newDictionary{{"value",html},{"apikey",ConfigurationManager.AppSettings["pdf:key"]},{"MarginLeft","10"},{"MarginRight","10"}};//THISLI

c# - 序列化异常 : Type is not resolved for member "..."

我一直在尝试将程序集动态加载到AppDomain。我需要这样做是因为我想动态调用一个方法,但在我的应用程序运行时不要保留DLL的句柄,以便在需要时可以替换它。但我收到此SerializationException异常:类型未解析成员“...”这是我的代码:AppDomaindomain=AppDomain.CreateDomain("TempAppDomain",null,AppDomain.CurrentDomain.SetupInformation);try{objectobj=domain.CreateInstanceFromAndUnwrap(dllPath,typeName)

c# - TaskCompletionSource 抛出 "An attempt was made to transition a task to a final state when it had already completed"

我想使用TaskCompletionSource来包装MyService这是一个简单的服务:publicstaticTaskProcessAsync(MyServiceservice,intparameter){vartcs=newTaskCompletionSource();//EverytimeProccessAsynciscalledthisassignstoCompleted!service.Completed+=(sender,e)=>{tcs.SetResult(e.Result);};service.RunAsync(parameter);returntcs.Task;}

c# - 新手 LINQ 问题 : Is Paging in LINQ Queries Possible?

是否可以在Linq查询中使用“分页”功能?假设我有一些这样的XML:ChoiceOneChoiceTwoChoiceThree...ChoiceForty-EightChoiceForty-NineChoiceFifty如果我想实现分页功能,我是否能够为LINQ查询提供一个偏移量,以便我可以从第11个元素开始并在第20个元素结束?如果是这样,如果数据是对象列表而不是XML,查询会有什么不同吗? 最佳答案 varq=fromXinChoices.Skip((page-1)*pageSize).Take(pageSize)selectX

c# - NaoQi 和 Leap 问题 : An unhandled exception of type 'System.BadImageFormatException' . .. 并且无法加载文件或程序集

目前,我遇到了一个问题,我无法通过Google上的解决方案解决这个问题。到目前为止没有任何效果。当我编译LeapMotion代码并导入NaoqiC#库时,它工作正常。当我实际尝试使用一行代码连接到机器人时,我的程序崩溃了。我的程序设置为为任何CPU构建。.dll被Leap库和NaoQi库引用,并且.dll被放置在调试文件夹和项目文件夹中以备不时之需。目前我还不知道问题出在哪里。这里有人能弄清楚吗?我会很高兴让这个工作。这是第一条错误信息,然后它要求我中断或继续:Anunhandledexceptionoftype'System.BadImageFormatException'occur

C# 系统.Net.WebException : The underlying connection was closed: An unexpected error occurred on a send

我在一台运行WindowsServer2003的服务器上遇到此错误:System.Net.WebException:Theunderlyingconnectionwasclosed:Anunexpectederroroccurredonasend.这是我的代码...有什么想法吗?HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create("https://URLHERE");//request.Headers.Add("Accept","application/xml");byte[]bytes;bytes=System.Text.E

c# - 公开课 - "is inaccessible due to its protection level. Only public types can be processed."

我正在做一个测试项目来了解对象的XML序列化,但我遇到了一个奇怪的运行时错误:namespaceSerializeTest{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidForm1_Load(objectsender,EventArgse){}privatevoidserializeConnection(Connconnection){XmlSerializerserializer=newXmlSerializer(typeof(Conn));TextWritertextWrit

c# - 无法加载文件或程序集 ':This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded

我在我的解决方案中有3个项目:BL、DL和UI。这三个项目的目标框架都是>NET4;我通过查看每个项目的属性页仔细检查了这一点。当我尝试在托管环境中运行网站时收到以下错误消息,但在本地运行时却没有。Couldnotloadfileorassembly'BL'oroneofitsdependencies.Thisassemblyisbuiltbyaruntimenewerthanthecurrentlyloadedruntimeandcannotbeloaded.提前致谢! 最佳答案 -转到IIS。-DefaultWebSite->Y

c# - 有没有办法将参数传递给 is 运算符?

我正在尝试找到以下替代方法,以便我可以利用is运算符。publicboolIsOfType(Typetype){returnthis._item.GetType()==type;}类似于下面的内容,无法编译。publicboolIsOfType(Typetype){returnthis._itemistype;} 最佳答案 我认为您正在寻找Type.IsAssignableFrom:publicboolIsOfType(Typetype){return_item!=null&&type.IsAssignableFrom(_item.