草庐IT

protecting-connection-information

全部标签

c# - "opening a connection"实际上是什么意思?

我试图向某人解释为什么数据库连接实现IDisposable,当我意识到我真的不知道“打开连接”实际上是什么意思时。所以我的问题是-c#在打开连接时实际上做了什么?谢谢你。 最佳答案 实际上有两个类涉及实现连接(实际上更多,但我正在简化)。其中之一是IDbConnection您在代码中使用的实现(SQLConnection、NpgsqlConnection、OracleConnection等)。另一个是程序集内部的“真实”连接对象,对您的代码不可见。我们暂时将其称为“RealConnection”,尽管其实际名称因不同的实现而异(例如

c# - 如何使用最小起订量测试调用 protected 助手的代码

我目前运行的测试如下所示://InBlah.cspublicclassClassUnderTest{publicboolMethodUnderTest(){//Doabunchofstuff...returnHelperMethod();}protectedvirtualboolHelperMethod(){boolsuccess=false;//ProprietaryHardwareAccess.//DatabaseCalls.//FileSystemModifications.returnsuccess;}}//InTestBlah.cspublicclassTestStub:Cl

c# - 添加服务引用给出异常 : Unable to connect to remote server

从控制台应用程序客户端调用时,我的WCF服务返回结果。但是,它正在显示Exception:Unabletoconnecttoremoteserver实际错误:Failedtoinvoketheservice.Possiblecauses:Theserviceisofflineorinaccessible;theclient-sideconfigurationdoesnotmatchtheproxy;theexistingproxyisinvalid.Refertothestacktraceformoredetail.Youcantrytorecoverbystartinganewpro

c# - 从 ftp 服务器下载文件时为 "The underlying connection was closed"

我想从ftp服务器下载文件。我写了下面的代码来从ftp下载文件publicvoiddownloadFile(stringFTPAddress,stringfilename,stringusername,stringpassword,stringdestFile){try{FtpWebRequestrequest=FtpWebRequest.Create(FTPAddress+filename)asFtpWebRequest;request.Method=WebRequestMethods.Ftp.DownloadFile;request.Credentials=newNetworkCr

c# - TCP 错误代码 10061 : No connection could be made because the target machine actively refused it

很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visitthehelpcenter.关闭9年前。Couldnotconnecttonet.tcp://localhost:5051/user.Theconnectionattemptlastedforatimespanof00:00:02.0600206.TCPerrorcode10061:Noconnectioncouldbemadebecausethetargetmachineactivelyrefusedit127.0.0.1:5051.

c# - Facebook Connect 与使用 ASP.NET Membership Provider 的站点集成

是否有任何最佳实践或示例说明如何使用成员资格提供程序(或类似的东西)将Facebook连接与现有ASP.NET应用程序最佳集成。我确信我可以做一些事情,但是,如果有一些关于此的信息和最佳实践来减轻任何安全问题,那就太好了。目前我可以让用户“连接”并获取他们的信息,但是,我希望尽可能安全地处理它们,并尽可能与现有用户类似。特别是,我希望他们在“用户”表中有一个条目。对于与ASP.NETMVC相关的任何信息,这将非常有用。我迄今为止发现的一些有用的链接:http://facebooktoolkit.codeplex.com/Thread/View.aspx?ThreadId=45825Fa

c# - SignalR 2.1.0 : The connection has not been established

我有一个ASP.NETWeb应用程序,其中包含一个简单的HTML页面和一些通过SignalR进行通信的JavaScript。那很好用。现在,我正在尝试从另一个项目(在同一解决方案中)调用Hub上的方法并使用.NETSignalrClientApi:varconnection=newHubConnection("http://localhost:32986/");varhub=connection.CreateHubProxy("MessageHub");connection.Start();hub.Invoke("SendMessage","","");最后一行导致InvalidOpe

c# - 测试和模拟私有(private)/ protected 方法。许多帖子,但仍然无法使一个示例起作用

我看过很多关于“Mockingaprivatemethod”的帖子和问题,但仍然无法让它工作,也没有找到真正的答案。让我们忘记代码的味道,你不应该这样做等等......据我所知,我做了以下事情:1)创建了一个类库“MyMoqSamples”2)添加了对Moq和NUnit的引用3)编辑AssemblyInfo文件并添加[装配:InternalsVisibleTo(“DynamicProxyGenAssembly2”)][程序集:InternalsVisibleTo("MyMoqSamples")]4)现在需要测试一个私有(private)方法。因为它是一个私有(private)方法,所以

c# - 声明 protected 成员的静态类

我正在看书"C#Language",然后点击VladimirReshetnikov的这张便条:Ifastaticclassdeclaresaprotectedorprotectedinternalmember,acompile-timeerroroccurs(CS1057).我可以知道为什么吗?具有protected成员的静态类有什么问题?静态类可以有私有(private)成员,所以我猜这个CS1057错误不是由于可访问性引起的,但也许是由于编译问题引起的?作为protected成员可以在子类中被覆盖...但我不明白为什么。 最佳答案

c# - 如何使用反射获得重载的私有(private)/ protected 方法

usingSystem;usingSystem.Reflection;namespaceReflection{classTest{protectedvoidmethodname(inti){Console.WriteLine(("intheworldofthereflection-onlyi"));Console.Read();}protectedvoidmethodname(inti,intj){Console.WriteLine(("intheworldofthereflectioni,j"));Console.Read();}}classProgram{staticvoidMai