草庐IT

create_method

全部标签

c# - SSL 网络服务 : Could not create SSL/TLS secure channel

我的C#.net应用程序正在使用HTTPS网络服务。由于证书现在即将过期,我正在尝试用我得到的新证书更新它(一个.jks文件,我使用javasdks的keytool将其转换为.p12)。我认为这很容易,因为我知道该怎么做,但它就是不合作。到目前为止我做了什么:将证书导入到CURRENT_USER\Personal导入证书到LOCAL_MACHINE\Personal给定正确的用户(apppoolidentity)通过winhttpcertcfg工具访问证书的私钥。以下是权限列表用于证书。使用findprivatekey工具,我还找到了实际的key文件,并授予apppoolidentit

c# - F# 列表到 C# IEnumerable : most efficient method?

我目前正在使用用C#编写的带有GUI的F#库,我想问一下将F#(通用)列表传递给C#代码(通用IEnumerable)的最佳或正确方法是什么。到目前为止我找到了三种方法:[1;2;3;4;5;]|>List.toSeq[1;2;3;4;5;]|>Seq.ofList[1;2;3;4;5;]:>seq请问这三种方法有什么实际区别吗? 最佳答案 如果查看F#库源代码,您会发现它们都是一样的:Seq.ofList只需调用List.ofSeq如你所见hereinthe"list.fs"fileList.toSeq使用s:>seq实现如你所见

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

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

c# - 计划的 Azure WebJob 但未调用 NoAutomaticTrigger-Method

这个问题与这个问题相关:RunningAzureWebJobwithoutqueue我的场景:我只想每小时将一个文件写入blob存储,不需要任何队列系统。从前一个问题中,我得到了这段代码——它在第一次被触发时运行良好:[NoAutomaticTrigger]publicstaticvoidDoWork([Blob("container/foobar.txt")]TextWriterwriter){writer.Write("HelloWorld"+DateTime.Now.ToShortTimeString())"}staticvoidMain(){JobHosthost=newJob

c# - 系统.Runtime.Serialization.InvalidDataContractException : No set method for property

如错误所示,我的属性没有setter,但我不想要setter,它应该是只读的。 最佳答案 已编辑:使二传手成为内部。这仍然可以在程序集中设置,但这是一个很好的技巧,当用于位于其他人使用的程序集中的数据对象时效果很好,因为那些使用程序集的人将无法设置该属性,但是各种序列化程序都可以。 关于c#-系统.Runtime.Serialization.InvalidDataContractException:Nosetmethodforproperty,我们在StackOverflow上找到一个类

c# - 简易喷油器 : Factory classes that need to create classes with dependencies

我有一个工厂类,它创建了几个不同类型的类。工厂在容器中注册。鉴于它们也具有依赖性,在工厂内部创建类的推荐方法是什么。我显然想避免对容器的依赖,但如果我新建这些类,那么它们将不会使用容器。例如publicclassMyFactory{publicIMyWorkerCreateInstance(WorkerTypeworkerType){if(workerType==WorkerType.A)returnnewWorkerA(dependency1,dependency2);returnnewWorkerB(dependency1);}}所以问题是我从哪里获得这些依赖项。一种选择是使它们成

c# - 如何在 .NET Core 2.1 中使用 String.Create 的示例

有谁知道这个方法是如何使用的?文档有点“轻”!publicstaticstringCreate(intlength,TStatestate,System.Buffers.SpanActionaction);https://learn.microsoft.com/en-us/dotnet/api/system.string.create?view=netcore-2.2 最佳答案 String.Create()method需要三样东西:决赛length的字符串。您必须事先知道这一点,因为该方法需要它安全为Span创建一个内部固定长度缓

c# - C++/命令行界面 : How do I declare abstract (in C#) class and method in C++/CLI?

以下C#代码在C++/CLI中的等价物是什么?publicabstractclassSomeClass{publicabstractStringSomeMethod();} 最佳答案 只需稍微混合关键字即可获得正确的语法。abstract在C#中位于前面,但在C++/CLI中位于末尾。与override关键字相同,今天也被C++11兼容的编译器识别,它们期望它位于函数声明的末尾。就像传统C++中的=0标记函数抽象一样:publicrefclassSomeClassabstract{public:virtualString^SomeM

c# - BitmapFrame.Create 异常(WPF 框架中的错误?)

我实现了一个C#应用程序,它以30fps的帧速率接收帧RGB。帧到达事件是用这段代码管理的:voidclient_ColorFrameReady(objectsender,ColorFrameReadyEventArgse){mycounter++;Console.WriteLine("newframereceived:"+mycounter);if(writer!=null){count++;if(count%2==0){using(varframe=BitmapImage2Bitmap(e.ColorFrame.BitmapImage))using(varthumb=ResizeB

c# - 为什么这个程序会出错? `Object synchronization method was called from an unsynchronized block of code`

这段代码有什么问题?我收到“从未同步的代码块调用对象同步方法”。我在谷歌上发现了一个结果,说我可能在锁定之前释放了一个互斥体,但根据我的输出,情况并非如此。这是互斥锁代码,中间没有其他代码。-edit-对不起大家,贴错了。我的输出1W1W2W代码usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Threading;namespacesqliteTest{classProgram{staticvolatileMutexmut1=newMutex();staticvolatileMutexmut