草庐IT

the_menu

全部标签

c# - 一对一关系导致异常 : AssociationSet is in the 'Deleted' state. 给定多重约束

我首先按照此处规定的方法使用EF代码建立了一对一的关系:UnidirectionalOne-To-OnerelationshipinEntityFramework我的映射看起来像这样......protectedoverridevoidOnModelCreating(DbModelBuildermodelBuilder){modelBuilder.Entity().HasRequired(i=>i.NewsItem).WithOptional(e=>e.Asset).Map(m=>m.MapKey("NewsItemId"));}但是当我得到这个异常时......Arelationsh

c# - SerialPort port.open "The port ' COM 2' does not exist."

SerialPort.Open();我遇到了一个大问题我正在与USB虚拟COM端口(cdc)通信,它被列为COM2。它在TeraTerm/hyperTerminal等中运行良好。但是当我尝试在C#中打开端口时,它给了我异常Theport'COM2'doesnotexist。我使用SerialPort.GetPortNames()函数获取端口名称,调试时它看起来很好。我曾尝试将名称设置为硬编码,但没有成功。现在真正奇怪的是,它在某些PC上运行良好,而在其他PC上运行失败。在一些PC上,它总是失败,而在其他PC上,它有10%的时间失败。更奇怪的是它取决于所使用的USB端口,一些端口工作正常

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

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

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# - 使用 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

c# - 玻璃映射器 : InferType is ignored when querying the SitecoreContext

我已经在我的Sitecore7.1解决方案上安装了Glass.Mapper.Sc.CaSTLeWindsor版本3.1.2.11包,并尝试使用推断类型。我有以下类(class):[SitecoreType]publicclassServiceConfiguration{[SitecoreField(FieldName="ServiceId")]publicvirtualstringServiceId{get;set;}}[SitecoreType(TemplateId="{26512C19-8D30-4A1E-A2CD-3BA89AF70E71}")]publicclassJavasc