locked
Deployment of BizTalk 2010 solution fails: Exception type: BadImageFormatException Source: mscorlib RRS feed

  • Question

  • Folks,

    I have a strange deployment error that I did not have before, and I have really no idea what to do about it.

    When compiling a BizTalk 2010 solution, I get the following error message in Visual Studio 2010 when doing a build:


    Error 551 "System.String" must be XML-serializable to be valid as a message part type. Please find More information in the event log.

    (The original English error message may differ, as this is a translation back from a localized version).

    This was kind of strange, so I looked into the event log and found a pretty bad error there (also translated back into English, so original message in English may slightly differ):

    xlang/s engine event log entry: Fehler bei der XML-Serialisierung vom Typ "System.String".
            
    Exception type: XmlSerializationException
    Additional information:

            Error loading assembly "c:\<my c sharp helper dll for my biztalk application>.DLL".
            
    Exception type: AssemblyLoadException
    Source: Microsoft.XLANGs.RuntimeTypes
    Destination site: Void AddReferences(System.String[])
    The following stack trace shows where the Exception was trapped:

       at Microsoft.XLANGs.RuntimeTypes.CompilerMetaDataInfo.AddReferences(String[] strRefs)
       at Microsoft.XLANGs.RuntimeTypes.CompilerMetaDataInfo.GetPropertiesForDotNetPartType(String typeName, String assemblyLocation, String& formatterTypeName, String& reflectedTypeName, String& targetNameSpace)

    Additional information:
            The file or assembly "file:///c:\<my c sharp helper dll for my biztalk application>.DLL" or a dependent component was not found. It was tried to load a file in a wrong format.
            
    Exception type: BadImageFormatException
    Source: mscorlib
    Destination site: System.Reflection.RuntimeAssembly _nLoad(System.Reflection.AssemblyName, System.String, System.Security.Policy.Evidence, System.Reflection.RuntimeAssembly, System.Threading.StackCrawlMark ByRef, Boolean, Boolean, Boolean)
    The following stack trace shows where the Exception was trapped:

       at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
       at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
       at System.Reflection.Assembly.LoadFrom(String assemblyFile)
       at Microsoft.XLANGs.RuntimeTypes.CompilerMetaDataInfo.AddReferences(String[] strRefs)



    What's going wrong here? I thought it might have something to do with a 32-Bit/64-Bit problem, or with a Dot Net 3.5/Dot Net 4.0 issue, but I have no idea where to verify that, settings in Visual Studio look all fine and the solution used to compile pretty good.

    What can I do to narrow this?

    C.
    Monday, April 30, 2012 6:07 PM

Answers

  • Hi 

    If you are using a non serializable class in BizTalk Orchestration then you would need to use atomic scope to use the object. Please refer Why does the compiler require my variable to be serializable? 

    If that is the case then follow below steps to call the method of the custom class  , they are from this post

    Add a reference of that dll (class). The class must be strongly signed and in the GAC.

    • Make sure your transaction type of Orchestration is Long Running transactional.
      Add an Atomic scope.
      Create an Orchestration variable of that class inside the scope.
      Create an instance on that object inside the scope.
      Call the method.

    Make sure the host type is correct.

    I hope this helps!


    HTH,
    Naushad Alam

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki "BizTalk Server: Performance Tuning & Optimization"

    Monday, April 30, 2012 7:37 PM
    Moderator

All replies

  • Hi,

    This error is saying some dependent  dll is not deployed properly (not in gac).

    Are you using some .NET dll in your BizTalk solutions, or If yes check it is gaced or not ?if not please gac it first.

    Thanks,

    Chandra

    • Proposed as answer by Chandra Kumar Monday, April 30, 2012 6:22 PM
    Monday, April 30, 2012 6:22 PM
  • IMHO BAD Image error is dues to 32bit and 64 bit. Change the host type to 32 bit or appropriate and the issue should be resolved. 

    If you are using any external DLL which is compiled for 32 bit then You would need to change the host type to 32 bit. 


    HTH,
    Naushad Alam

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki "BizTalk Server: Performance Tuning & Optimization"

    Monday, April 30, 2012 6:26 PM
    Moderator
  • Hi Chandra,

    thanks for your advice. I have used GACUTIL to remove /U the existing DLL, and registered the rebuild one with /I. Tried to register it with different path and the like. Retried to rebuild the BT solution several times, but the outcome hasn't changed: same error in Visual Studio, and the same error in the event log.

    Tim

    Monday, April 30, 2012 6:44 PM
  • Hi Naushad, yes, this also was one of my first thoughts, beneath Dot Net Version mix issues. But that does not seem to be the case. 

    I am not sure whether I overlooked something, but it seems to me that one of earlier error messages has now slightly changed:

    Instead of 

    Error loading assembly "c:\<my c sharp helper dll for my biztalk application>.DLL".

    the message is now saying

     Error loading assembly "c:\<my c sharp helper dll for my biztalk application>.clrtypes.DLL".

    It looks like an XML serialization of CLR types is impossible, but that doesn' tmake sense, does it? And where is the DLL supposed to come from?

    Monday, April 30, 2012 7:20 PM
  • Hi 

    If you are using a non serializable class in BizTalk Orchestration then you would need to use atomic scope to use the object. Please refer Why does the compiler require my variable to be serializable? 

    If that is the case then follow below steps to call the method of the custom class  , they are from this post

    Add a reference of that dll (class). The class must be strongly signed and in the GAC.

    • Make sure your transaction type of Orchestration is Long Running transactional.
      Add an Atomic scope.
      Create an Orchestration variable of that class inside the scope.
      Create an instance on that object inside the scope.
      Call the method.

    Make sure the host type is correct.

    I hope this helps!


    HTH,
    Naushad Alam

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
    alamnaushad.wordpress.com
    My new TechNet Wiki "BizTalk Server: Performance Tuning & Optimization"

    Monday, April 30, 2012 7:37 PM
    Moderator
  • Have you used fuslogvw.exe to see what's failing to bind in greater detail?

    -Dan


    If this answers your question, please Mark as Answer

    Monday, April 30, 2012 8:44 PM