This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Proposed Answer This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

  • 2012年4月16日 15:02
     
      包含代码

    Hi guys,

    I am trying to load a custom assembly with “SQL Server MDs Workflow Integration”. However, I get the following error:

    Error loading workflow type extender:

    System.BadImageFormatException: Could not load file or assembly 'WorkflowService' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

    File name: 'WorkflowService'

    The WorkflowService requires ASP.NET 4.0. But, as you can see in the log bellow here, the .Net v2.0 is loaded instead.

    LOG: This bind starts in default load context.

    LOG: Using application configuration file: C:\Program Files\Microsoft SQL Server\110\Master Data Services\WebApplication\bin\Microsoft.MasterDataServices.Workflow.exe.Config

    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.

    LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).

    LOG: Attempting download of new URL file:///C:/Program Files/Microsoft SQL Server/110/Master Data Services/WebApplication/bin/WorkflowService.DLL.

    ERR: Failed to complete setup of assembly (hr = 0x8013101b). Probing terminated.

    - I have set the Application pool to v4.0.

    - ReInstalled .Net 4.0

    - Run the ASPNET_regiis.exe

    - I have even added the following settings into web.config with no results:

                    <startup>
                                    <supportedRuntime version="v4.0" safemode="true"/>
                                    <requiredRuntime version="v4.0" safemode="true"/>
                    </startup>

    Does anyone have experience with this issue?

    This is my code:

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.MasterDataServices.WorkflowTypeExtender; using System.Xml; using System.Data.SqlClient; using System.Diagnostics; namespace MDS { public class WorkflowService : IWorkflowTypeExtender { void IWorkflowTypeExtender.StartWorkflow(string workflowType, XmlElement dataElement) { EventLog.WriteEntry("MDS", "WORKS?", EventLogEntryType.Error); switch (workflowType) { case "BR_Relationship_Default_Items": ExecuteBusinessRule_Items_Defaults(dataElement); break; default: break; } } private void ExecuteBusinessRule_Items_Defaults(System.Xml.XmlElement message) { .....

    } } }


    Project setting:


    • 已编辑 developer554654 2012年4月16日 15:05 removed db settings + cleaned code
    •  

全部回复

  • 2012年4月17日 20:43
     
     

    I am having the exact same issue.  I posted to a forum yesterday and someone form MS said they would get back to me.

    If I hear anything I will let you know.


    Jonathan

  • 2012年4月17日 21:04
     
     建议的答复

    I found the solution: 

    - You should develop and compile only in .Net 3.5 and lower.

    - Make sure that also your other assembly references are not 4.0 (check the properties) 

    -  If you are using SQL Server 2012, then use should use Microsoft.MasterDataServices.WorkflowTypeExtender instead of  Microsoft.MasterDataServices.Core.Workflow

    I hope this will help you resolving the issue.

    • 已建议为答案 Henry Ong 2012年5月1日 23:42
    •  
  • 2012年4月17日 21:35
     
     

    Thank you.  Wha other references are you referring to?  Th eonly one I ma referencing is this one that is already present Microsoft.MasterDataServices.WorkflowTypeExtender.dll.

    Can I change the properties on this?  Forgive the questions but I ma not a VS developer only a very frustrated Sharepoint archtect whose boss is very upset that the MDS SharePoint workflow feature in SQL 2012 doesn't work.

    Thanks


    Jonathan

  • 2012年4月18日 7:54
     
     

    The one you are using in the correct one. I was refering to the following setting: Runtime Version should be v2.050727

    And make sure that your target framework is NOT v4.0!

  • 2012年4月18日 7:54
     
     

    The one you are using in the correct one. I was refering to the following setting: Runtime Version should be v2.050727

    And make sure that your target framework is NOT v4.0!

  • 2012年4月18日 10:33
     
     

    Thanks.

    When you are building the solution are using  Compile or Embedded Resource for the build Action?  When I use Complie, I receive errors as it does not recognize the SP calsses built in the sample code?


    Jonathan

  • 2012年4月18日 10:58
     
     
    You mean the option "Copy Local" under References? Mine is set to: False
  • 2012年4月18日 12:58
     
     

    That is good to know information but what about these settings?

    SHould BUild Action Be "Complie" or Embedded Resorce? When I use Compile it errors out.

    Thanks


    Jonathan

  • 2012年4月18日 13:29
     
     

    Mine is as follows:

    Build Action: Complie

    Copy to Output Directory: Do not copy

    What you could try is to start a new project and when selecting the template use Frame 3.5 in advance. Maybe that might help.

  • 2012年4月18日 13:45
     
     
    Thanks

    Jonathan

  • 2012年5月2日 8:12
     
     
    Got the problem fixed? Please share your solution.