Question: Has anyone successfully iLMerged Enterprise Library 5.0? iLMerge successfully creates the merged dll and my mvc application compiles, but when launching the application I receive the following error:

```
SecurityTransparent and SecurityCritical attributes cannot 
be applied to the assembly scope at the same time.

```

Answer: 
ILMerge is great if you wrote all of the assemblies that you're trying to merge, and you know that none of them are making assumptions about assembly organization. But under many circumstances (especially ones where heavy reflection or the Dynamic Language Runtime are involved), ILMerge just doesn't work. Sometimes things fail in surprising and mysterious ways.

When ILMerge fails, Jeffrey Richter h [a more reliable way to get applications with multiple DLL dependencies to be deployable as a single assembly](http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx).

With his approach, every assembly gets to retain its own name, strongname, and attributes, which *greatly* improves your chances of the resulting application just working.

It isn't without trade-offs, but even the ILMerge author, Mike Barnett, said in the comment thread on that blog post "As the author of ILMerge, I think this is fantastic! If I had known about this, I never would have written ILMerge."

If you can use Richter's method, you won't trip over most of the reflection or dynamism traps.

**The implementation steps**

1. Embed all of the third-party assemblies that you depend on in your application's Resources.
2. Register a [`ResolveEventHandler`](http://blogs.msdn.com/b/microsoft_press/archive/2010/02/03/jeffrey-richter-excerpt-2-from-clr-via-c-third-edition.aspx) with the `AppDomain.CurrentDomain.AssemblyResolve` event.
3. When your handler gets called with an assembly that you stashed in Resources, load the assembly.

You do part 3 as follows:

```
var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
return Assembly.Load(new BinaryReader(resourceStream).ReadBytes(int.MaxValue));

```
Try to merge only the DLLs that are part of your application, not the framework ones (System.Web.Mvc.dll, System.Web.Routing.dll and System.Web.Abstractions.dll)