Skip to main content

I created a sample web application (File-> New -> ASP.NET WebApplicaiton -> MVC 4) builds fine, then I added a reference to "SourceCode.Workflow.Client.dll"
and when building I get a warning as below

 

      1>------ Build started: Project: WebApplication1, Configuration: Debug Any CPU ------
       1>C:Program Files (x86)MSBuild12.0inMicrosoft.Common.CurrentVersion.targets(1696,5): warning MSB3270: There was a mismatch between the            processor architecture of the project being built "MSIL" and the processor architecture of the reference "SourceCode.Workflow.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=16a2c5aaaa1b130d, processorArchitecture=x86", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.
1> WebApplication1 -> C:DevWebApplication1WebApplication1inWebApplication1.dll
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

 

When I ran the application I got below error

 

     Could not load file or assembly 'SourceCode.Workflow.Client' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I tried changing the build configuration to x64 and I was able to get rid of the warning as below

 

       1>------ Build started: Project: WebApplication1, Configuration: Debug x64 ------
       1> WebApplication1 -> C:DevWebApplication1WebApplication1inWebApplication1.dll
        ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

But when I run, I still get the error

 

     Could not load file or assembly 'SourceCode.Workflow.Client' or one of its dependencies. An attempt was made to load a program with an incorrect format.

I have also tried to set the "useLegacyV2RuntimeActivationPolicy" in web config file as below

 

           <startup useLegacyV2RuntimeActivationPolicy="true"> </startup>

I still got the same error.

 

Please let me know the correct way to add the assemblies like

          SourceCode.Workflow.Client.dll

          SourceCode.HostClientAPI.dll

          SourceCode.SmartObjects.Client.dll
to a ASP.NET MVC web application.

 

Any help is appreciated.

Thanks

Hi,

 

I have used all of these K2 dlls in the console application and was getting the same error while trying to build. Changing the target framework in project properties to .Net Framework 3.5  worked.

 

By default MVC v4 targets .NET 4.5, I think these dlls would not work directly in MVC4, I am not sure about it.

 

Option 1.

You might create another class project by targeting it to 3.5 framework. Do all the k2 related operations in that project and then use that project DLL reference in your MVC 4 application.

 

Option 2.

There are web services, WCF services API provided by K2. You can do all the client side operations (action the worklist, get worklist items etc..) with services but it does not provide any API for administration functionality like got to activity etc..

 

Option 3

You could always create class project same as option 1 and expose the dll WCF service.

 

I would go for option 3

Let me know if this helps or approach you would follow.

 

-Yadnesh

http://spandk2.blogspot.com/

 


Thanks for the reply Ypawar, 

 

   After some trail and error, I was able add the SourceCode.Workflow.Client.dll directly to ASP.NET MVC project but you should know whether the .dll is build for x86 or x64. Based on the dll you add to prject you have to change the platform target of your MVC project. 

 

 For example if you use the x86 version of dll you should change the platform target of your MVC project to x86.

 

 You can find the x64 dlls in "C:Program Files (x86)K2 blackpearlHost ServerBin" location.

 

  I am also attaching the dll to this post.


Reply