Error in XML serialization for TypeForwardedTo classes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Deepak Kothari
    New Member
    • Jan 2011
    • 1

    Error in XML serialization for TypeForwardedTo classes

    When an object is serialized, the framework creates a .cs program file in the /Windows/Temp directory and tries to compile it with a cmdline (freshly created everytime) which is present in .cmdline file in the same path. The cmdline tries to compile the .cs program using csc.exe with appropriate reference paths included and the output file and path to store the output.

    Does anyone know based on what the references in the cmdline are included because when I try to serialize a TypeForwardedTo class' object it only picks up the reference to assembly of the new class and not the earlier one (which actually does the typeforwarding and has the reference to the new assembly) though it requires both the assemblies to compile the program.

    Error Type :System.Invalid OperationExcept ion
    Message :Unable to generate a temporary class (result=1).
    error CS0012: The type 'ABC' is defined in an assembly that is not referenced. You must add a reference to assembly 'OldAssembly, Version=2.0.0.0 , Culture=neutral , PublicKeyToken= null'.
    error CS0030: Cannot convert type 'ABC[]' to 'ABC[c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary ASP.NET Files\test\58f6 30a6\747e46b1\a ssembly\dl3\459 3adba\88d7c3d0_ c5a1cb01\NewAssembly.DLL]'
    error CS0029: Cannot implicitly convert type 'ABC[c:\WINDOWS\Micr osoft.NET\Frame work\v2.0.50727 \Temporary ASP.NET Files\test\58f6 30a6\747e46b1\a ssembly\dl3\459 3adba\88d7c3d0_ c5a1cb01\NewAssembly.DLL]' to 'ABC[]'

    I tried to run the auto-generated cmdline in command prompt and as expected got the same error. Then I added the reference to the old assembly in the cmdline and it started working.

    Now I have no clue how to get the reference added automatically in the auto-generated cmdline file.

    Any help is highly appreciated. Thanks
Working...