Web.Config and Assembly Binding problems

asp.net - Web.Config and Assembly Binding problemsIn a recent ASP.NET project, we had to replace NLog (excellent logging .Net library, by the way) assembly with newer one.

However, due to complexity of project, recompiling of all dependent assemblies was not an option. Suggested solution was simple – use assembly redirection:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="NLog"
        publicKeyToken="5120e14c03d0593c" culture="neutral" />
      <bindingRedirect oldVersion="1.0.0.0" newVersion="1.0.0.505" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

(all of this under <configuration> tag)

In a first attempt, it did not work 🙁 – assembly redirection did not happen. Even Fusion Viewer could not find anything strange – it looked like whole redirection part was simply ignored.

I looked (very simple) web.config again, carefully inspecting it; one line, at very top of the file, looked suspitious:

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

After removing name space, and leaving usual:

<configuration>

all worked as a charm.

It turns out, that due bug in Visual Studio 2005, if you used in some point the built-in web administration tool (launched via the WebSite->ASP.NET Configuration menu item) it will add this name space to root configuration element. This will cause not just to stop Intellisense working for Web.Config but also will ignore any Assembly Binding redirection instructions.

So, if you have problem with Assembly Binding redirection in your ASP.NET application, check web.config once more 🙂

VS 2005/2008 and Vista – IE cannot display the webpage

Vista and Visual Studio - problems with IPv6 and internal WebDev.WebServerI recently reinstalled my laptop completely (it is very nice Dell XPS M1330) and took that opportunity to make it into decent development machine (w/o all the stupid preinstalled applications).

Installed also Visual Studio 2005 and 2008, SQL 2005 Express and all the little tools necessary (ClipX for example).

Fired up latest web site on which I work on, F5 and … nothing – dreadfull message of “Internet Explorer cannot display the webpage”.

Ok, no panic here, let try Visual Studio 2008 with same web site; nothing 🙁 Same site, on two other development machines (Vista & Vista 64) under VS 2005 and VS 2008 works w/o problem.

Started researching and debugging; it turns out that next generation protocol IPv6, or its implementation on Vista clashes with integrated web server WebDev.WebServer.exe; WebDev has a problem finding localhost address in default configuration.

Easy fix for this is to comment ::1 entry in hosts file:

Uncomment ::1 in hosts file to correct webdev / visual studio problems

No restart is needed, either of computer or Visual Studio.

(to edit hosts file you can use notepad started with elevated rigths or “Run as administrator“; in Open dialog you type in %windir%System32driversetchosts)

VS 2005 SP1 Installation Nightmare :-( … and how to wake up

Visual Studio 2005 SP1As you probably know, long awaited Visual Studio 2005 SP1 is out.

However, installation of this giant (400+ Mb) update is far from easy, and it is not guaranteed to succeed, at least at first run.

  1. You need to have a LOT free space on your system drive: at least 3 Gb
  2. Make sure that you have enough patience – it can take between 10 minutes and 1,5 hour
  3. If you do not use C++ portion of Visual Studio, deinstall it before installation of SP1 – it can save a lot of installation time.
  4. Deinstall Web Application Project if you have it installed.
  5. Deinstall Visual Studio 2005 Web Deployment Projects if you have it installed.
  6. Deinstall Visual Studio 2005 SP1 beta

Finally, you can speed up installation process by:

Disabling Patch Cache

Create CMD file with following content:
reg export HKLMSoftwarePoliciesMicrosoftWindowsInstaller installer.reg
reg add HKLMSoftwarePoliciesMicrosoftWindowsInstaller /v MaxPatchCacheSize /t REG_DWORD /d 0 /f
net stop msiserver
start /wait VS80sp1-KB926601-X86-ENU.exe
reg delete HKLMSoftwarePoliciesMicrosoftWindowsInstaller /v MaxPatchCacheSize /f
reg import installer.reg
net stop msiserver
del /q installer.reg 2>nul

and save it in folder where SP1 is. Run it – it should cut down installation time significantly.

Ok, you succeeded to do all above, and installation is failing. What next?

Error 1718

Let assume that your operating system is XP SP2. If you got during installation this error:

Error 1718. File was rejected by digital signature policy

try recipe from this location:

http://support.microsoft.com/kb/925336 – this helped with installation on two locations where it failed previously.

I have Windows Server 2003 SP1 and unfortunately, neither of solutions (disable patch cache or KB925336) helped 🙁

I though that memory upgrade will help, so I added 1Gb to total of 2Gb – no luck.

You can also try to:

Disable SAFER check for local administrators

– Note (if exist) previous value of PolicyScope at:

HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftwindowssafercodeidentifiers

– Set this value (or create it as DWORD if does not exist) to 1

– Run net stop msiserver

– Try SP1 install

– Revert PolicyScope to previous value / delete it after installation.

(this helped on two other Windows 2003 SP1 machines; again, not on mine)

Finally, I decided to:

Slipstream SP1 into Visual Studio 2005 and reinstall it

There are couple steps here:

Make Network Installation

Create network administrative installation from your VS 2005 DVD (assuming that E: is DVD and location where you want installation \dvesicpublicVisualStudio2005SP1):

msiexec.exe /a E:vsvs_setup.msi TARGETDIR=\dvesicpublicVisualStudio2005SP1 /L*vx install.log

I did this all on same machine, using mounted ISO image on a virtual drive and unpacking it at network location on same machine – it took over 2 hours to create network install

Unpack the Patch

Original EXE file is just wrapper around MS Patch file. You can unpack it using some unzip utility (or Total Commander) or by executing:

VS80sp1-KB926601-X86-ENU.exe /extract .

Patch Network Install

Finally, do the patching of installation:

msiexec.exe /a \dvesicpublicVisualStudio2005SP1vs_setup.msi /p VS80sp1-KB926601-X86-ENU.msp /L*vx patch.log

Reinstall Visual Studio 2005 SP1

I hope that at least some of this will help you too.

Reference links:

http://weblogs.asp.net/jgalloway/…/things-i-wish-i-d-known-before-i-installed-vs-2005-service-pack-1.aspx

http://blogs.msdn.com/heaths/…/save-time-and-space-for-vs-2005-sp1-by-disabling-the-patch-cache.aspx

http://blogs.msdn.com/heaths/…/slipstreaming-visual-studio-2005-service-pack-1.aspx

http://blogs.msdn.com/heaths/…/Enabling-Large-Patches-to-Install.aspx

Update 12th May 2007

There is update availabile which will hopefully sort this problems out on easy way.

Digg!

Visual Studio 2005 SP1 is out!

Visual Studio 2005 SP1
Visual Studio 2005 SP1 is finally released.

Apart from bugfixes and corrections, Service Pack 1 also provides over 70 improvements for common development scenarios including:

  • New processor support (e.g., Core Duo) for code generation and profiling
  • Performance and scale improvements in Team Foundation Server
  • Team Foundation Server integration with Excel 2007 and Project 2007
  • Tool support for occasionally connected devices and SQL Server Compact Edition
  • Additional support for project file based Web applications
  • Windows Embedded 6.0 platform and tools support

However, this is not final solutions for developers working on Vista operating system 🙁

More info here: http://msdn.microsoft.com/vstudio/support/vs2005sp1/

Download (of hefty 432 MB) is here:
http://www.microsoft.com/downloads/details.aspx?familyid=BB4A75AB-E2D4-4C96-B39D-37BAF6B5B1DC