草庐IT

SE_BAD_FIELD

全部标签

c# - WCF 调用在 Fiddler On 时工作,否则在调试时给出 400 Bad Request

未解决-仍在寻找解决方案。我正在进行WCF调用并传递SAMLtoken:UsingSAMLtokenwithWebService(wsdl)privatestaticstringserviceEndpoint="httpsserviceendpoint";publicstaticvoidCallProviderService(SecurityTokentoken){varbinding=newWS2007FederationHttpBinding(WSFederationHttpSecurityMode.TransportWithMessageCredential);binding.S

c# - 使用 NEST Field Boosting 的 Elasticsearch

我正在使用NEST强类型客户端在C#中使用ElasticSearch。我有一个包含条目的索引:[ElasticType(Name="Entry",IdProperty="Id")]publicclassEntry{publicstringId{get;set;}publicstringTitle{get;set;}publicstringDescription{get;set;}publicstringAward{get;set;}publicintYear{get;set;}}其中Year是参赛作品的年份,例如2012,Award是参赛作品获得的奖项类型,可以为空。然后我想使用不同属

c# - 为什么 Property 执行比 Field 或 Method 执行慢?

在CLRviaCSharp第10章“属性”JeffRichter写道:Apropertymethodcantakealongtimetoexecute;fieldaccessalwayscompletesimmediately.Acommonreasontousepropertiesistoperformthreadsynchroni-zation,whichcanstopthethreadforever,andtherefore,apropertyshouldnotbeusedifthreadsynchronizationisrequired.Inthatsituation,ameth

c# - 格式化日期时间错误 "Templates can be used only with field access, property access, single-dimension array index.."

在MVCRazorView中,我试图将DateTime字段格式化为仅显示时间。使用下面的代码我收到错误“模板只能用于字段访问、属性访问、一维数组索引或单参数自定义索引器表达式。”@(Html.DisplayFor(m=>row.LastUpdatedDate.ToString("HH:mm:ss")))任何帮助请问是什么导致了这个错误以及如何解决它?感谢您的帮助。 最佳答案 我遇到了同样的问题,我已经解决了。如果您想将“LastUpdatedDate”转换为特定格式,那么您可以试试这个:@Html.TextBoxFor(m=>row

c# - ProtoBuf-Net 和 Compact Framework 出现 "Invalid field in source data: 0"错误

有人知道使用ProtoBuf-Net在紧凑框架和完整.Net框架之间进行序列化/反序列化时有任何问题吗?我有一个名为LogData的类,我正在compactframework3.5下序列化,传输到服务器(运行.Netframework4.0),然后反序列化。有时它有效,有时它会抛出上述错误,我还没有将其缩小到任何特定原因。我用不同的值做了很多测试,但似乎无法找到错误发生时的任何韵律或原因。我在下面包括我的类(class)(减去各种构造函数)。我已多次查看两侧的字节缓冲区,但尚未发现通过线路从一侧发送到另一侧的数据存在差异。[ProtoContract]publicclassLogDat

c# - Lazy<T> 延迟加载错误 : A field initializer cannot reference the non-static field, 方法或属性

我第一次尝试使用延迟加载来初始化我的类中的进度对象。但是,我收到以下错误:Afieldinitializercannotreferencethenon-staticfield,method,orproperty.privateLazym_progress=newLazy(()=>{longtotalBytes=m_transferManager.TotalSize();returnnewProgress(totalBytes);});在.NET2.0中,我可以执行以下操作,但我更愿意使用更新的方法:privateProgressm_progress;privateProgressPro

c# - 使用 WebClient 和 C#,即使响应为 (400) Bad Request,我如何获取返回的数据?

我正在使用GoogleTranslateAPI并trycatch当我收到error时返回的数据.(仅供引用:我知道APIkey是错误的,我只是在测试它)。问题是浏览器,您可以通过单击链接看到,显示错误信息,但C#抛出WebException,我似乎无法获得响应数据。这是我的代码:stringurl="https://www.googleapis.com/language/translate/v2?key=INSERT-YOUR-KEY&source=en&target=de&q=Hello%20world";WebClientclnt=newWebClient();//Getstrin

c# - 无法上传到 Azure Blob 存储 : The remote server returned an error: (400) Bad Request

我正在尝试创建一个实用程序来从Internet下载文件并将其再次上传到Azureblob存储。Blob容器已经创建好了;但出于某种原因,当我尝试将文件上传到存储时出现“BadRequest400”异常......创建了容器名称,小写字母,特殊字符。但我仍然不知道为什么会出现异常!请帮忙。注意:我没有使用任何模拟器...直接在云端进行测试。我的所有容器都具有“公共(public)容器”访问选项。异常(exception)情况:Anexceptionoftype'Microsoft.WindowsAzure.Storage.StorageException'occurredinMicros

c# - 如何自定义 "Encapsulate Field"生成的代码格式?

以前我相当确定“封装字段”命令会变成如下所示:publicintSomeNumber;进入以下内容(我想要来自VS2015的内容):privateintsomeNumber;publicintSomeNumber{get{returnsomeNumber;}set{someNumber=value;}}但在VisualStudio2015中,我看到了以下内容:privateintsomeNumber;publicintSomeNumber{get{returnsomeNumber;}set{someNumber=value;}}有办法解决这个问题吗? 最佳答

C# 互操作 : bad interaction between fixed and MarshalAs

我需要将C#4.0中的一些嵌套结构编码为二进制blob以传递给C++框架。到目前为止,我使用unsafe取得了很大的成功。/fixed处理基本类型的固定长度数组。现在我需要处理一个包含其他结构的嵌套固定长度数组的结构。我使用了复杂的变通方法来展平结构,但后来我遇到了一个MarshalAs的例子。看起来像它可以为我节省很多问题的属性。不幸的是,虽然它给了我正确的数据量,但它似乎也停止了fixed正如该程序的输出所示,数组不会被正确编码。您可以通过在最后一行放置断点并检查每个指针处的内存来确认失败。usingSystem;usingSystem.Threading;usingSystem.