Foros del Web » Programando para Internet » ASPX (.net) »

Utilizar Apliacion c# en vb

Estas en el tema de Utilizar Apliacion c# en vb en el foro de ASPX (.net) en Foros del Web. Hola, estoy con un proyecto en vb.net utilizando VS2003 porque no puedo utilizar otro en el proyecto, y tengo un "windowsapplication" realizado en c# para ...
  #1 (permalink)  
Antiguo 27/07/2010, 10:50
 
Fecha de Ingreso: junio-2010
Mensajes: 44
Antigüedad: 13 años, 10 meses
Puntos: 0
Utilizar Apliacion c# en vb

Hola, estoy con un proyecto en vb.net utilizando VS2003 porque no puedo utilizar otro en el proyecto, y tengo un "windowsapplication" realizado en c# para validar que los emails sean correctos. Como podria hacer referencia desde VS2003 a este programilla que valida mails.
GRACIAS Y SALUDOS!
  #2 (permalink)  
Antiguo 27/07/2010, 11:40
Avatar de Myakire
Colaborador
 
Fecha de Ingreso: enero-2002
Ubicación: Centro de la república
Mensajes: 8.849
Antigüedad: 22 años, 3 meses
Puntos: 146
Respuesta: Utilizar Apliacion c# en vb

movido desde asp clásico
  #3 (permalink)  
Antiguo 28/07/2010, 01:14
 
Fecha de Ingreso: junio-2010
Mensajes: 44
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Utilizar Apliacion c# en vb

Sorry, no me di cuenta, hasta ahora estaba con ASP y ahora con ASPX, prefiero el primero
  #4 (permalink)  
Antiguo 28/07/2010, 02:28
 
Fecha de Ingreso: junio-2010
Mensajes: 44
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Utilizar Apliacion c# en vb

