Unable to Generate a Temporary Class in Release Mode

TonyValentiTonyValenti USMember ✭✭

Hi All,
I'm getting a weird error when trying to build a project that references a .NET 2.0 style web service. Here's the situation:

  1. Create a new project. Make it a library to keep things simple.
  2. Right click on the Project > Add > Add Web Reference. Set the framework to ".NET 2.0 Web Services"
  3. Add "http://API.AppDriveForClio.com/V1/UpdateService.asmx" and add the reference.

Here's the problem: When you build the project in debug mode, it works great. When you switch to Release mode, it doesn't build with the following errors:

<br />Building: Test4 (Release)
Build started 4/24/2017 8:27:51 PM.
__________________________________________________
Project "/Users/tonyvalenti/Projects/Test4/Test4/Test4.csproj" (Build target(s)):

Target _DetectSdkLocations:
    DetectSdkLocations Task
      XamarinSdkRoot: <null>
Target _CoreCompileImageAssets:
    ACTool Task
      AppManifest: 
      DeviceModel: <null>
      DeviceOSVersion: <null>
      ImageAssets:
      IntermediateOutputPath: obj/Release/
      IsWatchApp: False
      OptimizePNGs: False
      OutputPath: bin/Release/
      ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
      ResourcePrefix: Resources
      SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
      SdkPlatform: MacOSX
      SdkVersion: 10.12
Target _CoreCompileInterfaceDefinitions:
    IBTool Task
      AppManifest: 
      InterfaceDefinitions:
      IntermediateOutputPath: obj/Release/
      IsWatchApp: False
      IsWatch2App: False
      IsAppExtension: False
      ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
      ResourcePrefix: Resources
      SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
      SdkPlatform: MacOSX
      SdkRoot: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
      SdkVersion: 10.12
      BundleResources Output:
      OutputManifests Output:
Target _CoreCompileSceneKitAssets:
    CompileSceneKitAssets Task
      IntermediateOutputPath: obj/Release/
      ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
      ResourcePrefix: Resources
      SceneKitAssets:
      SdkDevPath: /Applications/Xcode.app/Contents/Developer
      SdkRoot: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
      SdkVersion: 10.12
Target _CoreCompileTextureAtlases:
    TextureAtlas Task
      AtlasTextures: <null>
      IntermediateOutputPath: obj/Release/
      ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
      ResourcePrefix: Resources
      SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
      SdkDevPath: /Applications/Xcode.app/Contents/Developer
      SdkUsrPath: /Applications/Xcode.app/Contents/Developer/usr
Target _CollectBundleResources:
    CollectBundleResources Task
      BundleResources: <null>
      OptimizePropertyLists: False
      OptimizePNGs: False
      ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
      ResourcePrefix: Resources
Target _PackLibraryResources:
    PackLibraryResources Task
      BundleResourcesWithLogicalNames: <null>
      Prefix: xammac
Target PrepareForBuild:
    MakeDir Task
      Directories:
        bin/Release/
        obj/Release/
Target GenerateTargetFrameworkMonikerAttribute:
  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Target CoreCompile:
  Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
