草庐IT

access-protection

全部标签

c# - Azure key 保管库 : access denied

我有以下用于从Azurekey保管库获取secret的代码:publicstaticasyncTaskGetToken(stringauthority,stringresource,stringscope){varauthContext=newAuthenticationContext(authority);ClientCredentialclientCred=newClientCredential(...);//appid,appsecretAuthenticationResultresult=awaitauthContext.AcquireTokenAsync(resource,c

c# - 内部 protected 属性(property)仍然可以从不同的程序集访问

我正在为有关辅助功能的初学者session设置一些演示代码,我发现我能够从派生类访问内部protected属性。我错过了什么?程序集1namespaceAccessibility{classProgram{staticvoidMain(string[]args){ExampleClassc=newExampleClass();c.Go();//c.Prop1=10;}}classExampleClass:DerivedClass{publicvoidGo(){this.Prop1=10;this.Prop2=10;//this.Prop3=10;//Doesn'twork//this.

c# - protected 关键字 C#

我想知道C#中的protected是什么意思,为什么要用它,关键字有什么好处?例如protectedintcurrentColorIndex;请详细说明。 最佳答案 每个人的答案都是相似的(定义和/或摘录/MSDN链接),所以我将尝试回答您原来的3个问题:含义:任何标有“protected”的字段意味着它只对其自身和任何子级(从它继承的类)可见。您会注意到在ASP.NETWeb窗体代码隐藏模型中,事件处理程序(例如Page_Load)被标记为“protected”。这是因为ASPX标记文件实际上继承代码隐藏文件(查看@Page指令可

c# - 为什么我在 WPF 用户控件上看到 "member is not recognized or is not accessible"错误?

我有一个带有公共(public)属性的自定义用户控件,我希望能够在XAML中进行设置。在下面。TestControl.xamlTestControl.xaml.csusingSystem.Windows.Controls;namespaceMyProject.Controls{publicpartialclassTestControl:UserControl{publicstringTestMe{get;set;}publicTestControl(){InitializeComponent();}}}然后,在我的MainWindow.xaml文件中,我尝试包含以下内容:但是,即使Vi

c# - 如何以编程方式在 C# 中创建 Microsoft Access 数据库?

如果MicrosoftAccess数据库文件不存在,如何在C#中创建它? 最佳答案 最简单的答案是在您的程序中嵌入一个空的.mdb/.accdb文件并将其写入磁盘。正确答案是将COMInterop与ADOX库一起使用:varcat=newADOX.Catalog()cat.Create(connectionString);请记住使用OleDbConnectionStringBuilder生成连接字符串。 关于c#-如何以编程方式在C#中创建MicrosoftAccess数据库?,我们在S

c# - WPF 调度程序 {"The calling thread cannot access this object because a different thread owns it."}

首先我需要说我是WPF和C#的菜鸟。应用程序:创建Mandelbrot图像(GUI)在这种情况下,我的调度员工作得很好:privatevoidprogressBarRefresh(){while((con.Progress)尝试使用以下代码执行此操作时,我收到了消息(标题):bmp=BitmapSource.Create(width,height,96,96,pf,null,rawImage,stride);this.Dispatcher.Invoke(DispatcherPriority.Send,newAction(delegate{img.Source=bmp;ViewBox.C

c# - LINQ to Entities Group By 表达式给出 'Anonymous type projection initializer should be simple name or member access expression'

我在这个表达式中遇到了上述错误:varaggregate=fromtinentities.TraceLinesjoinminentities.MethodNames.Where("it.NameLIKE@searchTerm",newObjectParameter("searchTerm",searchTerm))ont.MethodHashequalsm.MethodHashwhere(t.CallTypeId&(int)types)==t.CallTypeId&&t.UserSessionProcessId==m_SessionIdgrouptbym.Nameintodselect

c# - T4代码生成: access types in current project

使用T4代码生成,是否可以访问当前项目中定义的类型?例如,如果我有一个接口(interface)并且我想将它的实现委托(delegate)给另一个类,即interfaceIDoSomething{publicvoiddo_something();}classDoSomethingImpl:IDoSomething{publicvoiddo_something(){//implementation...}}classSomeClass:IDoSomething{IDoSomethingm_doSomething=newDoSomethingImpl();//forwardcallstoi

c# - ASP.net 核心网络 API : Using Facebook/Google OAuth access token for authentication

这几天我一直在尝试使用Google和Facebook进行OAuth身份验证,以便在我的ASP.net核心WebAPI项目中工作。我目前的状态是:我有一个ASP.net核心WebApi项目,其中的用户需要进行身份验证我有一个Angular2网络应用程序,它应该使用我的网络API(需要身份验证)我有一个android应用程序,它应该使用我的webapi(需要身份验证)我的目标是:使用Google/Facebook作为OAuth提供商进行登录稍后:添加自己的用户帐户(可能使用IdentityServer4)无需重定向到特殊的登录网站(如IdentityServer4解决方案)。只需点击应用程

c# - 为什么 C# 不支持 Protected 和 Internal 可访问性的交集?

protected内部:protected和internal可访问性的联合(这比protected或internal的限制更少单独)TheCLRhastheconceptofintersectionofprotectedandinternalaccessibility,butC#doesnotsupportthis.所以我的问题是:省略这个访问修饰符是什么意思,有具体原因吗?那么为什么C#不应该支持它呢? 最佳答案 更新:C#7.2使用访问修饰符privateprotected引入了这一点,这在某些方面似乎是错误的,但确实避免了我在