I have an issue where I keep getting an error
No provider registered for 'svn.ssl.server' credentials
I am using the same code that works on another SVN server, but a new server I setup can't seem to connect even though I can connect no problem through a web browser.
//SVN Client repo sync
public void DownloadSVNStartup(string url, string path)
{
using (SvnClient client = new SvnClient())
{
try
{
client.CleanUp(path); //will go to catch block since there's no working copy yet I
//want to checkout for the first time then next time this part
//will work.
SvnUI.Bind(client, this);
SvnCheckOutArgs sco = new SvnCheckOutArgs();
sco.AllowObstructions = false;
}
catch (Exception ex)
{
MessageBox.Show("Line 88");
MessageBox.Show(ex.ToString());
myLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
client.Configuration.SetOption("servers", "global", "http-auth-types", "basic;digest");
client.Authentication.Clear();
client.Authentication.ForceCredentials("user", "password");
try
{
client.Authentication.SslServerTrustHandlers += delegate (object sender,
SvnSslServerTrustEventArgs e)
{
e.AcceptedFailures = e.Failures;
e.Save = false; // Save acceptance to authentication store
};
Object[] args = { url, path };
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += backgroundWorker1_DoWork;
worker.RunWorkerAsync(args);
this.Hide();
}
catch (Exception ex)
{
MessageBox.Show("Line126");
MessageBox.Show(ex.ToString());
myLog.WriteEntry(ex.ToString(), EventLogEntryType.Error);
}
}
}
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) //connect to the Svn
//server
{
try
{
Object[] arg = e.Argument as Object[];
string url = (string)arg[0];
string path = (string)arg[1];
using (SvnClient client = new SvnClient())
{
client.Authentication.Clear(); // Prevents saving/loading config to/from disk
client.Authentication.ForceCredentials("user", "password");
client.CheckOut(new Uri(url), path); //fails here with the error No provider registered for 'svn.ssl.server' credentials
client.CleanUp(path);
client.Update(path);
client.CleanUp(path);
}
}
catch (Exception ex)
{
MessageBox.Show("Line166", ex.Message.ToString());
MessageBox.Show(ex.ToString());
}
}
I have searched for hours for solutions and can't find anything.
Both servers are setup with same port, same HTTPS settings and created certificates, same VisualSVN server editions.
I have tried only the one solution that I could find as this is not a common issue at all.
This is supposed to fix that error but it doesn't.
client.Authentication.SslServerTrustHandlers += delegate (object sender, SvnSslServerTrustEventArgs e)
{
e.AcceptedFailures = e.Failures;
e.Save = false; // Save acceptance to authentication store
};
I fixed it with adding an event handler for the certificate
private void SslClientCertificateHandlers(object sender, SvnSslClientCertificateEventArgs e)
{
e.Save = true;
e.CertificateFile = #"where you want to save certs";
}
Related
I'm trying to make a windows form application that can be "hidden" in the taskbar (like WiFi and so on), equipped with a timer, and that every 10 seconds it scans my email inbox in Outlook.
The first part works fine, but I can't get the scan to work. At first i just want to extract the names of email subjects and put them into a text file, just to test the code. But in the end i'd like to scan one particular inbox (i have several on my outlook, like 5 or 6, with different mail address associeted, and i can't find anything on the internet to target one of them) and make a popup or something when particular email are received.
Anyway, this is the code i have so far:
public static bool isRunning = false;
public Form1()
{
InitializeComponent();
System.Timers.Timer timer = new System.Timers.Timer(10000);
timer.Elapsed += OnTimedEvent;
timer.Enabled = true;
}
private void Hide_Click(object sender, EventArgs e)
{
this.Hide();
notifyIcon1.Visible = true;
}
private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
{
this.Show();
notifyIcon1.Visible = false;
}
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Outlook.Application app = null;
Outlook.MAPIFolder inbox = null;
Outlook._NameSpace ns = null;
if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
{
try
{
app = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
ns = app.GetNamespace("MAPI");
List<Outlook.MailItem> ReceivedEmail = new List<Outlook.MailItem>();
List<string> titles = new List<string>();
foreach (Outlook.MailItem mail in inbox.Items)
{
ReceivedEmail.Add(mail);
}
foreach (Outlook.MailItem mail in ReceivedEmail)
{
titles.Add(mail.Subject.ToString());
}
File.WriteAllLines("C://Users/A222946/Desktop/allMails.txt", titles);
}
catch (System.Runtime.InteropServices.COMException ex)
{
MessageBox.Show(ex.Message);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show("Please, start outlook..");
}
}
}
The error i find when i'm running this is the following:
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)
I tried with and without administrator rights, same error.
Update
So after some changes it looks like this now:
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
Outlook.Application app = new Outlook.Application();
Outlook.MAPIFolder inbox = null;
Outlook._NameSpace ns = null;
Outlook.Items items = null;
if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
{
try
{
app = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
ns = app.GetNamespace("MAPI");
inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
items = inbox.Items;
List<Outlook.MailItem> ReceivedEmail = new List<Outlook.MailItem>();
List<string> titles = new List<string>();
foreach (Object obj in items)
{
if (obj is Outlook.MailItem)
{
ReceivedEmail.Add((Outlook.MailItem)obj);
}
}
foreach (Outlook.MailItem mail in ReceivedEmail)
{
titles.Add(mail.Subject.ToString());
}
File.WriteAllLines("C://Users/A222946/Desktop/allMails.txt", titles);
}
catch (COMException ex)
{
MessageBox.Show(ex.Message);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else
{
MessageBox.Show("Please, start outlook..");
}
}
But i still have this error:
object reference not set to an instance of an object
Also, do you have any idea how i could target one particular mailbox? Example: "abcdefg#blabla.com"
I think the COM components are not accessible. COM components are used by some of the Windows components(like MS Office).You need to make use of STAThreadAttribute.
[STAThread]
static void Main(string[] args)
{
// etc..
}
I think this should fix the issue.
Firstly, this really needs to be an Outlook COM addin (which runs when Outlook runs), not a separate exe that detects when Outlook is running.
That being said, you are using Namespace.GetDefaultFolder. What you need to be using is Store.GetDefaultFolder (where Store is retrieved from the Namespace.Stores collection) if the store is already opened in the profile. Or Namespace.CreateRecipient / Namespace.GetSharedDefaultFolder if the store is not already opened in the profile.
I am building an application , in which I need to have a c# server and nodejs client. I have built the components , but I am always getting ECONNREFUSED error. any leads when I can except this error?
FYI,
I am able to connect to c# server from c# client. similarly. I am able to connect to nodejs tcp server from nodejs tcp client. however the I am facing error with this mixture.
hey sorry for not adding code earlier.
the following is the c# server code:
using System;
using System.Text;
using AsyncClientServerLib.Server;
using System.Net;
using AsyncClientServerLib.Message;
using SocketServerLib.SocketHandler;
using SocketServerLib.Server;
namespace TestApp
{
delegate void SetTextCallback(string text);
public partial class FormServer : Form
{
private BasicSocketServer server = null;
private Guid serverGuid = Guid.Empty;
public FormServer()
{
InitializeComponent();
}
protected override void OnClosed(EventArgs e)
{
if (this.server != null)
{
this.server.Dispose();
}
base.OnClosed(e);
}
private void buttonStart_Click(object sender, EventArgs e)
{
this.serverGuid = Guid.NewGuid();
this.server = new BasicSocketServer();
this.server.ReceiveMessageEvent += new SocketServerLib.SocketHandler.ReceiveMessageDelegate(server_ReceiveMessageEvent);
this.server.ConnectionEvent += new SocketConnectionDelegate(server_ConnectionEvent);
this.server.CloseConnectionEvent += new SocketConnectionDelegate(server_CloseConnectionEvent);
this.server.Init(new IPEndPoint(IPAddress.Loopback, 2147));
this.server.StartUp();
this.buttonStart.Enabled = false;
this.buttonStop.Enabled = true;
this.buttonSend.Enabled = true;
MessageBox.Show("Server Started");
}
void server_CloseConnectionEvent(AbstractTcpSocketClientHandler handler)
{
MessageBox.Show(string.Format("A client is disconnected from the server"), "Socket Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
void server_ConnectionEvent(AbstractTcpSocketClientHandler handler)
{
MessageBox.Show(string.Format("A client is connected to the server"), "Socket Server", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
void server_ReceiveMessageEvent(SocketServerLib.SocketHandler.AbstractTcpSocketClientHandler handler, SocketServerLib.Message.AbstractMessage message)
{
BasicMessage receivedMessage = (BasicMessage)message;
byte[] buffer = receivedMessage.GetBuffer();
if (buffer.Length > 1000)
{
MessageBox.Show(string.Format("Received a long message of {0} bytes", receivedMessage.MessageLength), "Socket Server",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
string s = System.Text.ASCIIEncoding.Unicode.GetString(buffer);
this.SetReceivedText(s);
}
private void buttonStop_Click(object sender, EventArgs e)
{
this.server.Shutdown();
this.server.Dispose();
this.server = null;
this.buttonStart.Enabled = true;
this.buttonStop.Enabled = false;
this.buttonStop.Enabled = false;
MessageBox.Show("Server Stopped");
}
private void SetReceivedText(string text)
{
if (this.textBoxReceived.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetReceivedText);
this.Invoke(d, new object[] { text });
}
else
{
this.textBoxReceived.Text = text;
}
}
private void buttonSend_Click(object sender, EventArgs e)
{
ClientInfo[] clientList = this.server.GetClientList();
if (clientList.Length == 0)
{
MessageBox.Show("The client is not connected", "Socket Server", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
AbstractTcpSocketClientHandler clientHandler = clientList[0].TcpSocketClientHandler;
string s = this.textBoxSend.Text;
byte[] buffer = System.Text.ASCIIEncoding.Unicode.GetBytes(s);
BasicMessage message = new BasicMessage(this.serverGuid, buffer);
clientHandler.SendAsync(message);
}
}
}
The following is the nodejs client code.
var sys = require("sys"),
net = require("net");
var client = net.createConnection(2147);
client.setEncoding("UTF8");
client.addListener("connect", function() {
sys.puts("Client connected.");
// close connection after 2sec
setTimeout(function() {
sys.puts("Sent to server: close");
client.write("close", "UTF8");
}, 2000);
});
client.addListener("data", function(data) {
sys.puts("Response from server: " + data);
if (data == "close") client.end();
});
client.addListener("close", function(data) {
sys.puts("Disconnected from server");
});
I am able to solve the issue. This is just a overlook issue. In server code , I am using lan address assigned to my machine , but in client side , I am using 127.0.0.1 . when I changed the both to same value , I amnot getting econnrefused error.
Now I am able to send and receive data. However I am getting ECONNRESET error very frequently. any leads?
I have application that host WCF service.
I am opening the connection via BackgroundWorker
private bool isConnected;
private BackgroundWorker asyncWorker = new BackgroundWorker();
InitializeComponent();
asyncWorker.WorkerReportsProgress = true;
asyncWorker.WorkerSupportsCancellation = true;
asyncWorker.ProgressChanged += new ProgressChangedEventHandler
(bwAsync_ProgressChanged);
asyncWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler
(bwAsync_RunWorkerCompleted);
asyncWorker.DoWork += new DoWorkEventHandler(bwAsync_DoWork);
btnConnect.BackColor = Color.ForestGreen;
This is my Connect button click event:
private void btnConnect_Click(object sender, EventArgs e)
{
btnConnect.Enabled = false;
Interface.interfaceNumber = interfaceNumber;
asyncWorker.RunWorkerAsync();
}
And DoWork:
private void bwAsync_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bwAsync = sender as BackgroundWorker;
try
{
if (!isConnected)
{
// Returns a list of ipaddress configuration
IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName());
// Get machine ipaddress
IPAddress _ipAddress = IPAddress.Parse(tbServerIp.Text);
// Create the url that is needed to specify where the service should be started
urlService = "net.tcp://" + _ipAddress.ToString() + ":8000/MyService";
// Instruct the ServiceHost that the type that is used is a ServiceLibrary.service1
//host = new ServiceHost(typeof(ServiceLibrary.service1));
ServiceLibrary.service1 serviceInstance = new ServiceLibrary.service1();
serviceInstance.CapturingEvent += yourServiceInstance_StartCapturingEvent;
serviceInstance.OnProcessExitedEvent += serviceInstance_OnProcessExitedEvent;
host = new ServiceHost(serviceInstance);
host.Opening += new EventHandler(host_Opening);
host.Opened += new EventHandler(host_Opened);
host.Closing += new EventHandler(host_Closing);
host.Closed += new EventHandler(host_Closed);
// The binding is where we can choose what transport layer we want to use. HTTP, TCP ect.
NetTcpBinding tcpBinding = new NetTcpBinding();
tcpBinding.TransactionFlow = false;
tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
tcpBinding.Security.Mode = SecurityMode.None; // <- Very crucial
// Add a endpoint
host.AddServiceEndpoint(typeof(ServiceLibrary.IService1), tcpBinding, urlService);
// A channel to describe the service. Used with the proxy scvutil.exe tool
ServiceMetadataBehavior metadataBehavior;
metadataBehavior = host.Description.Behaviors.Find<ServiceMetadataBehavior>();
if (metadataBehavior == null)
{
// Create the proxy object that is generated via the svcutil.exe tool
metadataBehavior = new ServiceMetadataBehavior();
metadataBehavior.HttpGetUrl = new Uri("http://" + _ipAddress.ToString() + ":8001/MyService");
metadataBehavior.HttpGetEnabled = true;
metadataBehavior.ToString();
host.Description.Behaviors.Add(metadataBehavior);
urlMeta = metadataBehavior.HttpGetUrl.ToString();
}
host.Open();
isConnected = true;
}
else
{
if (asyncWorker.IsBusy)
{
//bnAsync.Enabled = false;
this.Invoke((MethodInvoker)delegate { lblStatus.Text = "Cancelling..."; });
// Notify the worker thread that a cancel has been requested.
// The cancel will not actually happen until the thread in the
// DoWork checks the bwAsync.CancellationPending flag, for this
// reason we set the label to "Cancelling...", because we haven't
// actually cancelled yet.
asyncWorker.CancelAsync();
}
host.Close();
isConnected = false;
}
}
catch (Exception ex)
{
isConnected = false;
MessageBox.Show(ex.Message);
return;
}
}
private void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
// Lock\Release buttons
}
My application connect successfully and all works fine but in case i am specified wrong IP Address i get TCP error that requested Ip Address is not valid which is OK but in case i fix this wrong IP Address to the correct Ip Address i still get the same error unless my application is restarted.
Maybe my thread is still running and this is why i cannot connect ?
First off don't use IP addresses unless your just doing localhost dev, it's always a bad idea, use DNS names or hosts file name entries. Secondly, I assume that your host variable is a class member variable (code you didn't include above). After you open the host, it's bindings are going to remain active in server memory until you restart the application which is standard practice.
The other issue with that code is that in the else block of bwAsync_DoWork you close the host after the form button is clicked but you are not re-binding/re-opening the host with the updated form data. Consider doing the following to fix this.
Move the code that does the actual host binding out of bwAsync_DoWork into its own method.
Call this method at the very end of bwAsync_DoWork to ensure the new binding is turned on.
code:
private void bwAsync_DoWork(object sender, DoWorkEventArgs e)
{
BackgroundWorker bwAsync = sender as BackgroundWorker;
if (asyncWorker.IsBusy)
{
this.Invoke((MethodInvoker)delegate { lblStatus.Text = "Cancelling..."; });
asyncWorker.CancelAsync();
}
else
{
if(isConnected)
{
host.Close();
isConnected = false;
}
BindHost();
}
}
private void BindHost()
{
...
isConnected = true;
}
I got a problem in my WP-7 app.
I have an event when I read from the cloud - OpenReadCompletedEventHandler,
but somehow when the event occurs the EventHandler cannot be executed.
Here is my functions:
public void SetCategories()
//set the Companies table from Shret.net DataBase
{
try
{
WebClient webClient = new WebClient();
Uri uri = new Uri("http://api.sherut.net/?method=Category");
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
try
{
webClient.OpenReadAsync(uri);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
DataContractJsonSerializer serializer = null;
try
{
serializer = new DataContractJsonSerializer(typeof(Categories));
var categories = (Categories)serializer.ReadObject(e.Result);
// foreach (Company c in companies.data)
// MessageBox.Show(c.Name + " " + c.CompanyID+" "+c.CompanyGUID);
//לכתוב לבסיס נתונים באפליקציה
BuildCategoriesDB(); //build the local data base
AddCategoriesData(categories);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
It reads from the cloud, but it doesn't go inside the handler: webClient_OpenReadCompleted
Check to make sure the event is being created and "thrown".
I'm trying to read from a Uri which i created and to display it on windows phone 7 app.
(I'm doing this tutorial:http://msdn.microsoft.com/en-us/windowsmobile/Video/hh237494).
My problem is that the program doesnt get into the OpenReadCompletedEventHandler and i dont know why. (i putted message box in order to debug and i found out that the program doesnt get into the OpenReadCompletedEventHandler). Here is the relevant code:
void myButton_Click(object sender, RoutedEventArgs e)
{
try
{
WebClient webClient = new WebClient();
Uri uri = new Uri("http://localhost:44705/Service1.svc/GetAllBrands");
webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
try
{
webClient.OpenWriteAsync(uri);
MessageBox.Show("opening sucsseded");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
MessageBox.Show("OpenRead Handler");
// OpenWriteCompletedEventArgs temp = (OpenWriteCompletedEventArgs)e;
DataContractJsonSerializer serializer = null;
try
{
serializer = new DataContractJsonSerializer(typeof(ObservableCollection<Brand>));
ObservableCollection<Brand> Brands = serializer.ReadObject(e.Result) as ObservableCollection<Brand>;
foreach (Brand b in Brands)
{
int id = b.BrandId;
string name = b.BrandName;
listBrands.Items.Add(id + " " + name);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Thanks in advance!
I have never used this but a quick google takes me to this page on MSDN - http://msdn.microsoft.com/en-us/library/system.net.webclient.openreadcompleted.aspx
This should tell you why it's not working - because you are using a read event for a write operation. You should be using OpenWriteCompletedEventHandler with OpenWriteAsync as per this page on MSDN - http://msdn.microsoft.com/en-us/library/system.net.webclient.openwritecompleted.aspx