He estado trasteando algo mas con esto pero no doy con ello, tengo mi archivo de la dll, que tiene esto:
Código ASP:
Ver original
  1. class ValidadorEMail
  2.     {
  3.         // valores devueltos
  4.         // 0 = OK
  5.         // 1 = Email mal escrito
  6.         // 2 = Email inválido
  7.         // 3 = error con dominio valido
  8.         // 4 = dominio invalido
  9.         // 5 = Sin conexion a internet
  10.  
  11.         public int SevidorEMail(string sEmail, bool SoloSintaxis)
  12.         {
  13.         NetworkStream oStream;
  14.         string sFrom;
  15.         string sTo;
  16.         string sResponse;
  17.         string Remote_Addr;
  18.         string mserver;
  19.         string[] sText;
  20.         int returnvalue = 0;
  21.  
  22.         if (!ValidEmail(sEmail)) return 1;
  23.  
  24.         if (!SoloSintaxis)
  25.             {
  26.  
  27.             if (!IsConnected()) return 5;
  28.  
  29.             sTo = "<" + sEmail + ">";
  30.             sText = sEmail.Split('@');
  31.             mserver = NSLookup(sText[1]);
  32.  
  33.             if (mserver == "")
  34.             {
  35.                 returnvalue = 4;
  36.                 return returnvalue;
  37.             }
  38.             Remote_Addr = "datacronos.com";
  39.             sFrom = "datacronos@" + Remote_Addr + ">";
  40.             TcpClient oConnection = new TcpClient();
  41.  
  42.             try
  43.             {
  44.                 oConnection.SendTimeout = 3000;
  45.                 oConnection.Connect(mserver, 25);
  46.                 oStream = oConnection.GetStream();
  47.                 sResponse = GetData(oStream);
  48.                 sResponse = TalkToServer(oStream, "HELO " + Remote_Addr + "\n");
  49.                 sResponse = TalkToServer(oStream, "MAIL FROM: " + sFrom + "\n");
  50.                 if (ValidResponse(sResponse))
  51.                 {
  52.                     sResponse = TalkToServer(oStream, "RCPT TO: " + sTo + "\n");
  53.                     if (ValidResponse(sResponse))
  54.                     {
  55.                         returnvalue = 0;
  56.                     }
  57.                     else
  58.                     {
  59.                         returnvalue = 2;
  60.                     }
  61.                 }
  62.                 TalkToServer(oStream, "QUIT" + "\n");
  63.                 oConnection.Close();
  64.                 oStream = null;
  65.             }
  66.             catch
  67.             {
  68.                 returnvalue = 3;
  69.             }
  70.         }
  71.  
  72.         return returnvalue;
  73.     }
  74.         private bool ValidEmail(string email)
  75.         {
  76.             String expresion;
  77.             expresion = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";
  78.             if (Regex.IsMatch(email, expresion))
  79.             {
  80.                 if (Regex.Replace(email, expresion, String.Empty).Length == 0)
  81.                 { return true; }
  82.                 else { return false; }
  83.             }
  84.             else { return false; }
  85.         }
  86.         private string GetData(NetworkStream oStream)
  87.         {
  88.         byte[] bResponse = new byte[1024];
  89.         string sResponse = "";
  90.         int lenStream = 0;
  91.  
  92.         lenStream = oStream.Read(bResponse, 0, 1024);
  93.  
  94.         if (lenStream > 0)
  95.         {
  96.         sResponse = Encoding.ASCII.GetString(bResponse, 0, 1024);
  97.         }
  98.         return sResponse;
  99.  
  100.         }
  101.         private string SendData(NetworkStream oStream, string sToSend)
  102.         {
  103.         string sResponse;
  104.         byte[] bArray = Encoding.ASCII.GetBytes(sToSend.ToCharArray());
  105.  
  106.         oStream.Write(bArray, 0, bArray.Length);
  107.         sResponse = GetData(oStream);
  108.  
  109.         return sResponse;
  110.         }
  111.         private bool ValidResponse(string sResult)
  112.         {
  113.         bool bResult = false;
  114.         int iFirst;
  115.  
  116.         if (sResult.Length > 1)
  117.         {
  118.             iFirst = Convert.ToInt32(sResult.Substring(0, 1));
  119.             if (iFirst < 3) { bResult = true;}
  120.         }
  121.  
  122.         return bResult;
  123.         }
  124.         private string TalkToServer(NetworkStream oStream, string sToSend)
  125.         {
  126.         string sresponse;
  127.  
  128.         sresponse = SendData(oStream, sToSend);
  129.  
  130.         return sresponse;
  131.         }
  132.         private string NSLookup(string sDomain)
  133.         {
  134.         ProcessStartInfo info = new ProcessStartInfo();
  135.         info.UseShellExecute = false;
  136.         info.RedirectStandardInput = true;
  137.         info.RedirectStandardOutput = true;
  138.         info.FileName = "nslookup";
  139.         info.Arguments = "-type=MX " + sDomain.ToUpper().Trim();
  140.         info.WindowStyle = ProcessWindowStyle.Hidden;
  141.  
  142.         Process ns;
  143.         ns = Process.Start(info);
  144.  
  145.         StreamReader sout;
  146.         sout = ns.StandardOutput;
  147.         Regex reg = new Regex("mail exchanger = (?<server>[^\\\\\\s]+)");
  148.         string mailserver = "";
  149.         string response = "";
  150.         do
  151.         {
  152.             response = sout.ReadLine();
  153.             Match amatch = reg.Match(response);
  154.             Debug.WriteLine(response);
  155.             if (amatch.Success) { mailserver = amatch.Groups["server"].Value; }
  156.         } while (sout.Peek() > -1);
  157.  
  158.         return mailserver;
  159.  
  160.         }
  161.  
  162.         private static bool IsConnected()
  163.         {
  164.             int connectionDescription = 0;
  165.             return InternetGetConnectedState(out connectionDescription, 0);
  166.         }
  167.         [DllImport("wininet.dll")]
  168.         private extern static bool InternetGetConnectedState(out int connectionDescription, int reservedValue);
  169.  
  170.     }

Y yo lo estoy intentanto utilizar asi, pero me peta:

Código ASP:
Ver original
  1. Imports validaMail
  2. Imports System.Runtime.InteropServices
  3. Public Class pruebasMias
  4.  
  5. ....................................................
  6.  
  7. <DllImport("validaMail.dll",true)>

Y no sé que parametros y como debo invocar a la dll, a ver si alguien me puede echar una mano.
GRACIAS!!!
  #5 (permalink)  
Antiguo 28/07/2010, 08:34
 
Fecha de Ingreso: junio-2010
Mensajes: 44
Antigüedad: 13 años, 10 meses
Puntos: 0
Respuesta: Utilizar Apliacion c# en vb

-------------solucionado---------------

Etiquetas: vb, aspx, utilidades
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:40.