Rob Kraft's Software Development Blog

Software Development Insights

Archive for the ‘Dev Environment’ Category

How to prevent foreign language subfolders in Silverlight projects

Posted by robkraft on April 2, 2011

I like to keep my folders and libraries clean, and one thing I find annoying is the generation of subfolders and DLLs for to support foreign languages when I have no interest in providing that support in my application.  Specifically, when I am developing Silverlight applications I notice many subfolders like ar, bg, zh-hans, sr-cryl-cs, and es.  If you want to keep your compile from generating those subfolders, you can do this by deleting all the foreign language subfolders that were created by the installation of Silverlight.
This can be tedious, especially if you want to delete them on several machines.  So I created this simple batch file to do it for me.  You may need to change the silverlight folder, and there will probably be additional langauges added, but this may provide you a starter batch file.

c:
cd\
cd "program files\microsoft silverlight\4.0.60129.0\"
rd ar /S /Q
rd bg /S /Q
rd ca /S /Q
rd cs /S /Q
rd da /S /Q
rd de /S /Q
rd el /S /Q
rd es /S /Q
rd et /S /Q
rd eu /S /Q
rd fi /S /Q
rd fr /S /Q
rd he /S /Q
rd hr /S /Q
rd hu /S /Q
rd id /S /Q
rd it /S /Q
rd ja /S /Q
rd ko /S /Q
rd lt /S /Q
rd lv /S /Q
rd ms /S /Q
rd nl /S /Q
rd ru /S /Q
rd zh-hans /S /Q
rd zh-hant /S /Q
rd no /S /Q
rd pl /S /Q
rd pt /S /Q
rd pt-br /S /Q
rd ro /S /Q
rd sk /S /Q
rd sl /S /Q
rd sr-cyrl-cs /S /Q
rd sr-latn-cs /S /Q
rd sv /S /Q
rd th /S /Q
rd tr /S /Q
rd uk /S /Q
rd vi /S /Q

cd\
cd "Program Files\Microsoft SDKs\Silverlight\v4.0\Libraries\Client\"
rd ar /S /Q
rd bg /S /Q
rd ca /S /Q
rd cs /S /Q
rd da /S /Q
rd de /S /Q
rd el /S /Q
rd es /S /Q
rd et /S /Q
rd eu /S /Q
rd fi /S /Q
rd fr /S /Q
rd he /S /Q
rd hr /S /Q
rd hu /S /Q
rd id /S /Q
rd it /S /Q
rd ja /S /Q
rd ko /S /Q
rd lt /S /Q
rd lv /S /Q
rd ms /S /Q
rd nl /S /Q
rd ru /S /Q
rd zh-hans /S /Q
rd zh-hant /S /Q
rd no /S /Q
rd pl /S /Q
rd pt /S /Q
rd pt-br /S /Q
rd ro /S /Q
rd sk /S /Q
rd sl /S /Q
rd sr-cyrl-cs /S /Q
rd sr-latn-cs /S /Q
rd sv /S /Q
rd th /S /Q
rd tr /S /Q
rd uk /S /Q
rd vi /S /Q

Posted in Dev Environment, Silverlight | Leave a Comment »

Post Build steps for both 64bit and 32bit development

Posted by robkraft on July 4, 2010

We recently upgraded a developer workstation to 64bit windows and learned that our project post-build steps did not work because the folder names are different.  To remedy this problem we replaced the post build with a call to a batch file that gave us more control over the post build logic.

The post build in most of all our projects now only contains something like this:

Call “c:\dev\Postbuild.bat” $(TargetPath) $(ProjectName) ourProjectName

The “Call” command is always recommended for invoking batch files.  We hard-coded the folder that contains the .bat file.  The 3 pieces of data following that are input parameters to the DOS batch file.

To install to the GAC on the 64bit or 32bit machines, our batch file has this code:

IF EXIST “c:\Program Files (x86)\”. (set gacexe=”C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\gacutil”) ELSE (set gacexe=”C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\gacutil”)

%gacexe% /u %3
%gacexe% /if %1

To copy files to the correct nunit folder we have code in the batch file like this:

IF EXIST “c:\Program Files (x86)\”. (set nunitdir=”c:\program files (x86)\nunit\bin\net-2.0″) ELSE (set nunitdir=”c:\program files\nunit\bin\net-2.0″)

echo off
xcopy %1 %nunitdir% /Y

I hope someone else gets some value from this.

Posted in Dev Environment | Leave a Comment »

Our upgrade to Visual Studio 2010 encountered more problems than we expected

Posted by robkraft on May 18, 2010

