我正在尝试使用Visual Studio 2017中的SSH连接到Git存储库(在Bitbucket上)(据我所知,它支持用于Git的SSH).我已经设置了所有东西,将存储库克隆到我的计算机上,然后我可以提交,但是如果我尝试执行某些操作,则会使用以下消息(来自Visual Studio的"输出"窗口)失败:
Error encountered while fetching: Git failed with a fatal error.
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
从命令提示符尝试它,我得到这些稍微提供信息的消息:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)
从Git Bash我尝试打开SSH代理,添加我的私钥和获取,它似乎工作(或者至少我没有得到任何消息,不像代理未启动或未添加密钥):
eval `ssh-agent`
ssh-add ~/.ssh/xxxx
git fetch
Run Code Online (Sandbox Code Playgroud)
但是Visual Studio仍然无法连接.我也尝试从Windows命令提示符执行相同的操作:
ssh-agent
set SSH_AUTH_SOCK=/tmp/ssh-SIAryCa61iz9/agent.11128
set SSH_AGENT_PID=9804
ssh-add xxxx
git fetch
Run Code Online (Sandbox Code Playgroud)
但我仍然得到同样的错误.
我已经将公钥添加到Bitbucket,并ssh -T git@bitbucket.org输出"以xxxx登录".此外,我可以使用SourceTree正确连接并将私钥添加到Pageant(我使用的密钥ssh-add具有所需的OpenSSH格式,我是从.ppk格式创建的).
让我们说我有这个(不完整的)类,我在其中引发一个事件而没有先将它分配给一个变量以使其成为线程安全的:
public class Test
{
public event EventHandler SomeEvent;
void OnSomeEvent(EventArgs e)
{
if (SomeEvent != null)
SomeEvent(this, e);
}
}
Run Code Online (Sandbox Code Playgroud)
从自身取消订阅事件处理程序是否安全,或者是否存在类似于在枚举时从集合中删除项目时会发生什么问题?
void SomeEventHandler(object sender, EventArgs e)
{
testInstance.SomeEvent -= SomeEventHandler;
}
Run Code Online (Sandbox Code Playgroud)