/// <summary> /// Get the cache dependency for an embedded resource /// </summary> /// <param name="virtualPath">The virtual path to the file</param> /// <param name="virtualPathDependencies">The virtual path dependencies associated with the cache dependency</param> /// <param name="utcStart">The start date</param> /// <returns>The cache dependency</returns> public override CacheDependency GetCacheDependency(string virtualPath, IEnumerable virtualPathDependencies, DateTime utcStart) { // Find the resource and return its cache dependency var resource = new EmbeddedResource(virtualPath); return resource.CacheDependency(utcStart); }
private Template GetTemplate(EmbeddedResource resource) { Func<TextReader> getContentReader = () => new StreamReader(resource.Assembly.GetManifestResourceStream(resource.GetResourceName())); return new Template(resource.GetViewName(), resource.GetPath(), ".", findModelFromViewCollection.FindModelType(getContentReader(), resource.GetViewName()), getContentReader); }
void HandleItem(EmbeddedResource eres) { this.eres = eres; Attributes.Bind(eres); HexEditorControl.Bind(eres); }
void PackModules(ConfuserContext context, CompressorContext compCtx, ModuleDef stubModule, ICompressionService comp, RandomGenerator random) { int maxLen = 0; var modules = new Dictionary <string, byte[]>(); for (int i = 0; i < context.OutputModules.Count; i++) { if (i == compCtx.ModuleIndex) { continue; } string id = GetId(context.Modules[i].Assembly); modules.Add(id, context.OutputModules[i]); int strLen = Encoding.UTF8.GetByteCount(id); if (strLen > maxLen) { maxLen = strLen; } } foreach (var extModule in context.ExternalModules) { var name = GetId(extModule).ToUpperInvariant(); modules.Add(name, extModule); int strLen = Encoding.UTF8.GetByteCount(name); if (strLen > maxLen) { maxLen = strLen; } } byte[] key = random.NextBytes(4 + maxLen); key[0] = (byte)(compCtx.EntryPointToken >> 0); key[1] = (byte)(compCtx.EntryPointToken >> 8); key[2] = (byte)(compCtx.EntryPointToken >> 16); key[3] = (byte)(compCtx.EntryPointToken >> 24); for (int i = 4; i < key.Length; i++) // no zero bytes { key[i] |= 1; } compCtx.KeySig = key; int moduleIndex = 0; foreach (var entry in modules) { byte[] name = Encoding.UTF8.GetBytes(entry.Key); for (int i = 0; i < name.Length; i++) { name[i] *= key[i + 4]; } uint state = 0x6fff61; foreach (byte chr in name) { state = state * 0x5e3f1f + chr; } byte[] encrypted = compCtx.Encrypt(comp, entry.Value, state, progress => { progress = (progress + moduleIndex) / modules.Count; context.Logger.Progress((int)(progress * 10000), 10000); }); context.CheckCancellation(); var resource = new EmbeddedResource(Convert.ToBase64String(name), encrypted, ManifestResourceAttributes.Private); stubModule.Resources.Add(resource); moduleIndex++; } context.Logger.EndProgress(); }
void DumpEmbeddedFile(EmbeddedResource resource, string assemblyName, string extension, string reason) { DeobfuscatedFile.CreateAssemblyFile(resourceDecrypter.Decrypt(resource.GetResourceStream()), Utils.GetAssemblySimpleName(assemblyName), extension); AddResourceToBeRemoved(resource, reason); }
public void Find() { resource = FindCsvmResource(); vmAssemblyRef = FindVmAssemblyRef(); }
static PowerShellBootstrapper() { BootstrapScriptTemplate = EmbeddedResource.ReadEmbeddedText(typeof(PowerShellBootstrapper).Namespace + ".Bootstrap.ps1"); DebugBootstrapScriptTemplate = EmbeddedResource.ReadEmbeddedText(typeof(PowerShellBootstrapper).Namespace + ".DebugBootstrap.ps1"); }
static LinkAttributesParser GetExternalLinkAttributesParser(LinkContext context, EmbeddedResource resource, AssemblyDefinition assembly) { return(new LinkAttributesParser(context, GetExternalDescriptor(resource), resource, assembly, "resource " + resource.Name + " in " + assembly.FullName)); }
void SendEmbeddedResource (HttpContext context, out EmbeddedResource res, out Assembly assembly) { HttpRequest request = context.Request; NameValueCollection queryString = request.QueryString; // val is URL-encoded, which means every + has been replaced with ' ', we // need to revert that or the base64 conversion will fail. string d = queryString ["d"]; if (!String.IsNullOrEmpty (d)) d = d.Replace (' ', '+'); AssemblyEmbeddedResources entry; res = DecryptAssemblyResource (d, out entry); WebResourceAttribute wra = res != null ? res.Attribute : null; if (wra == null) throw new HttpException (404, "Resource not found"); if (entry.AssemblyName == "s") assembly = currAsm; else assembly = Assembly.Load (entry.AssemblyName); DateTime modified; if (HasIfModifiedSince (request, out modified)) { if (File.GetLastWriteTimeUtc (assembly.Location) <= modified) { RespondWithNotModified (context); return; } } HttpResponse response = context.Response; response.ContentType = wra.ContentType; DateTime utcnow = DateTime.UtcNow; response.Headers.Add ("Last-Modified", utcnow.ToString ("r")); response.ExpiresAbsolute = utcnow.AddYears (1); response.CacheControl = "public"; Stream s = assembly.GetManifestResourceStream (res.Name); if (s == null) throw new HttpException (404, "Resource " + res.Name + " not found"); if (wra.PerformSubstitution) { using (StreamReader r = new StreamReader (s)) { TextWriter w = response.Output; new PerformSubstitutionHelper (assembly).PerformSubstitution (r, w); } } else if (response.OutputStream is HttpResponseStream) { UnmanagedMemoryStream st = (UnmanagedMemoryStream) s; HttpResponseStream hstream = (HttpResponseStream) response.OutputStream; unsafe { hstream.WritePtr (new IntPtr (st.PositionPointer), (int) st.Length); } } else { byte [] buf = new byte [1024]; Stream output = response.OutputStream; int c; do { c = s.Read (buf, 0, 1024); output.Write (buf, 0, c); } while (c > 0); } }
bool GenerateEXaml(TypeDefinition typeDef, EmbeddedResource resource, out IList <Exception> thrownExceptions) { thrownExceptions = null; ModuleDefinition module = typeDef.Module; CustomAttribute xamlFilePathAttr; var xamlFilePath = typeDef.HasCustomAttributes && (xamlFilePathAttr = typeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "Tizen.NUI.Xaml.XamlFilePathAttribute")) != null ? (string)xamlFilePathAttr.ConstructorArguments[0].Value : resource.Name; LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Parsing Xaml"); var rootnode = ParseXaml(resource.GetResourceStream(), typeDef); if (rootnode == null) { LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}failed."); return(false); } LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done."); hasCompiledXamlResources = true; LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Replacing {0}.InitializeComponent ()"); Exception e; var embeddedResourceNameSpace = GetNameSpaceOfResource(resource); var visitorContext = new EXamlContext(typeDef, typeDef.Module, embeddedResourceNameSpace); if (!TryCoreCompile(rootnode, visitorContext, out e)) { LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}failed."); (thrownExceptions = thrownExceptions ?? new List <Exception>()).Add(e); if (e is XamlParseException xpe) { LoggingHelper.LogError(null, null, null, xamlFilePath, xpe.XmlInfo.LineNumber, xpe.XmlInfo.LinePosition, 0, 0, xpe.Message, xpe.HelpLink, xpe.Source); } else if (e is XmlException xe) { LoggingHelper.LogError(null, null, null, xamlFilePath, xe.LineNumber, xe.LinePosition, 0, 0, xe.Message, xe.HelpLink, xe.Source); } else { LoggingHelper.LogError(null, null, null, xamlFilePath, 0, 0, 0, 0, e.Message, e.HelpLink, e.Source); } if (null != e.StackTrace) { LoggingHelper.LogError(e.StackTrace); } return(false); } else { var examlDir = outputRootPath + @"res/examl/"; if (Directory.Exists(examlDir)) { Directory.CreateDirectory(examlDir); } var examlFilePath = examlDir + typeDef.FullName + ".examl"; EXamlOperation.WriteOpertions(examlFilePath, visitorContext); } return(true); }
bool DoInjection(TypeDefinition typeDef, EmbeddedResource resource, out IList <Exception> thrownExceptions) { thrownExceptions = null; var initComp = typeDef.Methods.FirstOrDefault(md => md.Name == "InitializeComponent"); if (initComp == null) { LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}no InitializeComponent found... skipped."); return(false); } CustomAttribute xamlFilePathAttr; var xamlFilePath = typeDef.HasCustomAttributes && (xamlFilePathAttr = typeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "Tizen.NUI.Xaml.XamlFilePathAttribute")) != null ? (string)xamlFilePathAttr.ConstructorArguments[0].Value : resource.Name; var initCompRuntime = typeDef.Methods.FirstOrDefault(md => md.Name == "__InitComponentRuntime"); if (initCompRuntime != null) { LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}__InitComponentRuntime already exists... not creating"); } else { LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Creating empty {typeDef.Name}.__InitComponentRuntime"); initCompRuntime = new MethodDefinition("__InitComponentRuntime", initComp.Attributes, initComp.ReturnType); initCompRuntime.Body.InitLocals = true; LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done."); LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Copying body of InitializeComponent to __InitComponentRuntime"); initCompRuntime.Body = new MethodBody(initCompRuntime); var iCRIl = initCompRuntime.Body.GetILProcessor(); foreach (var instr in initComp.Body.Instructions) { iCRIl.Append(instr); } initComp.Body.Instructions.Clear(); initComp.Body.GetILProcessor().Emit(OpCodes.Ret); initComp.Body.InitLocals = true; typeDef.Methods.Add(initCompRuntime); LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done."); } LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Parsing Xaml"); var rootnode = ParseXaml(resource.GetResourceStream(), typeDef); if (rootnode == null) { LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}failed."); return(false); } LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done."); hasCompiledXamlResources = true; LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Replacing {0}.InitializeComponent ()"); Exception e; var embeddedResourceNameSpace = GetNameSpaceOfResource(resource); if (!TryCoreCompile(initComp, rootnode, embeddedResourceNameSpace, out e)) { LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}failed."); (thrownExceptions = thrownExceptions ?? new List <Exception>()).Add(e); if (e is XamlParseException xpe) { LoggingHelper.LogError(null, null, null, xamlFilePath, xpe.XmlInfo.LineNumber, xpe.XmlInfo.LinePosition, 0, 0, xpe.Message, xpe.HelpLink, xpe.Source); } else if (e is XmlException xe) { LoggingHelper.LogError(null, null, null, xamlFilePath, xe.LineNumber, xe.LinePosition, 0, 0, xe.Message, xe.HelpLink, xe.Source); } else { LoggingHelper.LogError(null, null, null, xamlFilePath, 0, 0, 0, 0, e.Message, e.HelpLink, e.Source); } if (null != e.StackTrace) { LoggingHelper.LogMessage(Low, e.StackTrace); } return(false); } if (Type != null) { InitCompForType = initComp; } LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done."); if (OptimizeIL) { LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Optimizing IL"); initComp.Body.Optimize(); LoggingHelper.LogMessage(Low, $"{new string(' ', 8)}done."); } #pragma warning disable 0618 if (OutputGeneratedILAsCode) { LoggingHelper.LogMessage(Low, $"{new string(' ', 6)}Decompiling option has been removed. Use a 3rd party decompiler to admire the beauty of the IL generated"); } #pragma warning restore 0618 return(true); }
static ResolveFromXmlStep GetExternalResolveStep(EmbeddedResource resource, AssemblyDefinition assembly) { return(new ResolveFromXmlStep(GetExternalDescriptor(resource), "resource " + resource.Name + " in " + assembly.FullName)); }
/// <summary> /// Arrange the input flat file contents from an embedded resource in the given assembly. /// </summary> /// <param name="assembly">The assembly that contains the resource.</param> /// <param name="resourceName">The name of the resource.</param> public void ArrangeInputFlatFileContents(Assembly assembly, string resourceName) { this.ArrangeInputFlatFileContents(EmbeddedResource.GetAsString(assembly, resourceName)); }
private void EmbeddResources(Dictionary <BridgeResourceInfo, byte[]> resourcesToEmbed) { this.Log.Trace("Embedding resources..."); var assemblyDef = this.AssemblyDefinition; var resources = assemblyDef.MainModule.Resources; var configHelper = new ConfigHelper(); foreach (var item in resourcesToEmbed) { var r = item.Key; this.Log.Trace("Embedding resource " + r.Name); // No resource name normalization //var name = this.NormalizePath(r.Name); //this.Log.Trace("Normalized resource name " + name); var name = r.Name; // Normalize resourse output path to always have '/' as a directory separator r.Path = configHelper.ConvertPath(r.Path, '/'); var newResource = new EmbeddedResource(name, ManifestResourceAttributes.Private, item.Value); var existingResource = resources.FirstOrDefault(x => x.Name == name); if (existingResource != null) { this.Log.Trace("Removing already existed resource with the same name"); resources.Remove(existingResource); } resources.Add(newResource); this.Log.Trace("Added resource " + name); } CheckIfResourceExistsAndRemove(resources, Translator.BridgeResourcesPlusSeparatedFormatList); var resourceListName = Translator.BridgeResourcesJsonFormatList; CheckIfResourceExistsAndRemove(resources, resourceListName); var listArray = resourcesToEmbed.Keys.ToArray(); var listContent = Newtonsoft.Json.JsonConvert.SerializeObject(listArray, Newtonsoft.Json.Formatting.Indented); var listResources = new EmbeddedResource(resourceListName, ManifestResourceAttributes.Private, Translator.OutputEncoding.GetBytes(listContent)); resources.Add(listResources); this.Log.Trace("Added resource list " + resourceListName); this.Log.Trace(listContent); // Checking if mscorlib reference added and removing if added var mscorlib = assemblyDef.MainModule.AssemblyReferences.FirstOrDefault(r => r.Name == "mscorlib"); if (mscorlib != null) { this.Log.Trace("Removing mscorlib reference"); assemblyDef.MainModule.AssemblyReferences.Remove(mscorlib); } var assemblyLocation = this.AssemblyLocation; this.Log.Trace("Writing resources into " + assemblyLocation); assemblyDef.Write(assemblyLocation); this.Log.Trace("Wrote resources into " + assemblyLocation); this.Log.Trace("Done embedding resources"); }
private Dictionary<string, EmbeddedResource> CreateDict() { var dict = new Dictionary<string, EmbeddedResource>(StringComparer.InvariantCultureIgnoreCase); foreach (var assembly in _assemblies) { foreach (var resourceName in assembly.GetManifestResourceNames()) { if (IsValidResource(resourceName)) { var embeddedResource = new EmbeddedResource(assembly, resourceName); // split name into bits separated by periods var nameParts = resourceName.Split('.'); var fileName = nameParts[nameParts.Length - 2] + "." + nameParts[nameParts.Length - 1]; dict[fileName] = embeddedResource; // TODO: add alternatives that include the rest of the path } } } return dict; }
public ResourceInfo(EmbeddedResource resource, string name) { this.resource = resource; this.name = name; }
public ResourcesFileTreeNode(EmbeddedResource er) : base(er) { this.LazyLoading = true; }
static FSharpBootstrapper() { BootstrapScriptTemplate = EmbeddedResource.ReadEmbeddedText(typeof(FSharpBootstrapper).Namespace + ".Bootstrap.fsx"); }
static BodySubstitutionParser GetExternalSubstitutionParser(LinkContext context, EmbeddedResource resource, AssemblyDefinition assembly) { return(new BodySubstitutionParser(context, GetExternalDescriptor(resource), resource, assembly, "resource " + resource.Name + " in " + assembly.FullName)); }
protected static byte[] decryptResourceV3(EmbeddedResource resource) { return(decryptResourceV3(resource.GetResourceData())); }
static XPathDocument GetExternalDescriptor(EmbeddedResource resource) { using (var sr = new StreamReader(resource.GetResourceStream())) { return(new XPathDocument(sr)); } }
public WrappedResource(AssemblyDefinition asm, EmbeddedResource res) { _asm = asm; _res = res; }
public byte[] Decrypt(EmbeddedResource resource) { return(DeobUtils.AesDecrypt(resource.GetResourceData(), key, iv)); }
bool CheckMethod(MethodDef method) { if (method == null || method.Body == null) { return(false); } if (!DotNetUtils.CallsMethod(method, "System.Void System.AppDomain::add_ResourceResolve(System.ResolveEventHandler)")) { return(false); } simpleDeobfuscator.Deobfuscate(method, SimpleDeobfuscatorFlags.Force | SimpleDeobfuscatorFlags.DisableConstantsFolderExtraInstrs); fields.Clear(); var tmpHandler = GetHandler(method); if (tmpHandler == null || tmpHandler.DeclaringType != method.DeclaringType) { return(false); } var tmpResource = FindResource(tmpHandler); if (tmpResource == null) { return(false); } simpleDeobfuscator.Deobfuscate(tmpHandler, SimpleDeobfuscatorFlags.Force | SimpleDeobfuscatorFlags.DisableConstantsFolderExtraInstrs); var tmpVersion = ConfuserVersion.Unknown; if (DotNetUtils.CallsMethod(tmpHandler, "System.Object System.AppDomain::GetData(System.String)")) { if (!DotNetUtils.CallsMethod(tmpHandler, "System.Void System.Buffer::BlockCopy(System.Array,System.Int32,System.Array,System.Int32,System.Int32)")) { if (!FindKey0Key1_v14_r55802(tmpHandler, out key0, out key1)) { return(false); } tmpVersion = ConfuserVersion.v14_r55802; } else if (FindKey0_v17_r73404(tmpHandler, out key0) && FindKey1_v17_r73404(tmpHandler, out key1)) { tmpVersion = ConfuserVersion.v17_r73404; } else { return(false); } } else { if (AddFields(FindFields(tmpHandler, method.DeclaringType)) != 1) { return(false); } if (FindKey0_v17_r73404(tmpHandler, out key0) && FindKey1_v17_r73404(tmpHandler, out key1)) { tmpVersion = ConfuserVersion.v17_r73822; } else if (FindKey0_v18_r75367(tmpHandler, out key0) && FindKey1_v17_r73404(tmpHandler, out key1)) { tmpVersion = ConfuserVersion.v18_r75367; } else if (FindKey0_v18_r75369(tmpHandler, out key0) && FindKey1_v18_r75369(tmpHandler, out key1)) { lzmaType = ConfuserUtils.FindLzmaType(tmpHandler); if (lzmaType == null) { tmpVersion = ConfuserVersion.v18_r75369; } else { tmpVersion = ConfuserVersion.v19_r77172; } } else { return(false); } } handler = tmpHandler; resource = tmpResource; installMethod = method; version = tmpVersion; return(true); }
bool FindResource(MethodDef method) { encryptedResource = FindResourceFromCodeString(method) ?? FindResourceFromStringBuilder(method); return(encryptedResource != null); }
/// <summary> /// Bind a resource to this control /// </summary> /// <param name="res">Resource to bind</param> public override void Bind(EmbeddedResource res) { base.Bind(res); }
public AssemblyInfo(string assemblyName, EmbeddedResource resource, EmbeddedResource symbolsResource) { this.assemblyName = assemblyName; this.resource = resource; this.symbolsResource = symbolsResource; }
private static string LoadCodeFromResource(string resourceName) { return(EmbeddedResource.ReadAllText(typeof(ExecutionTests), "TestCode.Execution." + resourceName)); }
static BashScriptBootstrapper() { BootstrapScriptTemplate = EmbeddedResource.ReadEmbeddedText(typeof(BashScriptBootstrapper).Namespace + ".Bootstrap.sh"); }
public ImageResourceNode(ITreeNodeGroup treeNodeGroup, EmbeddedResource resource) : base(treeNodeGroup, resource) { this.imageData = resource.GetResourceData(); this.imageSource = ImageResourceUtils.CreateImageSource(this.imageData); }
private void GenerateAttribute(GeneratorExecutionContext context) { var attributeSource = EmbeddedResource.GetContent(@"resources/WrapperValueObjectAttribute.cs"); context.AddSource("WrapperValueObjectAttribute.cs", SourceText.From(attributeSource, Encoding.UTF8)); }
static ScriptCSBootstrapper() { BootstrapScriptTemplate = EmbeddedResource.ReadEmbeddedText(typeof(ScriptCSBootstrapper).Namespace + ".Bootstrap.csx"); }
public ImageResourceNodeImpl(ITreeNodeGroup treeNodeGroup, EmbeddedResource resource) : base(treeNodeGroup, resource) { imageData = resource.CreateReader().ToArray(); imageSource = ImageResourceUtilities.CreateImageSource(imageData); }
static DescriptorMarker GetExternalResolveStep(LinkContext context, EmbeddedResource resource, AssemblyDefinition assembly) { return(new DescriptorMarker(context, GetExternalDescriptor(resource), resource, assembly, "resource " + resource.Name + " in " + assembly.FullName)); }
static void InitEmbeddedResourcesUrls (KeyedHashAlgorithm kha, Assembly assembly, string assemblyName, string assemblyHash, AssemblyEmbeddedResources entry) { WebResourceAttribute [] attrs = (WebResourceAttribute []) assembly.GetCustomAttributes (typeof (WebResourceAttribute), false); WebResourceAttribute attr; string apath = assembly.Location; for (int i = 0; i < attrs.Length; i++) { attr = attrs [i]; string resourceName = attr.WebResource; if (!String.IsNullOrEmpty (resourceName)) { string resourceNameHash = GetStringHash (kha, resourceName); #if SYSTEM_WEB_EXTENSIONS bool debug = resourceName.EndsWith (".debug.js", StringComparison.OrdinalIgnoreCase); string dbgTail = debug ? "d" : String.Empty; string rkNoNotify = resourceNameHash + "f" + dbgTail; string rkNotify = resourceNameHash + "t" + dbgTail; if (!entry.Resources.ContainsKey (rkNoNotify)) { var er = new EmbeddedResource () { Name = resourceName, Attribute = attr, Url = CreateResourceUrl (kha, assemblyName, assemblyHash, apath, rkNoNotify, debug, false) }; entry.Resources.Add (rkNoNotify, er); } if (!entry.Resources.ContainsKey (rkNotify)) { var er = new EmbeddedResource () { Name = resourceName, Attribute = attr, Url = CreateResourceUrl (kha, assemblyName, assemblyHash, apath, rkNotify, debug, true) }; entry.Resources.Add (rkNotify, er); } #else if (!entry.Resources.ContainsKey (resourceNameHash)) { var er = new EmbeddedResource () { Name = resourceName, Attribute = attr, Url = CreateResourceUrl (kha, assemblyName, assemblyHash, apath, resourceNameHash, false, false) }; entry.Resources.Add (resourceNameHash, er); } #endif } } }
/// <summary> /// Reads the configuration settings from disk /// </summary> /// <returns>The configuration settings for Pattern Lab</returns> public IniData Config() { // Return cached value if set if (_config != null) return _config; // Configure the INI parser to handler the comments in the Pattern Lab config file var parser = new FileIniDataParser(); parser.Parser.Configuration.AllowKeysWithoutSection = true; parser.Parser.Configuration.SkipInvalidLines = true; var path = Path.Combine(HttpRuntime.AppDomainAppPath, FilePathConfig); if (!File.Exists(path)) { // If the config doesn't exist create a new version var virtualPath = string.Format("~/{0}", FilePathConfig); var defaultConfig = new EmbeddedResource(string.Format("{0}.default", virtualPath)); var version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); Builder.CreateFile(virtualPath, defaultConfig.ReadAllText().Replace("$version$", version), null, new DirectoryInfo(HttpRuntime.AppDomainAppPath)); } // Read the contents of the config file into a read-only stream using ( var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { _config = parser.ReadData(new StreamReader(stream)); } return _config; }