Our upgrade to Visual Studio 2010 encountered more problems than we expected. We are developing Silverlight applications for resale using Visual Studio 2008, Silverlight 3 and Blend 3. After doing a little research we devised an upgrade plan to migrate to Visual Studio 2010, .Net 4, and Silverlight 4. Our basic upgrade sequence was correct, but we neglected to include steps for upgrading Nant, Nunit, and Microsoft Patterns and Practices. Also, as of this post, we have not succeeded to get our applications to work on Silverlight 4. I’ve included the upgrade plan we now recommend at the end of this article. In between here and there are the issues we faced with each task and our resolutions.

Visual Studio 2010

I don’t recall any problems with the installation of Visual Studio 2010 or opening our projects and running them there.

.Net 4
We encountered more problems than expected, particularly with the conversion to .Net 4.
Tip 1) When converting projects to .Net 4, start with the projects in the solution that have the most dependencies, such as an .exe. Work your way down toward the dll that has the most dependencies, doing several builds along the way. Check in the changes made so far after each successful build.
Tip 2) Keep an eye on the projects you have changed, particularly if you try to have multiple instances of Visual Studio open. I frequently found that some projects I had converted to .Net 4 lost their changes. This may be because I had two solutions opened at the same time, but each had some of the same dependency projects.
Tip 3) Be careful if you open a Visual Studio command prompt. Make sure you choose a VS 2010 command prompt instead of a VS 2008 command prompt.
Tip 4) In a few cases, the update to .Net 4 did not update some of the referenced system files to their .Net 4 equivalent. Of course, the project won’t compile, and you will need to manually change the reference. This happened to me a few times with the System.Data and System.Data.Extensions DLLs.

Our project files (.csproj) have post-build events in them. Some of the changes we had to make were:
1) To put a file in the GAC, change it from:
  C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil
  to
  C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\gacutil
2) To register an assembly in the post build event, change it from:
  C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm.exe
  to
  C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\regasm.exe
3) and possibly also:
  C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\tlbexp.exe
  to
  C:\Program Files\Microsoft SDKs\Windows\v7.0A\bin\NETFX 4.0 Tools\tlbexp.exe

Some of our projects could not compile because they used System.Data.OracleClient which is deprecated in .Net 4. We were able to convert those projects to using the DLLs from Oracle with a few hours of work.

Some of our Visual Basic projects would not compile due to this error:
The error is warning BC42353 or BC42025
“Function ‘IsExcludeField’ doesn’t return a value on all code paths…

Some attributes are deprecated and won’t compile like RegistryPermissionAttribute.

Nant:
Nant’s gac-install was not working for .Net 4, so we converted all of our gac-install tasks to run the gacutil.exe using “exec program” instead. In hindsight, this was not necessary. The real problem was that our modifications to the nant.exe.config file were incorrect. We are now using the nant.exe.config we found at http://pastebin.com/KxqFA8T6

Nunit:
We were running on Nunit 2.4. We realized after the fact that we needed to upgrade to Nunit 2.5.5.10112. I encourage you to upgrade to Nunit 2.5 prior to your upgrade to VS2010. We had a few tests begin failing simply due to differences between Nunit 2.5.5 and 2.4.

We used to run Nunit tests from within Visual Studio by having our nunit test projects launch the Nunit.exe. This option is more complicated now that our application is on .Net 4 because Nunit is a .Net 2 app. It is still possible for Nunit to run tests built in .Net 4, but now, after we launch our application from Visual Studio we need to go back into Visual Studio to the Debug menu, select Attach To Process, and attach to the nunit-agent process in order to debug/step through our nunit tests.

We had to change our nant build process to reference the reference the new directory we installed nunit to and also to specify the correct framework version:

1) <property value=”c:\program files\NUnit 2.4\bin” />
to <property value=”c:\program files\NUnit\bin\net-2.0″ />

2)<property value=”v2.0.50727″ unless=”${property::exists(‘framework.version’)}” />
to <property value=”v4.0.30319″ unless=”${property::exists(‘framework.version’)}” />

 3) on commandline for nunit-console:

… /output=mytests.txt /labels

to

… /output=mytests.txt /labels /framework=net-4.0

Managing the GAC
The GAC has changed in .Net 4 and Microsoft has not documented it well (IMHO).

The most (perhaps only) reliable way to manage the GAC on your PC for .Net 4 is the command line tool gacutil. If you open the assembly folder (c:\windows\assembly), you will not see any .Net 4 assemblies, nor is there a .Net 4 Assembly Configuration tool (yet).

I do see that you can open c:\windows\assembly\Download to see your .Net 4 assemblies. But on my machine several of my assemblies are in there multiple times with the same version numbers. And some are marked private and some are marked shared. I don’t know what to make of all of that.

