草庐IT

the_string

全部标签

c# - 将 C# 中的 String^ 转换为 C++/CLI 中的 CString

我在用MFC编写我的应用程序时遇到了一个问题,需要帮助。我在我的应用程序中使用CLR即CommonLanguageRuntime来集成c#API。但现在我坚持将System::String^转换为CString。我做不到。我正在使用以下代码。String^csPass=gcnewString(strPassword.GetBuffer());array^Value=Encoding::UTF8->GetBytes(csPass);for(inti=0;iLength;i++){csPass+=String::Format("{0:X2}",Value[i]);}现在我想将csPass转

c# - 从 .NET : the ‘return null’ issue 调用 Java/AXIS Web 服务

我一直在通过所有谷歌、stackoverflow等寻找这个问题。我找到了很多相关的答案,但没有找到真正的解决方案。我正在使用来自.NET客户端的Axis服务,但返回始终为空,无论我发送什么参数,始终为空。所以我开始寻找,并尝试从SOAPUI中使用它,它成功了!所以我的第一个想法是,.NET做错了什么,我搜索了又搜索,发现命名空间存在一些问题。相关帖子here所以在此之后,我尝试通过服务引用、Web引用使用服务,使用WSDL.EXE创建代理(它创建得很好!)并查找所有namespace,但一切都很好..我做了对命名空间进行了一些更改,但没有任何更改。然后我发现不仅命名空间有问题,数组也有

c# - 如何实现 StringBuilder 和/或调用 String.FastAllocateString?

我很想知道我是否可以创建一个优化版本的StringBuilder(尝试稍微加快它的速度,因为它目前是我的一个应用程序的瓶颈)。对我来说不幸的是,它似乎利用了我无法使用(或者看起来如此)的“神奇”系统调用。反编译System.Text.StringBuilder的源代码后,我注意到它使用了以下内部(因此无法调用)系统调用:[SecurityCritical][MethodImpl(MethodImplOptions.InternalCall)]internalstaticstringFastAllocateString(intlength);还有这个未记录的属性被大量使用:[ForceT

c# - Azure Devops 上的 Nuget 还原失败,消息为 "unable to load the service index for source"

我有一个在私有(private)代理中运行的.NET解决方案的构建。该解决方案同时包含.NETCore2.1和.NETStandard2.0项目。安装的一些nuget包如下:NETStandard.Libraryv2.0.3Microsoft.AspNetCore.Mvcv2.0.0Microsoft.NETCore.Appv2.1.5尝试恢复nuget包时构建失败,出现以下错误:"F:\Agent01\w\141\s\xxxxxxx.sln"(Restoretarget)(1)->(Restoretarget)->C:\ProgramFiles\dotnet\sdk\2.1.500\

c# - 如何修复 "The CORS protocol does not allow specifying a wildcard (any) origin and credentials at the same time"错误

我已经在C#.netCore的项目上启用了CORS在startup.cs中我添加了行...services.AddCors();...app.UseCors(builder=>builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());但是当我尝试在另一个Blazor项目中使用API时,我在Host上的API项目日志中看到了这个错误TheCORSprotocoldoesnotallowspecifyingawildcard(any)originandcredentialsatthesame

c# - ASP.NET 核心,Web API : No route matches the supplied values

请注意:这个问题是在2016年提出的。这个问题的最初答案是更新microsoftapiversiong包。最近几天,问题再次出现,但由于其他原因。原始问题:我在asp.netcore(webapi)中遇到了一些路由问题。我有这个Controller(简化版):[ApiVersion("1.0")][Route("api/v{version:apiVersion}/[Controller]")]publicclassDocumentController:Controller{[HttpGet("{guid}",Name="GetDocument")]publicIActionResult

C# 动态 Linq : Implement "Like" in The Where Clause

所以我想为我的数据做一个通用的分类器。我有这段代码可以从数据库中获取数据,它将仅提取包含value的数据。usingSystem.Linq.Dynamic;publicstaticIQueryableSortList(stringsearchString,TypemodelType,IQueryablemodel){....stringtoStringPredicate=type==typeof(string)?propertyName+".Contains(@0)":propertyName+".ToString().Contains(@0)";model=model.Where(p

c# - String.comparison 性能(带修剪)

我需要做很多高性能的不区分大小写的字符串比较,并意识到我这样做的方式.ToLower().Trim()真的很愚蠢,因为所有的新字符串都被分配了所以我仔细研究了一下,这种方式似乎更可取:String.Compare(txt1,txt2,StringComparison.OrdinalIgnoreCase)这里唯一的问题是我想忽略前导或尾随空格,即Trim()但如果我使用Trim,我会遇到与字符串分配相同的问题。我想我可以检查每个字符串,看看它是StartsWith("")还是EndsWith(""),然后才修剪。或者找出每个字符串的索引、长度并传递给string.Compareoverr

c# - 使用 SmtpClient 发送电子邮件时的故障排除 "Mailbox unavailable. The server response was: Access denied - Invalid HELO name"

我一直在尝试通过C#发送电子邮件。我在Google上搜索了各种示例,并从每个示例和每个人最有可能使用的标准代码中提取了点点滴滴。stringto="receiver@domain.com";stringfrom="sender@domain.com";stringsubject="HelloWorld!";stringbody="HelloBody!";MailMessagemessage=newMailMessage(from,to,subject,body);SmtpClientclient=newSmtpClient("smtp.domain.com");client.Crede

c# - 挣扎于最小起订量 : The following setups were not matched

我是第一次使用Moq,我正在努力让测试正常运行。我正在尝试最小化服务层的Save()方法。publicvoidSave(UserViewModelviewModel){//todo:thisstilldoesn'taddressupdatingapassword.TheUserViewModeldoesn'tcontainanyPassworddata.if(viewModel.Id!=Guid.Empty){//TheUserIdisnotempty,we'reeitherupdatinganexistinguser//orwe'reinsertinganewuserviasyncv