我的ssis作業包裡用了一個script task,會查詢一個http的頁面接口,擷取json資料後解析然後做後續處理,其中解析json引用了本地目錄下的第三方的類庫:Newtonsoft.Json.dll
在vs環境中調試包的時候報錯
<a href="http://my.oschina.net/u/221218/blog/291433">?</a>
1
2
3
4
5
<code> </code><code>在 System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)</code>
<code> </code><code>在 System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)</code>
<code> </code><code>在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)</code>
<code> </code><code>在 System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)</code>
<code> </code><code>在 Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()</code>
檢查後發現:dll沒有正确注冊,需要做如下操作:
将dll拷貝到sqlserver的程式目錄中,我的sqlserver是2012,版本号就是110,則檔案需要拷貝到...\110\DTS\PipelineComponents目錄中
向将類庫注冊到.net framework gac中,注冊工具室gacutil.exe,因為我的dll是基于.net 4.0的,是以也需要使用4。0的gacutil,但是.net framework 隻有1.1才有這個工具,版本卻不對,不過這個工具在visual studio的安裝中帶了,我的vs版本為2012,則在系統應用程式目錄下可以找到,我的目錄是C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin中可以找到gacutil.exe,執行 gacutil.exe /i ***.dll,成功注冊,再執行ssis package,不再出現以上錯誤。
C:\WINDOWS\system32>cd C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>gacutil.exe /i C:\Users\LAY\Desktop\Newtonsoft.Json.dll Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.18020 版權所有(C) Microsoft Corporation。保留所有權利。
程式集已成功添加到緩存中
====================
批處理檔案: