Showing posts with label VS2008. Show all posts
Showing posts with label VS2008. Show all posts

Saturday, March 6, 2010

svn and eol-style on Windows

Recently I had problems with one great tool - Resharper. Behaviour of this VS 2008 plugin in this particular situation wasn't perfect (showing boxes instead of text lines :), but it was easier to fix problem at our side than wait for resolution by developers.
Resharper doesn't like unix style (LF) or mixed style (somewhere LF, somewhere CRLF) EOLs (end of line-s). And our big solution had many C# source files with wrong (for windows platform) EOLs. So sometimes in some files refactoring or even just working with Resharper enabled was impossible.
I'm not sure about specific situation when our EOL's become damaged, but most likely this ocurred during migration from CVS to SVN. SVN contains built-in property to fix this problem (svn:eol-style set to native), so we only needed to:
1. Set autoproperties (most our developers are using tortoisesvn so it was easier for us to set tsvn:autoprops property one time for solution root, efficiently enabling autoproperties for all our working copies) to enable svn:eol-style option for all files added in future. So we set tsvn:autoprops property for project root to this value:
*.c = svn:eol-style=native
*.h = svn:eol-style=native
*.cpp = svn:eol-style=native
*.cs = svn:eol-style=native
*.strings = svn:eol-style=native
*.resx = svn:eol-style=native
*.csproj = svn:eol-style=native
*.sln = svn:eol-style=native
*.sql = svn:eol-style=native
*.config = svn:eol-style=native
*.build = svn:eol-style=native
*.tpl = svn:eol-style=native
2. Set svn:eol-style property for files already present at SVN repository. This was a tricky one (at least under windows), cause we needed to recurse all solution folders searching for .CS files, fix EOLs in them (otherwise svn won't accept eol-style property for these files), and set property. Ok, to make the script bellow work you'll need some client SVN binaries (I'd used sliksvn) and this my small regex processing tool (requires .Net 3.5sp1). Ok, contents of BAT file (I named it svnps.bat):
@echo off
for /R %%a IN (%1) DO (

echo ---- processing %%a
RegExRun.exe "(\r\n|\r|\n)" "\r\n" < "%%a" > "%%a.crlf"
rename "%%a" "%%~nxa.old"
rename "%%a.crlf" "%%~nxa"
del /F /Q "%%a.old"
"C:\Program Files\SlikSvn\bin\svn.exe" ps svn:eol-style native "%%a"

)
Place this bat file and RegExRun.exe to Program Files / Sliksvn / bin directory, go with command prompt (or FAR for example) to your SVN repository directory and run something like this:
"C:\Program Files\SlikSvn\bin\svnps.bat" *.cs
This will fix all non DOS (non Windows) EOLs in .CS files in current path (recursively) and set svn:eol-style=native for each of them. Together with autoproperties that should resolve all your (and our) problems :)

Friday, March 5, 2010

Beware of SHFileOperation

Take care in case you ever going to use SHFileOperation function.
Fields pFrom and pTo of SHFILEOPSTRUCT must be double-null terminated!
Even if you are passing only one file name.
 
P.s. Our tech.support guys informed me about funny thing: last version of one of our products distributed to clients was removing boot.ini, ntldr, and other files at C:\ during uninstall. Yes, due to missing second null. Evil :)

Saturday, February 13, 2010

Visual Studio 2008 failed to start

One funny problem just happened with my computer for the second time in half-a-year.
Visual Studio 2008 (MS VS2008 SP1 with ATL fixes) suddenly refused to run and displayed the following problem: "Cannot find one or more components. Please reinstall the application".

This thread contains the detailed desciption of the problem and similar user stories: http://social.msdn.microsoft.com/Forums/en/vssetup/thread/76713427-0daa-4907-a017-633ad258a5af
It actually helped me very much to resolve this problem for the first and second times.

The second time it was the same file, but I still don't know what kind of software/installation removed it.

WinSxS\x86_Microsoft.VC90.ATL_1fc8b3b9a1e18e3b_9.0.30729.4148_x-ww_353599c2\ATL90.DLL

The easiest way to restore it is to download and install vcredist_x86 (redistributable for Visual C++ 2008 SP1 with ATL security update) from here (if your computer is missing the same file):
http://www.microsoft.com/downloads/details.aspx?familyid=2051A0C1-C9B5-4B0A-A8F5-770A549FD78C&displaylang=en

I wouldn't recommend copying atl90.dll from any x86 directory inside WinSxS since they all different versions, and this one actually contains some security fixes.

P.S. You need to start profiling (F7) in depends (Dependancy Walker, rocks!) to see which dlls are really required and missing on your system.