1
Vote

Code\CodeUtilities.cs: VisualBasic ReferencedAssemblies, fixed paths issue

description

Hi.
 
http://publicdomain.codeplex.com/SourceControl/changeset/view/41779#308775
File: Code\CodeUtilities.cs:172-173
 
Problem:
compilerParameters.ReferencedAssemblies.Add(@"c:\windows\Microsoft.NET\Framework\v2.0.50727\System.dll"); compilerParameters.ReferencedAssemblies.Add(@"c:\windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll");   Paths are static, its not given that the Windows directory will always be C:\WINDOWS.
 
Possible solutions:
 
http://msdn.microsoft.com/en-us/library/system.environment.specialfolder(VS.71).aspx
with
http://msdn.microsoft.com/en-us/library/system.environment.getfolderpath(VS.71).aspx
 
string systemdir = Environment.GetFolderPath(Environment.SpecialFolder.System)
 
This will result in $windowsdir\System32. You can then check for the existense of the special files File.Exists() or check the parent directory:
 
systemdir += ".." + Path.DirectorySeparatorChar + "Microsoft.Net.....";
File.Exists(systemdir)
 
Or you can read the following registry key:
HKLM\SOFTWARE\Microsoft.NETFramework[REG_SZ:InstallRoot]
Which should return: C:\WINDOWS\Microsoft.NET\Framework\
 
Very practical library, if not directly used, then as reference.

comments