从 SSIS 脚本任务调用非托管代码
Call Unmanaged Code from SSIS Script Task
我有商业智能 -> 集成服务项目,其中有 SSIS 包 -> 脚本任务。我需要使用 DllImport 从脚本任务非托管代码调用。由于我不知道在 运行 期间脚本任务的代码存储在哪里,所以我无法调用我的非托管 dll。
下面的脚本任务示例代码:
using System; // Console
using System.Runtime.InteropServices; // DllImport
class App
{
[DllImport("lib.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int next(int n);
static void Main()
{
Console.WriteLine(next(0));
Dts.TaskResult = (int)ScriptResults.Success;
}
}
您可以找到有关脚本任务的更多信息here
问题:如何从 SSRS 包 -> 脚本任务调用非托管代码?
SSIS 不会按位置加载 dll,即使是托管 dll。您必须对它们进行 GAC,http://microsoft-ssis.blogspot.com/2011/05/referencing-custom-assembly-inside.html . I would therefore expect you to have to COM register your unmanaged dll, https://technet.microsoft.com/en-us/library/bb490985.aspx .
确保将 c/c++ dll 复制到“C:\Program Files\Microsoft SQL Server0\DTS\Binn”将在托管代码调用 DllImport
时加载
注意:120 是特定于版本的,请确保复制到您拥有的正确版本。
我有商业智能 -> 集成服务项目,其中有 SSIS 包 -> 脚本任务。我需要使用 DllImport 从脚本任务非托管代码调用。由于我不知道在 运行 期间脚本任务的代码存储在哪里,所以我无法调用我的非托管 dll。
下面的脚本任务示例代码:
using System; // Console
using System.Runtime.InteropServices; // DllImport
class App
{
[DllImport("lib.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int next(int n);
static void Main()
{
Console.WriteLine(next(0));
Dts.TaskResult = (int)ScriptResults.Success;
}
}
您可以找到有关脚本任务的更多信息here
问题:如何从 SSRS 包 -> 脚本任务调用非托管代码?
SSIS 不会按位置加载 dll,即使是托管 dll。您必须对它们进行 GAC,http://microsoft-ssis.blogspot.com/2011/05/referencing-custom-assembly-inside.html . I would therefore expect you to have to COM register your unmanaged dll, https://technet.microsoft.com/en-us/library/bb490985.aspx .
确保将 c/c++ dll 复制到“C:\Program Files\Microsoft SQL Server0\DTS\Binn”将在托管代码调用 DllImport
时加载注意:120 是特定于版本的,请确保复制到您拥有的正确版本。