Target GenerateSerializationAssemblies:
    /Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/4.5/sgen.exe /assembly:/Users/tonyvalenti/Projects/Test4/Test4/obj/Release/Test4.dll /proxytypes /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/mscorlib.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Core.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Web.Services.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Xml.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll 

    Unhandled Exception:
    System.InvalidOperationException: Unable to generate a temporary class (result=1).
    SGEN : error CS1703: An assembly `mscorlib' with the same identity has already been imported. Consider removing one of the references
    SGEN : error CS1703: An assembly `System' with the same identity has already been imported. Consider removing one of the references
    SGEN : error CS1703: An assembly `System.Web.Services' with the same identity has already been imported. Consider removing one of the references
    SGEN : error CS1703: An assembly `System.Xml' with the same identity has already been imported. Consider removing one of the references

      at System.Xml.Serialization.Compiler.Compile (System.Reflection.Assembly parent, System.String ns, System.Xml.Serialization.XmlSerializerCompilerParameters xmlParameters, System.Security.Policy.Evidence evidence) [0x0021a] in <83e9d7a4b42d41219e36aa02cb194cba>:0 
      at System.Xml.Serialization.TempAssembly.GenerateAssembly (System.Xml.Serialization.XmlMapping[] xmlMappings, System.Type[] types, System.String defaultNamespace, System.Security.Policy.Evidence evidence, System.Xml.Serialization.XmlSerializerCompilerParameters parameters, System.Reflection.Assembly assembly, System.Collections.Hashtable assemblies) [0x004c2] in <83e9d7a4b42d41219e36aa02cb194cba>:0 
      at System.Xml.Serialization.XmlSerializer.GenerateSerializer (System.Type[] types, System.Xml.Serialization.XmlMapping[] mappings, System.CodeDom.Compiler.CompilerParameters parameters) [0x000cb] in <83e9d7a4b42d41219e36aa02cb194cba>:0 
      at Driver.Run (System.String[] args) [0x003e5] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0 
      at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0 
    [ERROR] FATAL UNHANDLED EXCEPTION: System.InvalidOperationException: Unable to generate a temporary class (result=1).
    SGEN : error CS1703: An assembly `mscorlib' with the same identity has already been imported. Consider removing one of the references
    SGEN : error CS1703: An assembly `System' with the same identity has already been imported. Consider removing one of the references
    SGEN : error CS1703: An assembly `System.Web.Services' with the same identity has already been imported. Consider removing one of the references
    SGEN : error CS1703: An assembly `System.Xml' with the same identity has already been imported. Consider removing one of the references

      at System.Xml.Serialization.Compiler.Compile (System.Reflection.Assembly parent, System.String ns, System.Xml.Serialization.XmlSerializerCompilerParameters xmlParameters, System.Security.Policy.Evidence evidence) [0x0021a] in <83e9d7a4b42d41219e36aa02cb194cba>:0 
      at System.Xml.Serialization.TempAssembly.GenerateAssembly (System.Xml.Serialization.XmlMapping[] xmlMappings, System.Type[] types, System.String defaultNamespace, System.Security.Policy.Evidence evidence, System.Xml.Serialization.XmlSerializerCompilerParameters parameters, System.Reflection.Assembly assembly, System.Collections.Hashtable assemblies) [0x004c2] in <83e9d7a4b42d41219e36aa02cb194cba>:0 
      at System.Xml.Serialization.XmlSerializer.GenerateSerializer (System.Type[] types, System.Xml.Serialization.XmlMapping[] mappings, System.CodeDom.Compiler.CompilerParameters parameters) [0x000cb] in <83e9d7a4b42d41219e36aa02cb194cba>:0 
      at Driver.Run (System.String[] args) [0x003e5] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0 
      at Driver.Main (System.String[] args) [0x00005] in <eeaf85d64a8c4c2eb792db70e13a9f1e>:0 
Done building target "GenerateSerializationAssemblies" in project "Test4.csproj" -- FAILED.
Target _CleanRecordFileWrites:
    MakeDir Task
      Directories:
        obj/Release/

Done building project "Test4.csproj" -- FAILED.

Build FAILED.

SGEN : error CS1703: An assembly `mscorlib' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `System' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `System.Web.Services' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `System.Xml' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `mscorlib' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `System' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `System.Web.Services' with the same identity has already been imported. Consider removing one of the references
SGEN : error CS1703: An assembly `System.Xml' with the same identity has already been imported. Consider removing one of the references
    0 Warning(s)
    8 Error(s)

Time Elapsed 00:00:01.44

---------------------- Done ----------------------

Build: 8 errors, 0 warnings

What is causing this and how can I work around it?

Best Answer

