Ver Mensaje Individual
  #3 (permalink)  
Antiguo 18/08/2009, 17:02
Avatar de Peterpay
Peterpay
Colaborador
 
Fecha de Ingreso: septiembre-2007
Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 17 años, 5 meses
Puntos: 87
Respuesta: Como pasar de un proyecto a otro

Difiero con Hector, claro que puedes invocar a un winform desde tu aplicacion wpf.

Usando Reflection.

Código CSHARP:
Ver original
  1. Type x = Type.GetType("WpfApplication2.Form1");
  2.             System.Reflection.Assembly ensamblado= System.Reflection.Assembly.GetAssembly(x);
  3.             object r = ensamblado.CreateInstance("WpfApplication2.Form1");
  4.             System.Reflection.MethodInfo[] info = x.GetMethods();
  5.             foreach (System.Reflection.MethodInfo currentMethodInfo in info)
  6.             {
  7.                 if(currentMethodInfo.Name.Equals("Show"))
  8.                 {
  9.                     try
  10.                     {
  11.                         currentMethodInfo.Invoke(r, null);
  12.                         break;
  13.                     }
  14.                     catch (Exception ex)
  15.                     {
  16.                         //throw new ApplicationException("No es la sobrecarga que buscabamos",ex);
  17.                     }
  18.                 }
  19.             }

Atencion , si tu form no es parte de tu proyecto wpf simplemente necesitas usar el metodo

System.Reflection.Assembly.LoadFile("nombredetuwin formexecutable.exe");


y saber cual es lnombre del NameSpace.Clase que quieres instanciar.

Código csharp:
Ver original
  1. System.Reflection.Assembly ensamblado= System.Reflection.Assembly.LoadFile("c:\\Ejecutable.exe");
  2.             Type x = ensamblado.GetType("NameSpace.FormularioOClase");
  3.             object r = ensamblado.CreateInstance("NameSpace.FormularioOClase");
  4.             System.Reflection.MethodInfo[] info = x.GetMethods();
  5.             foreach (System.Reflection.MethodInfo currentMethodInfo in info)
  6.             {
  7.                 if(currentMethodInfo.Name.Equals("Show"))
  8.                 {
  9.                     try
  10.                     {
  11.                         currentMethodInfo.Invoke(r, null);
  12.                         break;
  13.                     }
  14.                     catch (Exception ex)
  15.                     {
  16.                         //throw new ApplicationException("No es la sobrecarga que buscabamos",ex);
  17.                     }
  18.                 }
  19.             }
__________________
Curso WF4
http://cursos.gurudotnet.com/ DF
Aprende HTML5

Última edición por Peterpay; 18/08/2009 a las 17:16