Suzanne Cook's .NET CLR Notes

Common Language Runtime Developer

Browse by Tags

Tagged Content List
  • Blog Post: 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: http://channel9.msdn.com/ShowPost.aspx?PostID=79591
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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, then it's not a managed...
  • Blog Post: 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...
  • Blog Post: 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...
  • Blog Post: 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 know how and are, in...
  • Blog Post: 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...
  • Blog Post: Assembly Identity

    There are two types of assembly identity that the loader deals with: bind-time and after bind-time. The identity is used to determine whether we will consider a certain assembly to be the same thing as an assembly reference or another assembly. Assembly Binding At assembly-bind time, the components...
  • Blog Post: Unloading an Assembly

    There's no way to unload an individual assembly without unloading all of the appdomains containing it. (See here for why not.) This can by done by calling AppDomain.Unload() for each AppDomain that has it loaded. (You could also use UnloadDomain() on the v1 unmanaged hosting API, but in general, I recommend...
  • Blog Post: Mscorlib.dll

    At least for v2 and earlier, mscorlib.dll is a special case. That causes it and its types to be loaded differently from other assemblies. Loading Mscorlib.dll Without a Path It and the execution engine are so closely integrated that it's required that they match each other. So, once a version of the...
  • Blog Post: Assembly.CodeBase vs. Assembly.Location

    The CodeBase is a URL to the place where the file was found, while the Location is the path from where it was actually loaded. For example, if the assembly was downloaded from the internet, its CodeBase may start with "http://", but its Location may start with "C:\". If the file was shadow copied, the...
  • Blog Post: Determining an Image’s CLR Version

    To get it programmatically, from managed code, use Assembly.ImageRuntimeVersion. From unmanaged, use mscoree.dll's GetFileVersion(). (From the command line, starting in v2.0, ildasm.exe will show it if you double-click on "MANIFEST" and look for "Metadata version".) Those will give you the CLR version...
  • Blog Post: AppDomain.Load()

    AppDomain.Load() is only meant to be called on AppDomain.CurrentDomain. (It's meant for interop callers only. They need a non-static method, and Assembly.Load() is static.) If you call it on a different AppDomain, if the assembly successfully loads in the target appdomain, remoting will then try to load...
  • Blog Post: Switching to the Load Context

    So, after checking out the binding context options , you've decided to switch your app to use the Load context. Now, you just need to figure out how to do it. Maybe it will be as simple as using Assembly.Load( assemblyDisplayName ) instead of Load(byte[]), etc. That will work if the assembly is available...
  • Blog Post: Executing Code in Another AppDomain

    The easiest way to run code in another appdomain is to execute an assembly entrypoint using AppDomain.ExecuteAssembly() or (starting in v2.0) AppDomain.ExecuteAssemblyByName(). If you want to execute a method other than an assembly entrypoint, call AppDomain.CreateInstance() on a type which extends...
  • Blog Post: App.Config Files

    By default, the application configuration file of the default appdomain (and other appdomains for v1.1 and later) is in the process exe’s directory and named the same as the process exe + ".config". This is true even if that exe is unmanaged. Also, note that a web.config file is an app.config - ASP.NET...
  • Blog Post: Avoid Partial Binds

    A partial bind is when only part of the assembly display name is given when loading an assembly. Assembly.LoadWithPartialName() also uses partial binding. First, it calls Assembly.Load(). But, if that fails to find the assembly, it will return the latest version of that assembly available in the GAC...
  • Blog Post: Using Type.GetType(typeName)

    If no assembly is specified, Type.GetType() will only look in the calling assembly and then mscorlib.dll for the type. For it to look in any other assembly, you need to give the Type.AssemblyQualifiedName for the type. For example: Type.GetType("System.Uri, System, Version=1.0.3300.0, Culture=neutral...
  • Blog Post: When to Change File/Assembly Versions

    First of all, file versions and assembly versions need not coincide with each other. I recommend that file versions change with each build. But, don’t change assembly versions with each build just so that you can tell the difference between two versions of the same file; use the file version for that...
  • Blog Post: Choosing a Binding Context

    There are three 'contexts' for assembly binding: Load context In general, if the assembly was found by probing in the GAC, a host assembly store (if hosted), or the ApplicationBase / PrivateBinPaths of the AppDomain, the assembly will be loaded in the Load context. LoadFrom context In general...
  • Blog Post: Assembly Display Names

    An assembly display name should include the assembly simple name, version, culture and public key token. The assembly simple name is usually the file name of the assembly without the extension (“.dll” or “.exe”). For example, the assembly display name for the v1.0 system.dll assembly is: System...
Page 1 of 1 (24 items)