当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - Sharepoint 2010 - how to communicate with ServiceStack.net services?

问题描述:

Is it possible to communicate between SharePoint 2010 and servicestack services using strongly typed clients? ServiceStack client lib is running on .net 4 framework (it is not correct see my edits section) ( SP2010 is on .net 3.5) causing BadFormatImage exception...

I tried to connect by WCF wizard (from sharepoint designer) but it was unsuccessful.

EDIT

The real problem is in my nant task signing stack libs. I used .net 4 ilasm instead of 2.0.

<target name="signss" description="sign service stack assemblies">

<foreach item="File" property="filename">

<in>

<items basedir="lib">

<include name="**/ServiceStack*.dll" />

</items>

</in>

<do>

<echo message="${filename}"/>

<echo message="${path::get-directory-name(filename)}"/>

<exec failonerror="true" program="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ildasm.exe">

<arg value="${filename}" />

<arg value="/out:${path::get-directory-name(filename)}/${path::get-file-name-without-extension(filename)}.il" />

</exec>

<exec failonerror="true" program="C:\Windows\Microsoft.NET\Framework64\v2.0.50727\ilasm.exe">

<arg value="${path::get-directory-name(filename)}/${path::get-file-name-without-extension(filename)}.il" />

<arg value="/dll" />

<arg value="/key=ss.snk" />

<arg value="/output=${path::get-directory-name(filename)}/${path::get-file-name-without-extension(filename)}.dll" />

</exec>

</do>

</foreach>

</target>

Nant task now sign and recompiles libraries to .net 2 assemblies but still I have got problem when I try to use ServiceStack.Common in my sharepoint 2010 solution.

var client = new JsonServiceClient("http://host:8080/");

gives error

Error 16 The type 'ServiceStack.Service.IServiceClientAsync' is defined in an assembly that is not referenced. You must add a reference to assembly 'ServiceStack.Interfaces, Version=3.9.60.0, Culture=neutral, PublicKeyToken=null'.

I should change public key token in referenced assemblies, now is null ... I will try to edit nant task to correct that key on .il files.

网友答案:

If you would like to use Service Stack Client with sharepoint 2010 you should:

  • Download sources from github (the newest commits using .net 3.5):

ServiceStack https://github.com/ServiceStack/ServiceStack/commit/4cdc5b5a87ea18dce77840252b72e680e29a6bd5

ServiceStack.Text https://github.com/ServiceStack/ServiceStack.Text/commit/cd1f130c1a9a2c4c79e62fb3e487197956d1f56b

  • Sign assemblies ServiceStack.Common, ServiceStack.Text, ServiceStack.Interfaces
分享给朋友:
您可能感兴趣的文章:
随机阅读: