public Version GetSharePointVersion() { Version x = new Version(); try { Helpers.ShowProgress(dte, "Retrieving SharePoint version...", 60); x = remoteObj.GetSharePointVersion(); } catch (Exception ex) { Helpers.LogMessage(dte, dte, ex.Message); } finally { Helpers.HideProgress(dte); StopBridge(); } return(x); }
static void Main(string[] args) { //AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); if (args.Length == 0) { try { SharePointRemoteObject obj = new SharePointRemoteObject(); Console.WriteLine(obj.GetSharePointVersion()); foreach (SharePointWebApplication s in obj.GetAllWebApplications()) { Console.WriteLine(s.Name); } } catch (Exception ex) { Console.WriteLine(ex.ToString()); } Console.ReadLine(); return; } IChannel ichannel = null; string channelName = ""; try { channelName = args[0]; if (channelName == "") { throw new Exception("No channel name as parameter available"); } } catch (Exception ex) { File.AppendAllText(logFile, ex.ToString()); //throw new Exception("Ex1", ex); } try { BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider(); serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider(); System.Collections.IDictionary properties = new System.Collections.Hashtable(); properties["name"] = channelName; properties["priority"] = "20"; properties["portName"] = channelName; //"ipc://" + channelName + "/RemoteObj" // Create the channel. ichannel = new IpcChannel(properties, clientProv, serverProv); //ichannel = new IpcChannel(properties, clientProv, serverProv); ChannelServices.RegisterChannel(ichannel, false); RemotingConfiguration.RegisterWellKnownServiceType(typeof(SharePointRemoteObject), "RemoteObj", WellKnownObjectMode.Singleton); // keep the process alive TimeSpan waitTime = new TimeSpan(0, 0, 5); while (1 == 1) { // pump messages Thread.CurrentThread.Join(waitTime); Thread.Sleep(waitTime); } } catch (Exception e) { File.AppendAllText(logFile, e.ToString()); Console.WriteLine(e.ToString()); Console.WriteLine(e.InnerException); } Console.ReadLine(); }