Channel 9 Interview

Charles Torre and Robert Scoble (behind the camera) dropped by my office to chat with me about the loader for MSDN’s Channel 9: part I and part II.Also, check out the PDC video I was in for Channel 9: https://channel9.msdn.com/ShowPost.aspx?PostID=79591

19

New Assembly, Old .NET (and Vice-Versa)

I typically recommend that you build and test your assemblies against the same version of .NET that you will be running them against. That way, you’ll have correct references and avoid surprises from behavior differences between builds. Older assembly, newer .NET But, sometimes you don’t run against the same version that you built against. For…

17

Versioning/Deploying Unmanaged Files

An unmanaged dll can be wrapped in a managed assembly by adding it as a file of a multi-module assembly. Then, it can be deployed and versioned in the same way as managed assemblies. (So, that assembly could contain nothing but metadata and unmanaged code – no managed code, if you prefer. It can also…

4

Load(AssemblyName)

Calling Load(AssemblyName) is not necessarily the same as calling Load(String). If the AssemblyName.CodeBase is not set, then they do do the same thing. So, if you’ve set the AssemblyName.Name, CultureInfo, public key token / public key and/or Version properties, it would be the same as if you had specified those properties in a String (as…

7

App.config Examples

Below are three examples of useful application configuration files. Forces the v1.0 CLR to be run. If the v1.0 CLR is not installed, the app will fail to run. <?xml version =”1.0″?>  <configuration>     <startup>          <requiredRuntime version=”v1.0.3705″/>          <supportedRuntime version=”v1.0.3705″/>      </startup>  </configuration> Redirects “assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=25283151a234958d“ to version 2.0.0.0 of that assembly. This…

25

Determining Whether a File Is an Assembly

A file is an assembly if and only if it’s managed and it contains an Assembly entry in its CLR metadata. Determining by hand A fast way to determine whether a file is an assembly is to run ildasm.exe on it. If it immediately gives an error saying that it may not be a PE file,…

10

LoadFile vs. LoadFrom

Be careful – these aren’t the same thing. LoadFrom() goes through Fusion and can be redirected to another assembly at a different path but with that same identity if one is already loaded in the LoadFrom context. LoadFile() doesn’t bind through Fusion at all – the loader just goes ahead and loads exactly* what the…

12

LoadFrom’s Second Bind

Pre-v2, when you load an assembly by path through Fusion (LoadFrom(), ExecuteAssembly(), etc.), it can actually cause two binds, not just one. The first bind loads the file at the given path. If that is successful, another bind is done with the display name of that assembly to see if it’s available in the Load…

2

Avoid DevPath

I hesitate to talk about this because I don’t want people who don’t know about it to think, “Hey, what’s this DevPath thing? I need that.” But, maybe if I don’t explain how to use it, it will be too much effort for people who don’t already know how. 🙂 (And, for those who already…

16

Binding to .NET Frameworks Assemblies

By “Frameworks assemblies,” I mean the assemblies that ship with the CLR. But, I’m not counting mscorlib.dll, since it’s special in a different way. With v1.0 SP3 or later, Frameworks assemblies are unified. That means that the version of those assemblies that you request is ignored – you get the version that matches the loaded…

3