小编Edw*_*win的帖子

调用私有方法保留调用堆栈

我正试图找到"打破非公开方法"的解决方案.

我只是想调用RuntimeMethodInfo.InternalGetCurrentMethod(...),传递我自己的参数(所以我可以实现GetCallingMethod()),或直接RuntimeMethodInfo.InternatGetCurrentMethod(ref StackCrawlMark.LookForMyCaller)在我的日志记录例程中使用.GetCurrentMethod实施方式如下:

[MethodImpl(MethodImplOptions.NoInlining)] 
public static MethodBase GetCurrentMethod() 
{     
    StackCrawlMark lookForMyCaller = StackCrawlMark.LookForMyCaller;     
    return RuntimeMethodInfo.InternalGetCurrentMethod(ref lookForMyCaller); 
}
Run Code Online (Sandbox Code Playgroud)

InternalGetCurrentMethod声明在哪里:内部:-).

我使用反射调用方法没有问题,但这会弄乱调用堆栈,这只是必须要保留的一件事,否则它会破坏它的目的.

我的堆栈跟踪保持接近原始的几率是多少(至少在允许的StackCrawlMarks 的距离内,这是LookForMe,LookForMyCallerLookForMyCallersCaller.是否有一些复杂的方法来实现我想要的?

c# reflection methods private

14
推荐指数
1
解决办法
2317
查看次数

如何使用CSOM与SharePoint-Online进行多因素身份验证

仅使用基于密码的身份验证,即可在CSOM中轻松进行身份验证:

context.Credentials = new SharePointOnlineCredentials(username, password);
Run Code Online (Sandbox Code Playgroud)

但是,当进行多因素身份验证时(http://technet.microsoft.com/zh-cn/library/dn249471.aspx),如何进行身份验证?

authentication csom sharepoint-online

5
推荐指数
1
解决办法
1539
查看次数

索引导致的 SQL 死锁

我在插入和选择之间遇到死锁问题

连接 A:

  1. 在表 MyTable 中插入一条记录(X 锁定记录)
  2. 更新非聚集索引 MyTable_Index(在索引条目上请求 X 锁)

连接 B:

  1. 使用 MyTable_Index 定位具有特定 Destination(MyTable 的列)的记录(索引条目上的 S 锁)
  2. 通过索引返回 (SELECT) MyTable 记录。(这是一个随后更新记录的子查询)(请求 S 锁定记录)

因此,当 A 插入(步骤 1)并且 B 使用索引(步骤 1)时,似乎发生了死锁。连接 A 和 B 都使用 ROWLOCK 提示。

有没有办法为连接 B 指定 MyTable_Index 不应该被锁定,就像一个表的 NOLOCK,但现在是索引?

或者其他一些聪明的技巧(除了删除索引或使用聚集索引)?

期待一些聪明的解决方案:-)

sql-server deadlock locking

5
推荐指数
0
解决办法
1622
查看次数

get-date | Write-Host($ _)在概念上有什么问题

我试图理解Powershell,但发现事情并不那么直观.我理解的是,在管道中传递对象,而不是传统的文本.并且$ _指的是管道中的当前对象.那么,为什么以下不起作用:

get-date|Write-Host "$_"
Run Code Online (Sandbox Code Playgroud)

错误消息是:

Write-Host:输入对象不能绑定到命令的任何参数,因为该命令不接受管道输入或输入及其属性不会影响任何接受管道输入的参数.在行:1 char:10 + get-date | Write-Host $ _ + ~~~~~~~~~~~~~ + CategoryInfo:InvalidArgument:(10-9-2014 15:17:00:PSObject) [Write-Host],ParameterBindingException + FullyQualifiedErrorId:InputObjectNotBound,Microsoft.PowerShell.Commands.WriteHostCommand

powershell

2
推荐指数
1
解决办法
1536
查看次数