Wednesday, November 24, 2010
Store data from async web service call with Silverlight
But that is only half the truth. Here it how it works!
Monday, November 1, 2010
Visual Studio, TFS and WinMerge
WinMerge is a great and handy tool for comparing and merging source code and other textual file types within a team development environment.
I use it since a few years and therefore I also want to use it with VS2010 and TFS and it’s very simple.
Just go through
Tools > Options > Source Control > Visual Studio Team Foundation Server > Hit <Configure Tools>
Here you can setup custom tools for comparing and merging.
Add a new tool and provide the installation path to WinMerge and some command line arguments like (explanation follows):
Hit <OK> and do the same with merge.
Command line switches for WinMerge are (copied from the WinMerge documentation):
-
/r
compares all files in all subfolders (recursive compare). -
/e
enables you to close WinMerge with a single Esc key press. -
/f
applies a specified filter to restrict the comparison. The filter can be a filemask or the name of a file filter -
/x
closes WinMerge (after displaying an information dialog) when you start a comparison of identical files. -
/s
limits WinMerge windows to a single instance. -
/ul
prevents WinMerge from adding the left path to the Most Recently Used (MRU) list. -
/ur
prevents WinMerge from adding the right path to the Most Recently Used (MRU) list. -
/u
prevents WinMerge from adding either path (left or right) to the Most Recently Used (MRU) list. -
/wl
opens the left side as read-only. -
/wr
opens the right side as read-only. -
/maximize
starts WinMerge as a maximized window. -
/dl
specifies a description in the left side title bar, overriding the default folder or filename text. -
/dr
specifies a description in the right side title bar, just like/dl
. -
specifies the folder, file or project file to open on the left side.leftpath
-
specifies the folder, file or project file to open on the right side.rightpath
-
Specifies an optional output folder where you want merged result files to be saved.outputpath
-
Specifies a conflict file, typically generated by a Version control system.conflictfile
Resources:
flurfunk.sdx-ag.de
www.prowebconsult.com
Winmerge manual
Sunday, October 31, 2010
Auto checkout with VS2010 and TFS2010 not working
On my project “Simple Proxy Switch” I decided to access codeplex version control system through VS2010 TFS integration.
As I mainly use Subversion I like that you can edit files without locking them. As I arrived on TFS I missed this a lot. Searching for other options I found the ability of TFS to check out files on edit.
Nevertheless it doesn’t work for me. Files still are not getting checked out on edit.
Fast search at the web discovers some helpful links mainly again in the Microsoft Developer Network.
The missing setting was the binding of the solution to TFS. This can be achieved on Selecting solution and than go through
File –> Source Control –> Change Source Control
select solution and hit <Bind>.
Et voilĂ . Now VS2010 checks out files on edit.
Thursday, October 21, 2010
You are logged into a Temporary Profile
After a short search with my search engine of choice I found a solution for this on the Windows 7 IT Pro Forums. Detailed information about user profiles can be found on About User Profiles.
So this has been caused because I used this machine with the same domain account before I had sysprepped it.
In short:
Search user profile at
C:\Users\%username%and delete it.
Open the registry editor and search for the profile with the corresponding SID at registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\ProfileListand delete it.
Restart and try to log on. Problem should be solved.
Detect current network setting with C#
In cause of my latest project Simple Proxy Switch I had to face the challenge of detecting the setting of the current network the computer is connected to.
Now here’s my snippet how do I retrieve the current network setting:
// zero conf ip address IPAddress zeroConf = new IPAddress(0); // get current assigned addresses IPAddress[] hostAddresses = Dns.GetHostAddresses(Dns.GetHostName()); var networkData = NetworkInterface.GetAllNetworkInterfaces() // filter running network interfaces .Where(network => network.OperationalStatus == OperationalStatus.Up) // filter unknown interfaces .Where(network => network.NetworkInterfaceType != NetworkInterfaceType.Unknown) // filter loopback interfaces .Where(network => network.NetworkInterfaceType != NetworkInterfaceType.Loopback) // get the properties .Select(network => network.GetIPProperties()) // filter initialized gateways .Where(ipProps => ipProps.GatewayAddresses.All(gateway => gateway.Address != zeroConf)) // filter and get ip addresses .SelectMany(ipProps => ipProps.UnicastAddresses.Where(ucAddress => hostAddresses.Contains(ucAddress.Address))) .Where(ucAddress => hostAddresses.Contains(ucAddress.Address)) // simply use the first .FirstOrDefault();
Be the force with you!
Monday, September 27, 2010
Network drives unavailable while running programs under Admin privileges
I guessed this was caused because of VS2010
%VSINSTALLDIR%\Common7\IDE\devenv.exeis treated to be executed as administrator also the VSLauncer.exe located in
%CommonProgramFiles%\microsoft shared\MSEnv\VSLauncher.exeYesterday I spent now 2 min with google and found a solution.
The problem is caused by using different access tokens for user currently logged in and program that runs with admin privileges. Further information can be found here.
This problem can be solved by enable sharing of access tokens between current (filtered) and admin access. This can be done by creating registry key
EnableLinkedConnectionslocated under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Systemand setting it’s DWORD value to ‘1’. Detailed information can be found here.
Have fun.
Wednesday, August 11, 2010
ReSharper shortcuts for VS2010 to improve TDD productivity
One very nice feature is to run your NUnit-Test within the integrated Testrunner. But it’s a little bit annoying to click on the play button every time you want to run a test.
The easiest thing to handle this is to set up keyboard shortcuts to run you tests. Visual Studio supports setting shortcuts for a lot of actions, so let’s go straight ahead and set up shortcuts.
Simple open the options dialog for keyboard settings via Tools –> Customize –> hit “Keyboard” button and then search for
ReSharper.ReSharper_UnitTest_
As result you get something like the following:
Now you can set the shortcut for the desired operation.
I have chosen combinations of
Ctrl + Shift + Alt & '<'
A short explanation of the shown possibilities:
- ContextRun runs the current selected test
- ContextDebug debugs the current selected test
- RunCurrentSession reruns a previous test session
- RunSolution runs all test within the solution
Thursday, June 24, 2010
Remote Certificate validation
While it is easy to get this information from unsecured HTTP resources it's often the case that such a resource is only available for secured access through HTTP.
In that case and to ensure that this connection is trusted you have to check the server certificate for that connection.
Some sample piece of code to access and download data over http can look like this one:
string data = String.Empty; using (WebClient webClient = new WebClient()) { byte[] rawData = webClient.DownloadData(new Uri(/* path to resource */)); using (MemoryStream memStream = new MemoryStream(rawData)) { using (StreamReader reader = new StreamReader(memStream, true)) { data = reader.ReadToEnd(); } } }
This code works well for connections through HTTP.
Now you have to access the same resource over HTTPS and this is where you have to face a new challenge:
Validation of Certificates.
In the case of .NET there is the ServicePointManager that let you intercept the mechanism of validation.
It defines the ServerCertificateValidationCallback method which is called on secure resource access.
The adjusted code is now something like this:
string data = String.Empty;
using (WebClient webClient = new WebClient()) { RemoteCertificateValidationCallback validationCallback = (sender, cert, chain, errors) => { return true; }; ServicePointManager.ServerCertificateValidationCallback += validationCallback; try { byte[] rawData = webClient.DownloadData(new Uri(/* path to resource */)); using (MemoryStream memStream = new MemoryStream(rawData)) { using (StreamReader reader = new StreamReader(memStream, true)) { data = reader.ReadToEnd(); } } } finally { ServicePointManager.ServerCertificateValidationCallback -= validationCallback; } }
This code simply declares all certificates as valid which is some kind of stupid.
Let's focus on the validation of the certificate. Feel free to implement you own code of validation or just simply use .NET integrated features.
Something I did at bugtraqplugin is to use the default validation chain which depends on certificates stored at the Windows certification storage.
My simple approach:
RemoteCertificateValidationCallback validationCallback =
(sender, cert, chain, errors) => { return (certificate as X509Certificate2 ?? new X509Certificate2(certificate)).Verify(); };
All code put together can be available at source code of bugtraqplugin.
Thursday, April 29, 2010
msiexec /a - MSI-Installer Error 2203
msiexec /a <product.msi> /qb TARGETDIR=%CD%Still after searching the web I still had no solution so tried to analyse failure with log file examination:
msiexec /a <product.msi> /qb TARGETDIR=%CD% /lv %CD%\Installer.logAfter reading a few lines of log the scales fell from my eyes. The source and the destination are the same and the Installer prohibit extracting into source directory directly.
So
msiexec /a <product.msi> /qb TARGETDIR=%CD%\Extractsolves the problem!
Thursday, April 8, 2010
Consuming XML-RPC web services with C# - Part 2 - the OOP approach
This can be only the first approach. It's unhandy and not easy to maintain.
The next level for me would be to cast this into an object oriented data structure that could be easily maintained and customized for special needs.
At this post I try to show my object oriented approach to consume such services.
Thursday, March 25, 2010
Permanent redirect with Apache Mod rewrite
Here's my snippet that I'm using
RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^/(.*)$ http://www\.%{HTTP_HOST}/$1 [R=301,L]
Someone may ask why I should do that?
The simple answer: SEO
Search engines are crawling the web to indexing content of web pages. So if they discover links to www.example.com they are not seen as a reference to the same content reachable through example.com.
That's all.
Good german resource explains redirection: Automatische Weiterleitung
Friday, March 19, 2010
Consuming XML-RPC web services with C# - Part 1 - the rough way
While dealing with integration of Bugzilla as data provider within BugtraqPlugin (which I described here) I encountered that bugzilla has an XML-RPC interface. Not this bad, but
How to perform XML-RPC calls with c# and .NET?
It's a simple task to get access on soap web services because it provides a description of it's own interface through a wsdl definition, so you easily can generate proxy classes for such a case.
But whats about XML-RPC web services? Here is just a sample practiced on bugzilla web service.
Monday, February 15, 2010
Customizing Visual Studio code templates to fit your needs
Here is a guide how do you extend this template.
Tuesday, February 9, 2010
Tortoise SVN Plugin for issue tracking system
(But discuss that is not the intention of this blog post, so skip comments about that.)
On the other hand, a version control system is not the right tool to manage project dependent things, feature requests and to track bugs. So professional teams use also a project management tools in combinition with bug tracking systems.
(To discuss the pro an cons of different systems is also not the intention of this post, so ...)
And now, one question:
What it will be, if you combine these applications and let them communicate in two ways?
Monday, February 8, 2010
Multi-Startpage with Firefox
The settings dialog only offers to set the current page as startpage, not the opened tabs. But a a short research on the internet results, that is it possible to sett multiple startpages by manual.
So just enter the urls to the pages separated by pipes an you get multiple startpages with firefox.
German version on www.baer-torsten.de
Wednesday, January 20, 2010
Two ways of disabling Ctrl-Alt-Delete on logon
Some like this feature, I not.
I have found two ways to disable this on Windows 7® and Vista®.
Not Requiring Ctrl-ALT-DEL at logon
Vista requiring ctrl-alt-del before login
The two ways are:
- Advanced User Accounts Control Panel (NETPLWIZ; %systemroot%\system32\netplWiz.exe)
- Local Security Policy
The Advanced User Accounts Control Panel is reachable via
- <Win> + <R> ⇒ type Netplwiz ⇒ hit <Enter>
- Start button or <Win> ⇒ press Run ⇒ type Netplwiz ⇒ hit <Enter>
- Start button or <Win> ⇒ press "Help and Support" ⇒ search for "Secure Login" or Ctrl-Alt-Del ⇒ usually the first result ⇒ hit "Click here to open Advanced User Accounts"
- Control Panel ⇒ User Accounts ⇒ User Accounts ⇒ Manage User Accounts ⇒ Advanced
[not reproduceable]
The Local Security Policy is reachable via
- Start or <Win> ⇒ Control Panel ⇒ System and Maintenance ⇒ Administrative Tools ⇒ Local Security Policy ⇒ Local Policies
- <Win> + <R> ⇒ Type gpedit.msc ⇒hit <Enter> ⇒ Local Computer Policy ⇒ Computer Configuration ⇒ Windows Settings ⇒ Security Settings ⇒ Local Policies
Have fun.