草庐IT

is_expected

全部标签

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# - 新手 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# - 公开课 - "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# - 'GET OR SET ACCESSOR EXPECTED' 是什么意思?

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data;usingSystem.Data.SqlClient;publicpartialclassRepeaterEx2:System.Web.UI.Page{SqlConnectioncn=null;SqlDataAdapterda=null;DataSetds=null;StringstrSqlQuery=

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

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

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# - 使用 FtpWebRequest 上传期间 "Requested URI is invalid"

我正在尝试将文件上传到FTP服务器上的目录。我将此方法与FtpWebRequest一起使用。我想将一个文件上传到该用户的主目录,但我总是收到以下错误消息:TherequestedURIisinvalidforthisFTPcommand.有什么问题?我试过关闭被动模式,但还是一样。staticvoidFtpUpload(){//Gettheobjectusedtocommunicatewiththeserver.FtpWebRequestrequest=(FtpWebRequest)WebRequest.Create("ftp://12.22.44.45");request.Metho

c# - 为什么 "Specified cast is not valid"错误*不*暴露根本原因?

按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭11年前。刚刚偶然发现了一个简单的错误,它提示了一个有趣的问题。环境:VS2010、NET.4、C#。从SQL存储过程获取返回值产生“指定的转换无效”异常:cm.Parameters.Add("@si",SqlDbType.SmallInt).Direction=ParameterDirection.ReturnValue;..cm.ExecuteNonQuery