possible x64 problem?


when I execute the program on x64 Vista or Server 2003 I get an error, that there is a nullreference exception in the main method :-(

file attachments


Echo wrote Dec 15, 2007 at 1:49 PM

Nope. Not a x64 problem.
The registry does not contain the value "InstallDir" at the specified location.

richfinn wrote Dec 17, 2007 at 10:12 PM

Sorry Rene. I don't have access to an x64 machine, so I wasn't able to test the template on that platform. However, this error occurs when executing the InstallMOSSSolutionBuilder EXE, which can be worked around by hand.

1) Create a new folder named 'SharePoint_RF' at C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates (or wherever you have VS installed)

2) Copy c:\createddf\MOSS Solution Builder Project.zip file to this new directory.

3) From a command line, execute C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe /installvstemplates
This will install the template into the Visual Studio IDE
4) If you have Visual Studio open, close it and reopen to see the template in the project template list.

wrote Dec 17, 2007 at 10:13 PM

wrote Dec 17, 2007 at 10:19 PM

Echo wrote Dec 18, 2007 at 4:31 PM

5) It is working :-)


wrote Dec 19, 2007 at 2:37 PM

KubuS wrote Jan 26, 2008 at 9:51 PM

It is a x64 problem - registry paths are different for x32 programs on x64 machines.
There is a special node/key Wow6432Node under Software node.

On 64-bit system, when checking for vs2008 vs. vs2005 you assumed that (when vs2008 is detected) the path would be: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0
while in reality it is: HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0

some code to be precise (from InstallWSPBuilder.Program.cs):
if (installFor2008)
vsRegInstallPath = "SOFTWARE\\Microsoft\\VisualStudio\\9.0";
vsRegInstallPath = "SOFTWARE\\Microsoft\\VisualStudio\\8.0";
(... some code cut out from the original, mainly Console.WriteLine() statements ...)

RegistryKey vsInstallkey = Registry.LocalMachine.OpenSubKey(vsRegInstallPath);
string vsInstallPath = vsInstallkey.GetValue("InstallDir") as string; <=== this line throws a NullReferrenceException as there is no "InstallDir" registry key there.

A general fix would be to test:
a) version of the Visual Studio (8.0, 9.0, 10.0 etc.)
b) bitness of the system (32 vs. 64)
c) bitness of the Visual Studio - if it is native 64-bit (vs10.0 will be) original path like HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0 would be correct, again :)

to sum up, in general:
  • on 32-bit systems (there can only be 32-bit software) the key is HKEY_LOCAL_MACHINE\SOFTWARE\Some_32_Bit_Software_Name
  • on 64-bit systems (64-bit software) the key is still HKEY_LOCAL_MACHINE\SOFTWARE\Some_64_Bit_Software_Name
  • on 64-bit systems (32-bit software) the key is HKEY_LOCAL_MACHINE\Wow6432Node\SOFTWARE\Some_32_Bit_Software_Name
Hope this helps :)

KubuS wrote Jan 27, 2008 at 11:05 PM

In order to help even more I've decided to rewrite the installer as a WinForms application adding some functionality ;)

Added functionality:
  • OS bitness detection
  • OS bitness aware registry scanning
  • easy extensibility with Enums for future versions of Visual Studio
  • error checking with friendly messages in case of exceptions
  • support for installation under Vista UAC (took me more than 1 day to get it right ;)
OS: Windows XP or higher (32-bit/64-bit)
.NET: v3.5 (LINQ technology used)

The logic behind original Installer was not changed, only some portions of the code were refactored to be more manageble/extensible.

wrote Jan 27, 2008 at 11:05 PM

KubuS wrote Jan 27, 2008 at 11:08 PM

And here is the source project.

Note: In post build events (and embedManifest.bat file) paths to mt.exe and sn.exe might be diffrent on other systems. Please check them before recompilation.

Source code inside the attachment.

wrote Jan 27, 2008 at 11:08 PM

wrote Feb 13, 2013 at 1:58 AM

wrote May 14, 2013 at 3:55 AM

wrote May 14, 2013 at 3:55 AM

wrote Jun 11, 2013 at 12:06 AM