views:

48

answers:

3

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=1.0.0.0, 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.

+1  A: 

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.

Aliostad
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
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
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
can't, i'm using some 3rd party 32bit dlls...
Or A
Build everything as x86. It will run as WOW in x64.
Aliostad
A: 

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));
Darin Dimitrov
with some reason i can't open the link that you sent, can you paste the content?
Or A
the test code that you posted work with no problems
Or A
A: 

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

thanks for the help.

Or A