C++/Cx component producing a corrupt .winmd file - by Lloyd

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 775871 Comments
Status Closed Workarounds
Type Bug Repros 1
Opened 1/5/2013 6:43:07 AM
Access Restriction Public


I have a C++/Cx component which I use in a C# DirectX Metro app.
It worked fine.
until my latest innocuous changes.. where my C# project can't use the C++/Cx project anymore, I got this error:
"There was a problem reading metadata from 'C:\Dev\WinRTDirectXSamples\Debug\DXBase\DXBase.winmd' ('An attempt was made to load a program with an incorrect format.')."

Reverting the changes made it work
(only a few properties / method in the C++ component changed, i.e. no project - target architecture changes)
Sign in to post a comment.
Posted by Anders Eggers-Krag on 7/16/2013 at 2:58 PM
I have tried the following to fix the problem:
Deleted every file i could find in the project folder that i had not created, had no effect
Installed a fresh windows 8, and visual studio on a VM, copying only the project same error occurs
Renamed the project file, project and root namespace (edited the vcxproj and sln files manually) this cuases the error to go away and also causes the winmd file to grow by about 2 kB (i will attach both winmd files)
returning to the original project name causes the error to return.

It should be noted that the former project name has worked for months and hundreds of compiles prior to the error occurring (if the number of files in \AppData\Local\Microsoft\VisualStudio\11.0\Designer\ShadowCache is anything to go by it has worked for over 500 compiles, which i might add caused that folder to take up 10 GB of disk space, over 500 22 MB pdb files)

Also the error has occured several times previously but in all cases a full rebuild was sufficient, this time it had no effect.

I will leave the VM with the failing project intact in case you need more information
Posted by Microsoft on 1/10/2013 at 1:44 AM
Hi lloyd, thanks for submitting feedback on Visual Studio and .Net Framework. We'll close this issue because you have found a workaround. Thanks for your time.
Posted by Lloyd on 1/5/2013 at 7:00 AM
I found a weird work around:

On a wild hunch (it's a compiler problem, right? I though I'll try to help it)
There was 2 properties in DXContext defined with a macro (TargetType, Status), I got rid of the macro and used code instead and then it worked fine!
Posted by Microsoft on 1/5/2013 at 6:51 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)