Per Malmberg - 504 - Jan 7, 2014

Hello,

VirtualFS and obfuscation doesn’t seem to like eachother. I compiled my project in release mode and when obfuscation is applied (works fine without) I get this exception:

System.IO.FileNotFoundException: Virtual file not found
File name: ‘WebAPI.188ad0c5e6484a3c80af16975f5536c7’
   at ServiceStack.VirtualPath.ResourceVirtualDirectory.CreateVirtualFile(String resourceName)
   at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext()<br>&nbsp; &nbsp;at System.Linq.Buffer1…ctor(IEnumerable1 source)<br>&nbsp; &nbsp;at System.Linq.OrderedEnumerable1.<GetEnumerator>d__0.MoveNext()
   at System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1 collection)
   at ServiceStack.VirtualPath.ResourceVirtualDirectory.InitializeDirectoryStructure(IEnumerable1 manifestResourceNames)<br>&nbsp; &nbsp;at ServiceStack.VirtualPath.ResourceVirtualPathProvider.Initialize()<br>&nbsp; &nbsp;at ServiceStack.ServiceStackHost.&lt;Init&gt;b__4(Assembly x)<br>&nbsp; &nbsp;at ServiceStack.EnumerableExtensions.Map[To,From](IEnumerable1 items, Func`2 converter)
   at ServiceStack.ServiceStackHost.Init()
   at BeyondMeasure.WebAPI.WebAPI.Init()

Now, if do Config.EmbeddedResourceSources.Clear(), the error goes away, but what exactly am I loosing and how did my assembly end up among those resources anyway?

Per Malmberg:

These are the obfuscation options used.
[assembly: Obfuscation( Feature = “encrypt symbol names with password mypassword”, Exclude = false )]
[assembly: Obfuscation( Feature = “code control flow obfuscation”, Exclude = false )]
[assembly: Obfuscation( Feature = “PEVerify”, Exclude = false )]

The EmbeddedResourceSources holds ServiceStack.dll which is needed for the Metadata pages and HTML format pages, so it’s a good idea to leave ServiceStack.dll in there, which you can re-add after clearing with:

Config.EmbeddedResourceSources.Add(typeof(ServiceStack.Service).Assembly);

Maybe I can prevent this exception, how did you add obfuscation?

Per Malmberg:

I’m using Eazfuscator, I can give you the details tonight.