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

Debugging an InvalidCastException

First, obviously, find the two types for which the cast failed and verify that they are the same type or otherwise castable. Next, if the type was just deserialized, also verify that its assembly successfully loaded in the target appdomain. If everything seems fine, check to see if the assemblies for those two types are loaded from different locations and…

11

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

Debugging a MissingMethodException, MissingFieldException, TypeLoadException

Say you’ve just installed some assemblies from a third party and now you’re seeing a MissingMethodException, MissingFieldException, or TypeLoadException (during the run of an application using those assemblies). Below are the common causes. Loading failuresFirst, check for assembly binding failures by getting the Fusion log. Look for the assembly containing that method/field/type or assemblies containing types referenced…

14