Take the 2-minute tour ×

I recently upgrade my machine to XP 64 bit and also made some code changes to our software and when I'm doing new XmlSerializer(valueType), where valueType is a type that is using DirectoryItem, I'm getting the following error:

Unable to generate a temporary class (result=1). error CS0012: The type 'XYZ.Blob.DirectoryItem' is defined in an assembly that is not referenced. You must add a reference to assembly 'XYZ.Services.Blob, Version=, Culture=neutral, PublicKeyToken=null'.

I really can't see why it shows this error. The dll is in the src folder and the exact same application is running with no issue on the same machine (the previous version).

If you have any idea how can I find what it gives this error that would be great.

share|improve this question
Why do you have a DLL in a folder that's named "src"? That's typically a name for a folder that stores source code files, not DLLs. Your project setup sounds very unusual, tough to help you. –  Hans Passant Sep 23 '10 at 21:19
its nothing related to the src, i add it by accident;the structure is like the standard .net strcutre –  Or A Sep 24 '10 at 13:42
add comment

3 Answers

Can you verify that you are not falling in this unfortunate scenario? If this is the case that's a bug that won't be fixed by Microsoft:

You need some type into an assembly A:

public interface IInterface {}

And a type to be serialized in another assembly:

public class MyClass
    public int Number;
    public void Method<T>() where T : IInterface { }

Now, try to initialize a XmlSerializer

XmlSerializer ser = new XmlSerializer(typeof(MyClass));
share|improve this answer
with some reason i can't open the link that you sent, can you paste the content? –  Or A Sep 24 '10 at 13:43
the test code that you posted work with no problems –  Or A Sep 24 '10 at 13:46
Glad you mentioned this FIVE YEAR OLD bug. Just tried the Interface workaround, no problem now. –  Nicholi Nov 19 '11 at 0:29
I ran into the same error...but the suggested dummy interface doesn't solve my problem. Actually, I get this error only if my dll is embedded in the exe and loaded by AssemblyResolve event. If the dll is not embedded, it's working fine. Only XmlSerializer has this problem with embedded dll, everything else seems to be fine. By the way, I'm using VS 2010 express, .NET 4.0, build Any platform. –  miliu Mar 14 '13 at 0:37
add comment

Your assembly has been built for x86 platform.

Have a look at your project's properties -> build -> target platform It is x86 by default. You need to recompile for x64.

Best option is compiling for "any" - in your case.

share|improve this answer
you are right, i the assemblies are built for x86 platform, but that by design.i run on a 64 bit machine, but our application need to be built for x86 for the time being. –  Or A Sep 24 '10 at 13:41
i also don't understand why it tells you the it can't find the reference, while the reference is there and the dll is in the output directory –  Or A Sep 24 '10 at 13:44
It cannot find the reference because it is built for x86 so it would not load it - as far as it is concerned it does not exist because x64 does not exist. build it with "Any CPU" option. –  Aliostad Sep 24 '10 at 13:50
can't, i'm using some 3rd party 32bit dlls... –  Or A Sep 24 '10 at 14:00
Build everything as x86. It will run as WOW in x64. –  Aliostad Sep 24 '10 at 14:04
add comment

it seems like that the solution was fixed once i changed all my implicit conversion to explicit ones.

thanks for the help.

share|improve this answer
add comment

Your Answer


