0

When I debug my VB.NET application in Visual Studio 2010, in the debug output it says a few things that I don't understand:

'something.vshost.exe' (Managed (v4.0.30319)): Loaded 'jb3yjswu'
'something.vshost.exe' (Managed (v4.0.30319)): Loaded 'mdul5h2c'

What are these random modules (or something else) that get loaded? Are they related to threads being created? The names change every time I debug.

Brad
  • 159,648
  • 54
  • 349
  • 530
  • 1
    Temporary assemblies for dynamically generated types? – Richard Cook Sep 23 '10 at 02:34
  • That could be it. What do you mean by dynamically generated types? I have a lot of custom types. – Brad Sep 23 '10 at 02:35
  • Do you have any lambda in your project? I believe lambda and definitely anonymous types are compiled to [closures](http://stackoverflow.com/questions/428617/what-are-closures-in-net) which might get thrown into temp assemblies? – Smudge202 Apr 21 '12 at 06:42
  • @Smudge202: No, they're compiled into the same assembly where they're declared. – Jon Skeet Apr 21 '12 at 06:52
  • 2
    @Brad: Do you have any XML serialization in your code? – Jon Skeet Apr 21 '12 at 06:53
  • @JonSkeet, Ah Yes! I do serialize/deserialize XML to a custom type. – Brad Apr 21 '12 at 16:03
  • 1
    @Brad: Right, I wouldn't be at all surprised if that were it. Follow my diagnostic suggestion below and you may well see that... – Jon Skeet Apr 21 '12 at 16:38

1 Answers1

2

I suggest you dump the modules and types from the loaded assemblies to a log file at appropriate times. You can then look for the mystery assembly and find the types in it. For example:

using System;
using System.Xml.Linq;

public class Test
{    
    static void Main()
    {
        Console.WriteLine("Before");
        DumpAssemblies();
        DoSomethingWithXml();
        Console.WriteLine("After");
        DumpAssemblies();
    }

    static void DoSomethingWithXml()
    {
        new XDocument();
    }

    static void DumpAssemblies()
    {
        Console.WriteLine("Assemblies loaded:");
        foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
        {
            Console.WriteLine("  Assembly {0}:", assembly.FullName);
            foreach (var module in assembly.GetModules())
            {
                Console.WriteLine("    Module {0}:", module.Name);
                foreach (var type in module.GetTypes())
                {
                    Console.WriteLine("      {0}", type.FullName);
                }
            }
        }
    }
}

Once you know which types are in which assemblies, that should probably explain what's going on. If you see the mystery modules without any types, or with types which don't make much sense, you'll need to add more diagnostics - e.g. listing resources within the modules, or methods within the types etc.

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194