views:

78

answers:

1

Hi,

I have no clue whats going on here. My c# (VS2008) app runs fine in 32 bit OS but when i run the same in Windows 2008 R2 64bit i am getting following error:

Unable to generate a temporary class (result=1). error CS0008: Unexpected error reading metadata from file 'c:\Windows\assembly\GAC_MSIL\xxxx\7.0.1001.0__5b72a65e64576834\xxxx.dll' -- 'Bad Key. '

Looked through some articles, which says if there is no sufficient permissions to temp folder this error will popup. And i have given permissions to temp folder "C:\windows\temp" and user temp folder ("C:\users\\appdata\local\temp") but no luck. I have a webservice proxy class in this assembly, which requires XML serialization and i guess uses temp folder to create serialized assembly at run time, where it is throwing this error.

Any inputs much appreciated. BTW i found that error (unable to generate.....) in event viewer.

Thanks.

+1  A: 

There are a couple of fundamental things wrong in your question. This is a compile time error, not a runtime error. Note CS0008 in the message, documented as:

A DLL was successfully opened for retrieving metadata but is corrupted, such that data could not be read from it. For more information, see /reference (Import Metadata) (C# Compiler Options).

Next thing that's wrong is that this assembly clearly comes from the GAC. The compiler should never reference an assembly from the GAC, reference assemblies have to be copies stored in a relevant directory. Like c:\windows\microsoft.net\etc for the .NET framework assemblies.

Whatever you did to get this error clearly voided the warranty. I cannot reverse-engineer what you did from your question, obfuscating the assembly name certainly did not help.

Hans Passant
You can safely assume the assembly name is something proprietary if it appears to be obfuscated intentionally.
Mike Atlas
Thanks for the replies. I am running the app from the installer and the assembly is not .net system assembly. I tried compiling this project in 64 bit and it compiles fine without errors in VS 2008 also runs fine. The problem is if i use installer to install this solution and run i am getting the above specified error.
Santosh
An update -- when i build the project with target platform as x64, everything works fine. Are we suppose to build target as x64 for 64 bit OS?
Santosh
OK, i found the cause to the problem. We added InternalsVisibleTo attribute to assembly class which is causing this issue. Not sure why that will cause issue. May be its a bug in 64 bit OS.
Santosh