locked
IMetadataDispenser.OpenScope fails with BadImageFormatException RRS feed

  • Question

  • I've made a tool to read .pdb symbols for a .NET assembly based on the sample provided here: https://www.microsoft.com/en-ca/download/details.aspx?id=19621

    It worked fine for .NET 4.0 assemblies, but moving on to VS 2015 CTP 6, I wanted to use my tool to read the symbols from a .NET 4.6 assembly. that failed with a BadImageFormatException (error 8007000B). The tool itself is compiled either with .NET 4.0, 4.5 or 4.6 for the Any CPU platform, it's all the same result. The target assembly is compiled with .NET 4.6 for Any CPU as well. My Windows installation is 64 bit. The following line of code throws the exception:

    dispenser.OpenScope(pathModule, OPEN_READ, ref importerIID, out objImporter);

    I've already found a similar thread but it only talks about C++. My tool is written in C# so I can't use the code provided there. Also, the other thread discusses 32/64 bit issues which I don't believe I have here. But it also mentions that the way to get the symbol reader instance is outdated and another one should be used.

    How can I get this to work in C#? I'd prefer to support any .NET assemblies from 2.0 on, but at least 4.0 or newer, up to the current 4.6 version. If possible, I'd like to stay with .NET 4.0 for my tool application so it can run on older systems as well.

    Friday, April 17, 2015 9:25 AM

Answers

  • Meanwhile I was able to port all the additional code from C++/COM to C#/.NET and it actually works, so I can use the information published in the other thread. That solves my problem. The tool can now be compiled with .NET 4.0 and 4.6 and it can process 4.0 and 4.6 target assemblies. Details in this commit.
    Tuesday, April 21, 2015 11:10 AM

All replies

  • Hi LonelyPixel,

    Visual studio 2015 Preview is a preview for testing and feedback purposes, we have not started to support it yet.

    Can your tool and target assembly work if they both built with .NET 4.0, 4.5? Please try to see whether the Dispenser.OpenScope method will throw this exception. If the error still comes, please post more information about the scenario for future troubleshooting.

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 20, 2015 3:31 AM
  • Meanwhile I was able to port all the additional code from C++/COM to C#/.NET and it actually works, so I can use the information published in the other thread. That solves my problem. The tool can now be compiled with .NET 4.0 and 4.6 and it can process 4.0 and 4.6 target assemblies. Details in this commit.
    Tuesday, April 21, 2015 11:10 AM