0

I wanted to access over IMAP to my gmail account bsed on this example:

http://code.msdn.microsoft.com/windowsdesktop/Simple-IMAP-CLIENT-b249d2e6

When I start to debug the code, I get always an error at the codeline:

tcpc = new System.Net.Sockets.TcpClient("imap.gmail.com", 993);

It gives me the error: "The requested service provider could not be loaded or initialized"

My search on Internet give me as result, that I need to repair the Window Socket. But, when I run directkly the compiled .exe file, then I don't get this error at all. This makes no sense to me.

Does anybody have an idea, whats wrong here?

The code looks like:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;

namespace IMAP
{
class Program
{
   static System.Net.Sockets.TcpClient tcpc = null; 
   static System.Net.Security.SslStream ssl = null; 
   static string username, password; 

    static void Main(string[] args) 
    {  
        username = "(username)";
        password = "(password)";
        SSLAuthenticate = "imap.gmail.com";

        try 
        {                               
           tcpc = new System.Net.Sockets.TcpClient("imap.gmail.com", 993);
           ssl = new System.Net.Security.SslStream(tcpc.GetStream()); 
           ssl.AuthenticateAsClient("imap.gmail.com");
           ...

I am thankful for any help.

  • It may be a permission issue when the debugger creates a process for the runtime. Similar thread here http://stackoverflow.com/questions/1554878/why-does-windows-not-allow-winsock-to-be-started-while-impersonating-another-use and http://social.msdn.microsoft.com/Forums/en-US/14068c32-2e27-4d6b-b9d1-99f73185eff4/wsaeproviderfailedinit-socket-10106-error?forum=vcgeneral also check to make sure you're not clobbering your path variable in the debugger under project options – Mike Apr 03 '14 at 15:05
  • Hi Mike, thanks for your answer. No, I didn't puth an path variables into project - option - debugger. – user3493408 Apr 04 '14 at 10:48
  • here the correct version of my commentt: Hi Mike, thanks for your answer. No, I didn't put any path variables into project - option - debugger. I read the named thread which you mention. This isssue seem to me like not solveable so easy, as I am not familiar with Winsocks at all. For sure would be helpful when it would work, so I could better debug my appliaction. But I can live with it.Thanks! – user3493408 Apr 04 '14 at 11:49

0 Answers0