Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio
All postings are provided AS IS with no warranties, and confer no rights. Additionally, views expressed herein are my own and not those of my employer, Microsoft.
I often get questions from fellow employees or customers who find my blog regarding how to troubleshoot .NET Framework installation errors. I want to outline the process that I use to narrow down one of the most common errors that I see that can cause the .NET Framework 3.0, the .NET Framework 3.0 SP1 or the .NET Framework 3.5 to fail in the hopes that it will help some folks who read this post in the future be able to narrow down and resolve this issue on their system if they encounter it.
This particular error occurs when a custom action that runs an EXE named ServiceModelReg.exe during .NET Framework 3.0 setup fails. This custom action is inside of the Windows Communication Foundation (WCF) MSI in the .NET Framework 3.0, and it also is run during .NET Framework 3.5 setup because the .NET Framework 3.5 requires the .NET Framework 3.0 SP1 as a prerequisite. I use the following process to narrow down the root cause of the error and attempt to identify useful workarounds:
Step 1 - Find the exact component that is failing
I start the investigation process by looking at the .NET Framework 3.0 setup log files or the .NET Framework 3.5 setup log files, depending on what setup is failing.
If the error occurs during .NET Framework 3.0 setup, the main .NET Framework 3.0 setup error log file (named %temp%\dd_dotnetfx3error.txt) will show an error like the following in this case:
[03/25/08,11:11:11] Windows Communication Foundation: [2] Error: Installation failed for component Windows Communication Foundation. MSI returned error code 1603
If the error occurs during .NET Framework 3.5 setup, then the main .NET Framework 3.5 setup error log file (named %temp%\dd_dotnetfx35error.txt) will show an error like the following in this case:
[03/25/08,11:11:11] Microsoft .NET Framework 3.0a: [2] Error: Installation failed for component Microsoft .NET Framework 3.0a. MSI returned error code 1603
Step 2 - Find the verbose MSI log for the failing component
From here, I proceed to locate the verbose MSI log file for the specific component that is failing. As I described in this blog post, the .NET Framework 3.0 and 3.5 installers create their own verbose log files by default, so there is no need to enable logging and re-run setup to produce verbose logs.
If the error occurs during .NET Framework 3.0 setup, the verbose log file that contains the error will be named %temp%\dd_wcf_retMSI*.txt in this case.
If the error occurs during .NET Framework 3.0 SP1 setup, the verbose log file that contains the error will be named %temp%\dd_NET_Framework30_Setup*.txt in this case.
Step 3 - Find the error causing the failure within the verbose MSI log
Once I have located the appropriate verbose MSI log file, I use the technique described in this blog post to narrow down the root cause of the failure. Searching for the string return value 3 in the case of this particular error shows that the last action being run prior to setup failing is the following:
MSI (s) (B4:D0) [11:11:11:011]: Executing op: CustomActionSchedule(Action = DD_CA_InstallXwsRegExe_X86.3643236F_FC70_11D3_A536_0090278A1BB8, ActionType=3073, Source=BinaryData, Target=QuietExec, CustomActionData=c:\WINDOWS\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe /r /x /y /v; dummy; c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\)
Note that you cannot search for the string return value 3 if you are installing on a non-English OS. Windows Installer translates the string "return value" into the OS language when it creates entries in a verbose MSI log file, so you will need to search for a translated version of this message if you are installing on a non-English OS.
Step 4 - Find the root cause of this custom action failure
In this case, the verbose MSI log file shows that the custom action that runs ServiceModelReg.exe is failing in this case. This custom action is designed to create its own log file named %temp%\dd_wcf_retCA*.txt, so the first thing I try when I see this type of error is to find that file and look for errors, warnings, or exceptions. Most of the time, if that log is created, the error listed there is fairly self-explanatory and it is straightforward to determine how to work around the problem.
However, I have also seen many cases where ServiceModelReg.exe fails but does not create this additional log file. In that case, the next step is to go look at the application event log to see if any exceptions were logged by this action that will help narrow down the root cause. You can do the following to locate this type of error in the application event log:
In most cases that I've seen of this issue in the past, the exception listed in the application event log looks like the following:
System.TypeInitializationException: The type initializer for 'System.ServiceModel.Install.IisHelper' threw an exception. ---> System.ApplicationException: ServiceModelReg.exe has detected a possible corruption in the IIS metabase that prevents the registration of the ServiceModel IIS scriptmaps. Please either fix the IIS metabase corruption, or, if you do not desire ServiceModel WebHost funtionality, disable the IISAdmin service and reregister ServiceModel. ---> System.Runtime.InteropServices.COMException (0x8009000F): Object already exists.
Step 5 - Try to fix the underlying issue
Typically, the above error means that there is something wrong with the installation of IIS on the system. What I normally suggest to try to fix this type of error is to try to uninstall and then re-install IIS using the Add/Remove Windows Components control panel, reboot, and then try to install the .NET Framework 3.0 or 3.5 again. If that does not help, it should also be possible to disable the IISAdmin service on the system prior to installing the .NET Framework 3.0 or 3.5 (assuming that you do not plan on using Windows Communication Foundation WebHost functionality after installing the .NET Framework 3.0 or 3.5). To do that, you can use these steps:
If the above steps do not work, it can also be helpful to try to install the .NET Framework 3.5 SP1 (which will install the .NET Framework 3.0 SP2 and 2.0 SP2 behind the scenes). As described in this blog post, there are some changes in .NET Framework 3.5 SP1 setup that can allow it to succeed in cases where .NET Framework 3.0 or 3.5 setup would otherwise fail.
What to do if steps 4 and 5 do not match what you see on your system
This blog post is intended to demonstrate how I approach narrowing down the root cause of a particularly common installation problem that affects the .NET Framework 3.0 and 3.5. However, there are several possible causes of installation failures in the .NET Framework, so that means that these steps will not work for all cases. If you do not see the specific types of entries in your log files, then the workaround in step 5 will likely not help, but steps 1 through 4 can still be helpful in finding the root cause.
I have posted about other possible causes of ServiceModelReg.exe custom action failures in the following blog post:
I also suggest consulting the .NET Framework setup troubleshooting guide for links to other possible installation issues and workarounds, links to log file locations, links to readme files, etc.
<update date="11/24/2008"> Added a link to a new blog post I wrote about another possible cause of ServiceModelReg.exe custom action failures in the .NET Framework 3.0 and 3.5. </update>
<update date="8/10/2009"> Added a suggestion to try installing the .NET Framework 3.5 SP1 as a possible workaround to this type of install failure. </update>
I believe you forgot SP1 somewhere.
"If the error occurs during .NET Framework 3.0 setup, the verbose log file that contains the error will be named %temp%\dd_wcf_retMSI*.txt in this case.
If the error occurs during .NET Framework 3.0 setup, the verbose log file that contains the error will be named %temp%\dd_NET_Framework30_Setup*.txt in this case."
Hi Tanveer - You are correct. I missed that when I was proof-reading the post yesterday. I will update the text of the post now. Thanks for letting me know.
I'm hitting this one today and I found that ServiceModelReg.exe was incurring a System.TypeLoadException during .NET 3.0 install (triggering a just-in-time debugger pop and probably Watson too).
I attached debugger and I see this failure:
0:000> !do 012687e0
Name: System.TypeLoadException
MethodTable: 791241c0
EEClass: 79124148
Size: 88(0x58) bytes
(E:\WINNT\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
Fields:
MT Field Offset Type VT Attr Value Name
...
790fd8c4 40000b8 10 System.String 0 instance 01268b0c _message
0:000> !do 01268b0c
Name: System.String
MethodTable: 790fd8c4
EEClass: 790fd824
Size: 578(0x242) bytes
String: Could not load type 'System.ServiceModel.Install.EventLogger' from assembly 'System.ServiceModel.Install, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
I found this issue has been reported to Watson in MessageBus#61220.
Issue is due to be mismatch between following binaries:
E:\WINNT\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe
And
E:\WINNT\assembly\GAC_MSIL\System.ServiceModel.Install\3.0.0.0__b77a5c561934e089\System.ServiceModel.Install.dll
What I did next was remove all 3.0.0 junk from gac:
gacutil /l | findstr Version=3.0.0.0 > c:\remove.txt
gacutil /ul c:\remove.txt
This left one remaining item:
E:\>gacutil /ul c:\remove2.txt
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.21022.8
Copyright (c) Microsoft Corporation. All rights reserved.
Assembly: Microsoft.VisualStudio.Diagnostics.ServiceModelSink, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, pr
ocessorArchitecture=MSIL
Unable to uninstall: assembly is required by one or more applications
Number of assemblies processed = 1
Number of assemblies uninstalled = 0
Number of failures = 1
For this one I had to remove registry key Microsoft.VisualStudio.Diagnostics.ServiceModelSink,version="3.0.0.0",publicKeyToken="b03f5f7f11d50a3a",fileVersion="9.0.21022.8",culture="neutral",processorArchitecture="MSIL" under HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Assemblies\Global, then re-run gacutil to remove it.
I did all of this, then re-ran .NET 3.0 installer and life was good.
Root cause in my case was old Beta versions of .NET 3.0 I suspect. I found .NET cleanup tool ignores these versions as well, I had to manually remove these using MSIZap.
Hi MattN - Thank you for posting about your experience with troubleshooting this issue. I have heard of some cases where there are TypeLoadExceptions being thrown due to assembly mismatches for System.ServiceModel.Install DLLs left behind from 3.0 beta versions. You're correct that the cleanup tool currently doesn't handle them, but that is something I will look to add to a future version of the cleanup tool.
One thing I'm not sure I understand though - the assembly Microsoft.VisualStudio.Diagnostics.ServiceModelSink is a Visual Studio assembly, not a .NET Framework assembly. I haven't previously heard of any conflicts related to assemblies not shipped within the .NET Framework installer packages. The cleanup tool only cleans up files that are installed by the .NET Framework, so I am not going to be adding any logic to cleanup that Visual Studio file. Are you sure that this assembly really caused any problems with .NET Framework installation on your system? Or were you just looking for anything in the GAC on your system that had ServiceModel or version 3.0.0.0 in the strong name?
Thanks MattN, I was getting the same error and the process you explained worked for me. I had to delete registry keys for 13 dlls before unregistering but afterward the installation worked!
Much appreciated.
Aaron, had very hard time to install 3.0, tried to cleanup, uninstall/reinstall IIS, check machine.cfg, unstalled virus checking, update net2.0 and 1.1 to full trust, still failing. The following is what is in event viewer
Thank you!
log1
============================================
System.IO.IOException: Unknown error "-1".
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at System.CodeDom.Compiler.TempFileCollection.EnsureTempNameCreated()
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension, Boolean keepFile)
at System.CodeDom.Compiler.TempFileCollection.AddExtension(String fileExtension)
at Microsoft.CSharp.CSharpCodeGenerator.FromSourceBatch(CompilerParameters options, String[] sources)
at Microsoft.CSharp.CSharpCodeGenerator.System.CodeDom.Compiler.ICodeCompiler.CompileAssemblyFromSourceBatch(CompilerParameters options, String[] sources)
at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromSource(CompilerParameters options, String[] sources)
at System.Xml.Serialization.Compiler.Compile(Assembly parent, String ns, XmlSerializerCompilerParameters xmlParameters, Evidence evidence)
at System.Xml.Serialization.TempAssembly.GenerateAssembly(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, Evidence evidence, XmlSerializerCompilerParameters parameters, Assembly assembly, Hashtable assemblies)
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location, Evidence evidence)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at System.ServiceModel.Install.Configuration.ConfigurationHandlersInstallComponent..ctor(ConfigurationLoader configLoader)
at System.ServiceModel.Install.Configuration.ConfigurationHandlersInstallComponent.CreateNativeConfigurationHandlersInstallComponent()
at Microsoft.Tools.ServiceModel.ServiceModelReg.BuildActionQueue()
at Microsoft.Tools.ServiceModel.ServiceModelReg.Run(String[] args)
at Microsoft.Tools.ServiceModel.ServiceModelReg.TryRun(String[] args)
==========================================
log2
An error occurred while creating the MSI-style log file at 'c:\Temp\temp\':
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at System.ServiceModel.Install.MsiStyleLogWriter..ctor(String logEntryPrefix)
Hi Forestever - It looks like the ServiceModelReg custom action is having trouble creating a temporary file on your system. There are a few cases where I've seen this happen in the past:
1. The %temp% directory is marked as compressed or encrypted
2. Some software is running that prevents programs from creating new files/folders in the %temp% directory. This can happen due to some overly aggressive anti-virus or anti-spyware software on the system.
I'd suggest checking to see if either of the above are causing issues on your system. If not, you may want to try to change the location of the %temp% directory on your system to see if that helps. To do that, you can use the following steps:
1. Click on the Start menu, choose Run, type sysdm.cpl and click OK
2. In the System Properties dialog, choose the Advanced tab, then click on the Environment Variables button
3. Find the TEMP and TMP user variables and change them to a different folder.
4. Click OK to close the dialogs
Hopefully one of these will help.
Great Post, much appreciated!
I followed your guides, ended up threw in 3.5 SP1 and everything seems successful.
Just wondering if I still need to re-install IIS snice I don't see it anywhere in Services.msc
Anyway, thanks a lot
Hi JackySzeto - It sounds like you didn't have IIS installed on your system in the first place, so in that case it is not necessary to install it.
One thing for others reading this post in the future - the .NET Framework 3.5 SP1 installs the .NET Framework 3.0 SP2 as a prerequisite behind the scenes. The .NET Framework 3.0 SP2 setup is configured to allow installation to complete even if the ServiceModelReg custom action fails. That means that you won't see the errors described in this blog post if you install the .NET Framework 3.5 SP1 on your system.
I have run into a few reports of .NET Framework 3.0 and 3.5 installation failures recently that have
I previously posted a couple of items about how to troubleshoot and work around issues in .NET Framework
More good articles on framework installation issues by Aaron Stebner are available than the ones related