public List <SharePointWebApplication> GetAllWebApplications() { List <SharePointWebApplication> res = new List <SharePointWebApplication>(); try { Helpers.ShowProgress(dte, "Retrieving webapplication list...", 60); res = remoteObj.GetAllWebApplications(); LogMessage("SharePointBrigdeHelper: GetAllWebApplications retrieved " + res.Count.ToString() + " items"); } catch (Exception ex) { LogMessage("SharePointBrigdeHelper: " + ex.ToString()); Helpers.LogMessage(dte, dte, ex.Message); Helpers.LogMessage(dte, dte, "Ensure that WWW Service and SharePoint database are running on your machine"); } finally { Helpers.HideProgress(dte); StopBridge(); } return(res); }
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(); }