Exemplo n.º 1
0
        static string GetPrecompiledVirtualPath(string asmPath)
        {
            string compiledFile = Path.ChangeExtension(asmPath, ".compiled");

            if (!File.Exists(compiledFile))
            {
                return(null);
            }

            var    pfile       = new PreservationFile(compiledFile);
            string virtualPath = pfile.VirtualPath;

            if (String.IsNullOrEmpty(virtualPath))
            {
                return("/");
            }

            if (virtualPath.EndsWith("/App_LocalResources/", StringComparison.OrdinalIgnoreCase))
            {
                virtualPath = virtualPath.Substring(0, virtualPath.Length - 19);
            }

            return(virtualPath);
        }
Exemplo n.º 2
0
		static Assembly ResolveAssemblyHandler(object sender, ResolveEventArgs e)
		{
			AssemblyName an = new AssemblyName (e.Name);
			string dynamic_base = AppDomain.CurrentDomain.SetupInformation.DynamicBase;
			string compiled = Path.Combine (dynamic_base, an.Name + ".compiled");
			string asmPath;

			if (!File.Exists (compiled)) {
				string fn = an.FullName;
				if (!RegisteredAssemblies.Find ((uint)fn.GetHashCode (), fn, out asmPath))
					return null;
			} else {
				PreservationFile pf;
				try {
					pf = new PreservationFile (compiled);
				} catch (Exception ex) {
					throw new HttpException (
						String.Format ("Failed to read preservation file {0}", an.Name + ".compiled"),
						ex);
				}
				asmPath = Path.Combine (dynamic_base, pf.Assembly + ".dll");
			}

			if (String.IsNullOrEmpty (asmPath))
				return null;
			
			Assembly ret = null;
			try {
				ret = Assembly.LoadFrom (asmPath);
			} catch (Exception) {
				// ignore
			}
			
			return ret;
		}
Exemplo n.º 3
0
		static internal void WritePreservationFile (Assembly asm, string genericNameBase)
		{
			if (asm == null)
				throw new ArgumentNullException ("asm");
			if (String.IsNullOrEmpty (genericNameBase))
				throw new ArgumentNullException ("genericNameBase");

			string compiled = Path.Combine (AppDomain.CurrentDomain.SetupInformation.DynamicBase,
							genericNameBase + ".compiled");
			PreservationFile pf = new PreservationFile ();
			try {
				pf.VirtualPath = String.Concat ("/", genericNameBase, "/");

				AssemblyName an = asm.GetName ();
				pf.Assembly = an.Name;
				pf.ResultType = BuildResultTypeCode.TopLevelAssembly;
				pf.Save (compiled);
			} catch (Exception ex) {
				throw new HttpException (
					String.Format ("Failed to write preservation file {0}", genericNameBase + ".compiled"),
					ex);
			}
		}
		static string GetPrecompiledVirtualPath (string asmPath)
		{
			string compiledFile = Path.ChangeExtension (asmPath, ".compiled");
			
			if (!File.Exists (compiledFile))
				return null;

			var pfile = new PreservationFile (compiledFile);
			string virtualPath = pfile.VirtualPath;
			if (String.IsNullOrEmpty (virtualPath))
				return "/";

			if (virtualPath.EndsWith ("/App_LocalResources/", StringComparison.OrdinalIgnoreCase))
				virtualPath = virtualPath.Substring (0, virtualPath.Length - 19);
			
			return virtualPath;
		}