Determine whether .NET assemblies were built from the same source

It’s not too painful to use command-line tools to filter out MVID and date-time stamps from a text representation of the IL. Suppose file1.exe and file2.exe are built from the same sources: c:\temp> ildasm /all /text file1.exe | find /v “Time-date stamp:” | find /v “MVID” > file1.txt c:\temp> ildasm /all /text file2.exe | find … Read more

ASP.NET – AppDomain.CurrentDomain.GetAssemblies() – Assemblies missing after AppDomain restart

I looked through the ASP.NET MVC 2.0 source code and looked up how AreaRegistration.RegisterAllAreas(); is implemented. This line is usually put into the Global.asax Application_Start() method and internally it scans all Assemblies for types that implement the AreaRegistration abstract type. This is kinda the behaviour I’m after. It appears RegisterAllAreas() makes a call to BuildManager.GetReferencedAssemblies(), … Read more

“Are you missing an assembly reference?” compile error – Visual Studio

In my case it was a project defined using Target Framework: “.NET Framework 4.0 Client Profile ” that tried to reference dll projects defined using Target Framework: “.NET Framework 4.0”. Once I changed the project settings to use Target Framework: “.NET Framework 4.0” everything was built nicely. Right Click the project->Properties->Application->Target Framework

How to prevent a .NET application from loading/referencing an assembly from the GAC?

If both assemblies are strong-named (signed), the CLR will always load from the GAC. Here are the steps the runtime uses to resolve assembly references (from How the Runtime Locates Assemblies): Determines the correct assembly version by examining applicable configuration files, including the application configuration file, publisher policy file, and machine configuration file. If the … Read more

using ILMerge with .NET 4 libraries

There was a very recent release to solve x64 problems. Get in touch with Mike Barnett directly if you still have problems (mbarnett at microsoft dot com) Addendum. There’s something very, very wrong about your /lib:”C:\Windows\Microsoft.NET\Framework64\v4.0.30319″ option. This has been getting lots of programmers in trouble lately, after .NET 4.5 was released. That directory is … Read more

How to read assembly attributes

This is reasonably easy. You have to use reflection. You need an instance of Assembly that represents the assembly with the attributes you want to read. An easy way of getting this is to do: typeof(MyTypeInAssembly).Assembly Then you can do this, for example: object[] attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false); AssemblyProductAttribute attribute = null; if (attributes.Length > … Read more