/** ** ** MinCor-C# -Demo ** CORBA Solution for .Net with C# Language mapping ** Version: 1.0 ** ** Copyright: ** Middsol GmbH, Hamburg ** Germany 2004 ** www.Middsol.com ** info@Middsol.de ** */ using System; using System.Drawing; using System.Collections; using System.Windows.Forms; using System.Data; namespace DotNetClient { public class ClientImpl { private static string[] m_strORBInit = {"-ORBInitRef NameService=corbaloc:iiop:1.2@localhost:10050/NameService", "-AddAssembly DotNetClient.exe, JavaBuiltinTypesCF.dll, MinCorCF.dll" }; public static void runDemo( FrmClt a_oFrmClt, string a_strIpAddr) { Exceptions.Greetings oGreetings; Middsol.CORBA.ORB oOrb = null; m_strORBInit[1] = m_strORBInit[1].Replace("localhost", a_strIpAddr); try { oOrb = Middsol.CORBA._ORB.init( m_strORBInit, null); Middsol.CosNaming.NamingContextExt oNsCtx = Middsol.CosNaming.NamingContextExtHelper.narrow( oOrb.resolve_initial_references("NameService")); try { oGreetings = Exceptions.GreetingsHelper.narrow( oNsCtx.resolve_str("ExceptionsJavaServer")); } catch(Middsol.CosNaming.NamingContextPackage.NotFound ex) { a_oFrmClt.writeLog( "NS Manager Error:" + ex.why); throw new System.Exception(); } try { a_oFrmClt.writeLog( "Call Greetings.hello( Middsol)"); string strRet = oGreetings.hello( "Middsol"); } catch( Exceptions.MyUserEx ex) { Exceptions.MyUserException oMyUserException = (Exceptions.MyUserException)ex._value; a_oFrmClt.writeLog( "Exception catched: "); a_oFrmClt.writeLog( " Exceptions.MyUserExceptionID "); a_oFrmClt.writeLog( " Id:"+ oMyUserException.iId); a_oFrmClt.writeLog( ""); a_oFrmClt.writeLog( "Stacktrace:"); a_oFrmClt.writeLog( oMyUserException.ToString()); } } catch( Middsol.CORBA.SystemException exSys) { a_oFrmClt.writeLog( "Catch Exception from Server"); a_oFrmClt.writeLog( " Middsol.CORBA.SystemException."); a_oFrmClt.writeLog( " ID:" + exSys.ID); } finally { if( oOrb != null) oOrb.destroy(); } } } }