I have gotten good at running this command to dump the GAC contents to a text file which I then open with notepad:
Gacutil /l > c:\gac.txt
Notepad c:\gac.txt
To add a file to the gac I use:
Gacutil /if MyFileName.dll
To remove a file from the gac I use (no .dll extenstion):
Gacutil /u MyFileName

Microsoft Patterns & Practices Logging Framework:
We run one of the programs built on our framework from a network drive. But after our upgrade to .Net 4 this program failed to run from the network drive. We tracked the error down to an inability to load the Microsoft Patterns and Practices (P&P) Logging Framework DLLs. The problem occurred because all the DLLs in our framework use strong name keys, but the P&P DLLs do not. This was not a problem prior to .Net 4; but it is now. Instead of obtaining the P&P source code, adding SNKs, and compiling them ourselves, we obtained the recently released 5.0 version of the P&P DLLs. We had to make a minor code change, and we had to change all of our config files from version 3.1.0.0 to version 5.0.414.0. We also now deploy five P&P DLLs instead of the three we needed in the previous version of P&P.
Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
to
Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35

Silverlight 4
I recommend that developers avoid installing the Silverlight 4 runtime until after they are on VS2010. I upgraded one machine to the Silverlight 4 runtime and then was no longer able to debug my Silverlight 3 application in VS2008.
At this time, we have not successfully converted to Silverlight 4.
When you convert to Silverlight 4, it is best to convert all the projects in the solution to Silverlight 4 at the same time. In a few cases, Visual Studio did not correctly upgrade the System Dlls and we had to unreferenced them, then re-reference them. Our application uses the Csla.net framework. We experienced a problem when running our app and the problem only occurs in release mode. Apparently Silverlight 4 release mode optimizes the data sent down to the client such that our serialized values don’t all make it to the client. We tried upgrading from Csla 3.8 to Csla 3.8.3; and we also tried converting all of our private static propertyinfo methods in our business objects to be public. This latter action did cause our application to get past several errors, but the application still fails to return all the data to the client in release mode most of the time. We are still working on resolving this.

If we were to do our upgrade again, this would be our conversion plan:

1) Upgrade to Nant 2.5 and upgrade your config files for Nant to support .Net 4 (http://pastebin.com/KxqFA8T6). Test build processes.
2) Upgrade to the most current version of the Microsoft Patterns & Practices Logging Framework. For us, version 5.0.414.0 (http://entlib.codeplex.com). Test build processes and deployed application from build.
3) Upgrade to the most current version of Nunit (http://nunit.org). Run all tests.
4) Upgrade one developer to Visual Studio 2010.
5) That developer should convert all projects and solutions to VS 2010 and test them.
6) Upgrade all other developers to Visual Studio 2010.
7) Upgrade the build server to Visual Studio 2010, convert all the projects and solutions on the build server to VS 2010, and test the build process. Check in all changes to the subversion repository. Developers update from subversion.
8 ) Have one developer upgrade all projects to .Net 4 and test.
9) Make changes to build processes for .Net 4, build, deploy, and test.
10) All developers update from subversion to get .Net 4 versions of projects.
11) Have one developer upgrade to Silverlight 4 and test. Make sure to test with Release mode compiles!
12) Make changes to build processes for Silverlight 4. I don’t think we had any.
13) All developers update to Silverlight 4.

Posted in Dev Environment, Visual Studio 2010 | Leave a Comment »

Upgrading your nant deploy to IIS from .Net 2 to .Net 4

Posted by robkraft on April 27, 2010

For a few hours I struggled to figure out how to change my nant build process to specify that my web application should be .Net 4.0 instead of .Net 2.0. We use nant to deploy our web site after we build it using the MKIISDIR tag and executing aspnet_compiler. I made sure we were using the 4.0 version of the aspnet_compiler but the site was still defaulting to 2.0.50727. Finally, as I lay in bed about to fall asleep that night, the solution revealed itself to me. I don’t need to change anything in my nant build process; I just need to change the Default Web Site in IIS on the DeployTo server to be 4.0.30319 instead of 2.0.50727.

Posted in Dev Environment | Tagged: , , | Leave a Comment »

How to close the IE 8 Developer Toolbar

Posted by robkraft on July 20, 2009

I spent about 30 minutes recently trying to prevent the Internet Explorer 8 Developer Toolbar from opening every time I opened my browser. I like the Developer Toolbar a lot, but I definitely don’t want it opening all the time. Finally I realized that you first have to dock it in an existing IE window, then close it within the IE window, then close IE. Before you do all of that, make sure you have all other instances of Internet Explorer closed.

Posted in Dev Environment, I.T. | Leave a Comment »