Determining the path to the .NET framework

  • Thread starter Thread starter andreas.baus
  • Start date Start date
A

andreas.baus

Is there a canonical way to determine the path to the folder where the
runtime environment is installed? The reason I am asking is that I have
created a small Office Add-In in C# which needs to be registered as a
COM component using regasm.exe during installation. So I need a way for
the install script (the Add-In is only a part of a larger project which
does not use the default Microsoft installer) to find the regasm, since
it is not in the path by default.
 
Unfortunately that won't work in the scripting language of the setup
utility, unless I can write a small .NET executable to call during the
installation process which returns the result of the call to me. I was
hoping there was a way to get this value from the registry, for example.
 
I don't know of an officially documented one, but

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework

has a value named InstallRoot that gives you the framework's root directory
(without the version number).

Usually this value is "C:\WINDOWS\Microsoft.NET\Framework\"

This seems to be consistent with v1.1 and v2.0, however, you still need the
version dependent part of the path.

On my v2.0 VPC, there is a subkey with the v2 version number, however this
is not consistent with v1.1.

HTH
 
Back
Top