Proxy Switcher arbeitet derzeit mit dem Internet Explorer und Firefox zusammen. In der Regel greifen Anwendungen automatisch auf die Proxy Einstellungen des Internet Explorers zurück, weshalb es normalerweise vollkommen ausreichend ist.
Hat man nun aber einen Sonderfall, also eine Applikation die nicht auf die Internet Explorer settings zurückgreifen kann, benötigt man ein zusätzlichen “Switcher”.
In diesem Artikel zeige ich, wie einfach es ist, selbst einen zu entwickeln und im Proxy Switcher zu verwenden.
Implementierung
Zunächst erstellt man ein neues Class Library Projekt im Visual Studio 2008. Dies ist auch mit der kostenlosen Variante Visual Studio 2008 Express (C# oder VB.NET) ohne Probleme möglich.
Als nächstes fügt man eine Referenz auf ProxySwitcher.Shared.dll hinzu. Dort befindet sich die benötigte Basisklasse.
Nun noch die Class1.cs Datei umbenennen, z.B. in DemoSwitcher.cs. Dadurch wird auch automatisch die Klasse umbenannt. Diese Klasse muss nun von der SwitcherBase Klasse erben, wofür außerdem das using statement hinzugefügt werden muss:
Über das SmartTag was erscheint wenn man SwitcherBase ausgeschrieben hat, lassen sich automatisch alle benötigten Methoden erzeugen. Das wären “DisableProxy”, “EnableProxy” und die Eigenschaft “Name”.
Über die Name Eigenschaft kann man einen Namen vergeben, der später dann im Proxy Switcher angezeigt wird.
Enable und Disable sollte sich von selbst erklären. Innerhalb der Methoden kann man auf this.CurrentProxyEntry zugreifen um die Daten abzurufen, die nun aktiviert/deaktiviert werden sollen.
Damit hätten wir die minimal Implementierung beendet.
Erweiterte Funktionen
Man kann nun noch für seinen Switcher Einstellungen laden und speichern und auch einen Settings Dialog als Windows Form anbieten (wofür dann noch eine Referenz auf “System.Windows.Forms” hinzugefügt werden muss):
Deployment
Nachdem man alles soweit fertig hat, muss das Projekt noch kompiliert werden. Dadurch entsteht eine DLL, in meinem Fall PSDemoSwitcher.dll.
Diese muss nur noch in das Verzeichnis kopiert werden, wo auch ProxySwitcher.exe liegt. Also normalerweise “C:\Programme\ProxySwitcher”.
Startet man nun den ProxySwitcher, erscheint im ersten Tab direkt mein neuer Switcher und kann selektiert werden, damit er auch aufgerufen wird.

Update:
Die dokumentierte Beispielimplementierung gibt es hier zum download.
With the Windows API Code Pack, Microsoft released a really cool managed wrapper for most of the new Windows 7 features. See here for more details and download.
One thing you can do is to create a .NET app with Jumplist support. Jumplists are these cool menus appearing on right click on an icon in the task bar:
But there is something wrong with the jumplist: It can only launch new apps! The demo solution for the Code Pack launches notepad and some other things, but there is no word about how to open the same app but with a new form.
So here is my solution, which is not very nice, but it works like a charm.
Scencario:
AppInstance1 is running –> click on a jumplist item starts a new instance –> appInstance2 now knows, that this is the second instance, so appInstance2 calls appInstance1 through remoting (IPC) and terminates–> appInstance1 receives the remoting call und execute something.
Ok, how to implement this?
First of all, create a new Windows Forms app and go to the Program.cs file. Within this class create a new class which works as your service for the remoting part and also a static reference to your form:
static class Program
{
public class RemotingService : MarshalByRefObject
{
public RemotingService() { }
public void ShowText(string text)
{
Program.formMain.SetTextToTextBox(text);
}
}
internal static Form1 formMain;
Then you will need some remoting code for the communication. I created two methods “InitRemoting” and “CallRunningInstance”. InitRemoting is called from the main method if this is the first instance. CallRunningInstance is called if the main method detects, that this is the second instance.
For the detection I use a system wide mutex.
I hope you get the idea. Because there are some more lines of code I created a demo project for you to download:
Download the entire working demo solution here.
If you ever tried to publish one or more pages with your site definition (by onet.xml), you see in Visual Studio (with the SharePoint XSD schemas selected) only one valid value for the “Level” attribute which is “Draft”:
But for this attribute you can choose between every value of the SPFileLevel enum. So for publishing the page automatically, set the Level to “Published”. Thats it.
If you already know how to enable XSD schema validation and IntelliSense support stop reading here.
Enable Schema Validation:
- Open your xml file, e.g. onet.xml (works with all SharePoint related xml files)
- In the property pane, click the ellipsis next to the “Schemas” property
- Add the wss.xsd. This file is located in the 12\Template\XML directory
- Now add the following xml Namespace attribute to the root element (here Project in onet.xml):
<Project xmlns="http://schemas.microsoft.com/sharepoint/" Title="" [...]
Now you should have IntelliSense and schema validation enabled.
Seit heute habe ich das Service Pack 1 für das .NET Framework 3.5 und den SQL Server 2008 auf meinem Server installiert. Ein paar neue kleine private Projekte warten und können nun mit den neuen Features ausgerüstet werden (z.B. Entity Framework und auch ASP.NET MVC obwohl das nur eine CTP ist).
An der Stelle kann ich das .NET 3.5 Enhancements Training Kit empfehlen! Sehr guter Überblick über alle Neuheiten.
Außerdem werde ich vielleicht die Datenbank von WoIstMarco? auf die neuen SQL Server 2008 Geo Datentypen upgraden. Mal schauen, was das so für Vorteile bringt.
Jetzt brauche ich nur noch viiel Zeit...
Es ist kaum zu glauben! Mit Visual Studio 2008 SP1 hat nun endlich die Funktion einzug gehalten, die man schon seit Jahren vermisst, wie ich gerade entdeckt habe...
Man hat z.B. folgendes geschrieben:
public bool IsFoo(object x)
{
}
Früher war es so: Den “Fehler” dass nicht alle Pfade der Methode einen Wert zurückgeben bekommt man erst, wenn man “Build” aufruft.
Jetzt neu: Der Fehler wird sofort im Error Log sichtbar! Ohne speichern, ohne Build! Danke Microsoft!
Wie ja bereits seit Tagen an diversen Stellen zu lesen ist, steht das Visual Studio 2008 für alle MSDN Subscription Kunden zum Download zur Verfügung!
Dies ist die erste VS Version, mit der man für alle .NET Framework Versionen entwickeln kann, weshalb ich direkt mal VS 2005 deinstalliert und 2008 installiert habe. Bisher bin ich ganz zufrieden. Der Team Explorer 2008 läuft sogar mit TFS 2005. Wer den Team Explorer 2008 übrigens sucht, hier ist der Download.
Jetzt warte ich nur noch auf Windows Server 2008... wohl leider bis Februar.
Danke Microsoft für die Implementierung dieses fundamentalen Features in der kommenden Version des Team Foundation Servers / VS 2008... endlich!
