// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-#if NET_2_0
+
using System;
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.Specialized;
using System.Globalization;
using System.IO;
using System.Reflection;
if (asm == null)
throw new HttpException (String.Format ("Unable to find assembly {0}", assemblyName), error);
- assemblyCache.Add (assemblyName, asm.Location);
- return asm.Location;
+ string path = new Uri (asm.CodeBase).LocalPath;
+ assemblyCache.Add (assemblyName, path);
+ return path;
}
}
}
internal class AppCodeAssembly
{
- private List<string> files;
- private List<CodeCompileUnit> units;
+ List<string> files;
+ List<CodeCompileUnit> units;
- private string name;
- private string path;
- private bool validAssembly;
- private string outputAssemblyName;
+ string name;
+ string path;
+ bool validAssembly;
+ string outputAssemblyName;
public string OutputAssemblyName
{
}
CodeDomProvider provider = null;
- CompilationSection compilationSection = WebConfigurationManager.GetSection ("system.web/compilation") as CompilationSection;
+ CompilationSection compilationSection = WebConfigurationManager.GetWebApplicationSection ("system.web/compilation") as CompilationSection;
if (compilerInfo == null) {
if (!CodeDomProvider.IsDefinedLanguage (compilationSection.DefaultLanguage))
throw new HttpException ("Failed to retrieve default source language");
CompilerParameters parameters = compilerInfo.CreateDefaultCompilerParameters ();
parameters.IncludeDebugInformation = compilationSection.Debug;
- if (binAssemblies != null && binAssemblies.Length > 0)
- parameters.ReferencedAssemblies.AddRange (binAssemblies);
+ if (binAssemblies != null && binAssemblies.Length > 0) {
+ StringCollection parmRefAsm = parameters.ReferencedAssemblies;
+ foreach (string binAsm in binAssemblies) {
+ if (parmRefAsm.Contains (binAsm))
+ continue;
+
+ parmRefAsm.Add (binAsm);
+ }
+ }
if (compilationSection != null) {
foreach (AssemblyInfo ai in compilationSection.Assemblies)
}
}
- private string PhysicalToVirtual (string file)
+ VirtualPath PhysicalToVirtual (string file)
{
- return file.Replace (HttpRuntime.AppDomainAppPath, "/").Replace (Path.DirectorySeparatorChar, '/');
+ return new VirtualPath (file.Replace (HttpRuntime.AppDomainAppPath, "~/").Replace (Path.DirectorySeparatorChar, '/'));
}
- private BuildProvider GetBuildProviderFor (string file, BuildProviderCollection buildProviders)
+ BuildProvider GetBuildProviderFor (string file, BuildProviderCollection buildProviders)
{
if (file == null || file.Length == 0 || buildProviders == null || buildProviders.Count == 0)
return null;
- BuildProvider ret = buildProviders.GetProviderForExtension (Path.GetExtension (file));
+ BuildProvider ret = buildProviders.GetProviderInstanceForExtension (Path.GetExtension (file));
if (ret != null && IsCorrectBuilderType (ret)) {
ret.SetVirtualPath (PhysicalToVirtual (file));
return ret;
return null;
}
- private bool IsCorrectBuilderType (BuildProvider bp)
+ bool IsCorrectBuilderType (BuildProvider bp)
{
if (bp == null)
return false;
internal class AppCodeCompiler
{
- static private bool _alreadyCompiled;
+ static bool _alreadyCompiled;
internal static string DefaultAppCodeAssemblyName;
// A dictionary that contains an entry per an assembly that will
// Files for which exist BuildProviders but which have no
// unambiguous language assigned to them (e.g. .wsdl files), are
// built using the default website compiler.
- private List<AppCodeAssembly> assemblies;
+ List<AppCodeAssembly> assemblies;
string providerTypeName = null;
public AppCodeCompiler ()
bool ProcessAppCodeDir (string appCode, AppCodeAssembly defasm)
{
// First process the codeSubDirectories
- CompilationSection cs = (CompilationSection) WebConfigurationManager.GetSection ("system.web/compilation");
+ CompilationSection cs = (CompilationSection) WebConfigurationManager.GetWebApplicationSection ("system.web/compilation");
if (cs != null) {
string aname;
}
string baseType = ps.Inherits;
- bool baseIsGlobal = false;
- if (String.IsNullOrEmpty (baseType)) {
+ if (String.IsNullOrEmpty (baseType))
baseType = "System.Web.Profile.ProfileBase";
- baseIsGlobal = true;
+ else {
+ string[] parts = baseType.Split (new char[] {','});
+ if (parts.Length > 1)
+ baseType = parts [0].Trim ();
}
+ bool baseIsGlobal;
+ if (baseType.IndexOf ('.') != -1)
+ baseIsGlobal = true;
+ else
+ baseIsGlobal = false;
+
BuildProfileClass (ps, "ProfileCommon", props, ns, baseType, baseIsGlobal, groupProperties);
return true;
}
{
if (ps == null || !ps.Enabled)
return false;
- if (!String.IsNullOrEmpty (ps.Inherits) || (ps.PropertySettings != null && ps.PropertySettings.Count > 0))
+
+ RootProfilePropertySettingsCollection props = ps.PropertySettings;
+ ProfileGroupSettingsCollection groups = props != null ? props.GroupSettings : null;
+
+ if (!String.IsNullOrEmpty (ps.Inherits) || (props != null && props.Count > 0) || (groups != null && groups.Count > 0))
return true;
return false;
return;
string appCode = Path.Combine (HttpRuntime.AppDomainAppPath, "App_Code");
- ProfileSection ps = WebConfigurationManager.GetSection ("system.web/profile") as ProfileSection;
+ ProfileSection ps = WebConfigurationManager.GetWebApplicationSection ("system.web/profile") as ProfileSection;
bool haveAppCodeDir = Directory.Exists (appCode);
bool haveCustomProfile = HaveCustomProfile (ps);
} else
return;
- if (HttpApplication.LoadTypeFromBin (providerTypeName) == null)
- throw new HttpException (String.Format ("Profile provider type not found: {0}",
- providerTypeName));
+ Exception noTypeException = null;
+ Type ptype = null;
+
+ try {
+ ptype = HttpApplication.LoadTypeFromBin (providerTypeName);
+ } catch (Exception ex) {
+ noTypeException = ex;
+ }
+
+ if (ptype == null)
+ throw new HttpException (String.Format ("Profile provider type not found: {0}", providerTypeName), noTypeException);
}
}
tmi = type.GetMethod ("AppInitialize",
BindingFlags.Public | BindingFlags.Static | BindingFlags.IgnoreCase,
null,
- new Type[0],
+ Type.EmptyTypes,
null);
if (tmi == null)
continue;
mi.Invoke (null, null);
}
- private bool CollectFiles (string dir, AppCodeAssembly aca)
+ bool CollectFiles (string dir, AppCodeAssembly aca)
{
bool haveFiles = false;
}
}
}
-#endif
+