Answers

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    I'm having difficulty getting the web reference stuff working on my machine right now. In general, when something works in Debug and not in Release, a good first step to the compare the build logs to see where they differ.

    Could you post a Debug build log?

  • TonyValentiTonyValenti USMember ✭✭

    Here is what the debug log looks like:

    <br />Building: Test4 (Debug)
    Build started 4/26/2017 4:34:48 AM.
    __________________________________________________
    Project "/Users/tonyvalenti/Projects/Test4/Test4/Test4.csproj" (Build target(s)):
    
    Target _DetectSdkLocations:
        DetectSdkLocations Task
          XamarinSdkRoot: <null>
    Target _CoreCompileImageAssets:
        ACTool Task
          AppManifest: 
          DeviceModel: <null>
          DeviceOSVersion: <null>
          ImageAssets:
          IntermediateOutputPath: obj/Debug/
          IsWatchApp: False
          OptimizePNGs: False
          OutputPath: bin/Debug/
          ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
          ResourcePrefix: Resources
          SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
          SdkPlatform: MacOSX
          SdkVersion: 10.12
    Target _CoreCompileInterfaceDefinitions:
        IBTool Task
          AppManifest: 
          InterfaceDefinitions:
          IntermediateOutputPath: obj/Debug/
          IsWatchApp: False
          IsWatch2App: False
          IsAppExtension: False
          ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
          ResourcePrefix: Resources
          SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
          SdkPlatform: MacOSX
          SdkRoot: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
          SdkVersion: 10.12
          BundleResources Output:
          OutputManifests Output:
    Target _CoreCompileSceneKitAssets:
        CompileSceneKitAssets Task
          IntermediateOutputPath: obj/Debug/
          ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
          ResourcePrefix: Resources
          SceneKitAssets:
          SdkDevPath: /Applications/Xcode.app/Contents/Developer
          SdkRoot: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
          SdkVersion: 10.12
    Target _CoreCompileTextureAtlases:
        TextureAtlas Task
          AtlasTextures: <null>
          IntermediateOutputPath: obj/Debug/
          ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
          ResourcePrefix: Resources
          SdkBinPath: /Applications/Xcode.app/Contents/Developer/usr/bin
          SdkDevPath: /Applications/Xcode.app/Contents/Developer
          SdkUsrPath: /Applications/Xcode.app/Contents/Developer/usr
    Target _CollectBundleResources:
        CollectBundleResources Task
          BundleResources: <null>
          OptimizePropertyLists: False
          OptimizePNGs: False
          ProjectDir: /Users/tonyvalenti/Projects/Test4/Test4
          ResourcePrefix: Resources
    Target _PackLibraryResources:
        PackLibraryResources Task
          BundleResourcesWithLogicalNames: <null>
          Prefix: xammac
    Target PrepareForBuild:
        MakeDir Task
          Directories:
            bin/Debug/
            obj/Debug/
    Target GenerateTargetFrameworkMonikerAttribute:
      Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
    Target CoreCompile:
        /Library/Frameworks/Mono.framework/Versions/5.0.0/lib/mono/4.5/csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:__UNIFIED__;DEBUG /errorendlocation /preferreduilang:en-US /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/mscorlib.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Core.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Web.Services.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/System.Xml.dll /reference:/Library/Frameworks/Xamarin.Mac.framework/Versions/Current/lib/mono/Xamarin.Mac/Xamarin.Mac.dll /debug+ /debug:portable /optimize- /out:obj/Debug/Test4.dll /target:library /utf8output MyClass.cs Properties/AssemblyInfo.cs "Web References/api.alphadriveforclio.com/Reference.cs" "/var/folders/s1/svk6yxjs5q35vddfrs53dr1h0000gn/T/Xamarin.Mac,Version=v2.0.AssemblyAttributes.cs"
    Target CopyFilesToOutputDirectory:
        Copy Task
          DestinationFiles: <null>
          DestinationFolder: bin/Debug/
          OverwriteReadOnlyFiles: False
          Retries: 0
          RetryDelayMilliseconds: 0
          SkipUnchangedFiles: True
          SourceFiles:
            obj/Debug/Test4.dll
          UseHardlinksIfPossible: False
        Copying file from '/Users/tonyvalenti/Projects/Test4/Test4/obj/Debug/Test4.dll' to '/Users/tonyvalenti/Projects/Test4/Test4/bin/Debug/Test4.dll'
        Test4 -> /Users/tonyvalenti/Projects/Test4/Test4/bin/Debug/Test4.dll
        Copy Task
          DestinationFiles:
            bin/Debug/Test4.pdb
          DestinationFolder: 
          OverwriteReadOnlyFiles: False
          Retries: 0
          RetryDelayMilliseconds: 0
          SkipUnchangedFiles: True
          SourceFiles:
            obj/Debug/Test4.pdb
          UseHardlinksIfPossible: False
        Copying file from '/Users/tonyvalenti/Projects/Test4/Test4/obj/Debug/Test4.pdb' to '/Users/tonyvalenti/Projects/Test4/Test4/bin/Debug/Test4.pdb'
    Target IncrementalClean:
        Delete Task
          Files:
          TreatErrorsAsWarnings: True
    
    Build succeeded.
        0 Warning(s)
        0 Error(s)
    
    Time Elapsed 00:00:01.92
    
    ---------------------- Done ----------------------
    
    Build successful.
    
    
  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    In your debug build the GenerateSerializationAssemblies target is not being called at all.

    I would create a simple console application and see if you can get these web services working consistently first.

    Also, please consider pasting links to your output posted to a pastebin/gist service instead of inline. It makes traversing forum posts more difficult to have pages of output inline.

  • TonyValentiTonyValenti USMember ✭✭

    Hi @ChrisHamons -
    I've uploaded a test project to:
    https://github.com/TonyValenti/GIST_XamarinWebServicesNotWorking

    Take a look at it. This is brand new with nothing except the web reference added. It builds fine with debug but crashes for release. I have not changed anything related to the stock building.

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    I can not reproduce your failure:

    Debug: https://gist.github.com/chamons/0872165dd916413007991ab39be14136
    Release: https://gist.github.com/chamons/35d881958fd5612a38d701f66ec26c3e

    I have Mono 5.0.0.78 (2017-02/ba317ed) (64-bit) with XS Version 6.3 (build 863) installed currently.

  • TonyValentiTonyValenti USMember ✭✭

    Hi Chris,
    Would you try using VS for Mac? I just tested with XS and it worked. With VS, it doesn't.

  • voidvoid DKBeta ✭✭✭

    @ChrisHamons It seems we could have a derivative of this bug on the mobile platforms : https://forums.xamarin.com/discussion/96856/error-msb6006-sgen-exe-exited-with-code-1-since-stable-update-last-tuesday

    The bug report is private. What is the status of the fix?

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    It sounds like the two threads might have a common cause. Both iOS and Xamarin.Mac Modern (Mobile) use a different mscorlib than the system which explains the errors.

    I believe the bug is in the xml serialization generator, and it is in work by a member of the runtime team (but not fixed yet).

  • voidvoid DKBeta ✭✭✭

    @ChrisHamons Thanks. Should I make a new bugzilla report, or will you add to the existing one?

  • DaniHarelDaniHarel USMember

    Hey guys
    Im having the same error and cannot get passed it! Any updates?
    Thanks!

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    @DaniHarel If you are referring to the original issue, the accepted answer:

    • Use XS instead of VSfM
    • Uncheck Preferences -> Projects -> Build -> Build with MSBuild instead of xbuild (I don't recommend this as it may affect other things)
    • Build the project with xbuild and check in the output for now.

    would all be work arounds.

    If not, please create a new thread.

  • joehannajoehanna AUBeta ✭✭

    This workaround does not work for me. I am desperately trying to fix a bug and release before iOS 11 lands next week. Any other ideas?

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    @Joehanna I would consider starting a new thread on the iOS forum if you are running into the issue (this thread is rather old), and consider posting the full build log.

    To my understanding, swapping to xbuild should work, but there might be some iOS specific issue on top of that.

  • joehannajoehanna AUBeta ✭✭

    Ok

  • SuatKorkmazSuatKorkmaz USMember ✭✭✭

    I'm having the same issue.

  • RudyScottRudyScott USMember ✭✭

    +1 Same issue. Very annoying. Also I had to restart visual studio after changing preferences to XBuild. Hopefully MS/Xamarin gives us a fix soon.

  • ChrisHamonsChrisHamons USXamarin Team Xamurai

    The bug is fixed in 15.4's mono (from what I can tell) so upgrading to the Alpha or Beta channel should fix everyone up.

  • RudyScottRudyScott USMember ✭✭

    Thanks! I will give this a try. I also found this potential work around in the discussion of bug #59502:

    xbuild did not generate these serialization assemblies with sgen. But msbuild uses sgen for non-debug configs by default, and so we hit this in Release config.

    The sgen step can be disabled with /p:GenerateSerializationAssemblies=Off on the command line or adding <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> to a property group in the .csproj

    https://bugzilla.xamarin.com/show_bug.cgi?id=59502

    I don't seem to have sufficient permissions to view the original bug 55697

Sign In or Register to comment.