SSIS 脚本任务 COMException/FileNotFoundException 错误 [英] SSIS Script Task COMException / FileNotFoundException error

查看:35
本文介绍了SSIS 脚本任务 COMException/FileNotFoundException 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我把它放在一个 .vbs 文件中并运行它,我有以下 VBS 运行没有任何问题.

Hi I have the follow VBS that runs without any problem if I put it in a .vbs file and run it.

Dim objshell
Set objshell = CreateObject("Shell.Application")
objshell.NameSpace("C:Temp").CopyHere(objshell.NameSpace("C:TempTest.zip").Items())
Set objshell = Nothing

但是如果我将它剪切并粘贴到 SSBI 2008 中的脚本任务中,它会运行并出现错误

But if I cut and paste it into a script task in SSBI 2008, it runs with the error

Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x80020003): Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))
   at Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType)
   at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSetComplex(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase)
   at ST_a4312d30d99b4cc4b02a2198afbc77d9.vbproj.ScriptMain.Main()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Task failed: Script Task

我相信必须在 SSBI 内部设置一些配置而不是默认运行才能使其正常工作.我是否必须改用 C# 并不重要.但只是不要让我使用和安装任何 3rd 方的东西.系统运行的是 Windows 7,安装了 .NET 4.5.

I believe there has to be some configuration inside SSBI to be set instead of just running by default in order to make this working. It doesn't matter if I will have to use C# instead. But just dont ask me to use and install any 3rd party stuff. The system is running Windows 7 with .NET 4.5 installed.

请帮忙!谢谢!

推荐答案

我想通了配置,但有点复杂.

I figured out the configuration but it is somewhat complicate.

  1. 打开您的脚本任务,编辑脚本.当脚本编辑窗口打开时,将上面的脚本放到 Sub Main 中,稍作改动:

  1. Open your script task, Edit Script. When the script editing window opens, place the above script to Sub Main with a little changes:

暗淡的 objshell

Dim objshell

变成

将 objshell 调暗为 Shell

Dim objshell As Shell

  • 转到项目->st_xxxxx 属性,签名,勾选程序集签名,选择新建,输入任意文件名,取消勾选保护我的文件使用密码.

  • Go to Project->st_xxxxx Properties, Signing, tick sign the assembly, select New, type any file name, untick Protect my file with a password.

    转到引用"、添加"、COM",选择Microsoft Shell 控件和自动化",然后确定.

    Go to References, Add, COM, select Microsoft Shell Controls And Automation, OK.

    ** 您应该会看到一个弹出窗口,提示未找到模板信息...,请忽略它.**

    ** You should see a popup saying No template information found..., just ignore that. **

    突出显示您刚刚添加的 Microsoft Shell 控件并查看右下角的属性部分,确保强名称"为 True.

    Highlight the Microsoft Shell Controls you just added and look at the bottom right properties section, make sure "Strong Name" is True.

    (如果您还没有完成第 2 步,这应该是 False,重做第 2 步并确保这是 True)

    (if you haven't done step 2., this should be False, redo step 2 and make sure this is True)

    打开我的电脑,进入生成的Microsoft Shell Controls dll的路径(见高亮的路径,通常是C:UsersxxxxxxxAppDataLocalTempSSISyyyyyyyyyyyyyyyyyobjDebugInterop.Shell32.dll).复制到其他地方(因为每次编辑脚本时都会随机生成原始路径yyyyyyyyyyyyy,导致每次签名的dll都消失了).

    Open My Computer and go to the path of the generated Microsoft Shell Controls dll (see the highlighted Path, usually it is C:UsersxxxxxxxAppDataLocalTempSSISyyyyyyyyyyyyyyyyyobjDebugInterop.Shell32.dll). Copy it to somewhere else (its because the original path yyyyyyyyyyyyyy is randomly generated everytime you edit your script, causing that the signed dll gone everytime).

    回到 Project->st_xxxxx Properties,删除突出显示的 Microsoft Shell Controls.点击添加,浏览,选择刚才复制的Interop.Shell32.dll,OK.再次确保强名称属性为 True.如果没有,请重做第 2 步.

    Back to the Project->st_xxxxx Properties, remove the highlighted Microsoft Shell Controls. Click Add, Browse, select the Interop.Shell32.dll you just copied, OK. Again, make sure the Strong Name property is True. If not, redo from step 2.

    仍然在引用,在导入的命名空间下,向下滚动以勾选 Shell32 旁边的框.

    Still at References, under Imported namespaces, scroll down to tick the box next to Shell32.

    转到签名,取消对程序集签名.转到右上角的项目资源管理器,删除您在步骤 2 中创建的密钥文件 (xxxx.snk)(删除项目资源管理器中的密钥文件,而不是从您的文件夹中,确保它不再包含在您的项目资源管理器或您的脚本中任务不会运行).

    Go to Signing, untick Sign the assembly. Go to Project Explorer on top right, delete the key file (xxxx.snk) you created at step 2 (delete the key file within Project Explorer, not from your folder, make sure it is not included in your Project Explorer anymore or your script task wont run).

    全部保存并关闭脚本编辑窗口.

    Save all and close the Script Editing window.

    在您的计算机中找到gacutil.exe".您应该将它与 SSIS 的安装一起使用.它位于 C:Program Files(x86)Microsoft SDKsWindowsv7.0Ainx64.输入 gacutil -i "路径您在第 5 步中复制的 Interop.Shell32.dll".

    Locate "gacutil.exe" in your computer. You should have it together with the installation of SSIS. Its under C:Program Files (x86)Microsoft SDKsWindowsv7.0Ainx64. Type gacutil -i "path of your copied Interop.Shell32.dll in step 5".

    例如gacutil -i F:CodeInterop.Shell32.dll

    e.g. gacutil -i F:CodeInterop.Shell32.dll

  • 完成所有这些步骤后,您的脚本任务应该可以正常运行.当然,如果您使用其他 COM 引用,则需要这些步骤.让我知道是否有一些更简单的方法来完成这项工作.希望这会有所帮助.

    After all these steps, your script task should run without problems. Of course, these steps are needed if you are using other COM references. Let me know if there are some easier ways to do the job. Hope this helps.

    这篇关于SSIS 脚本任务 COMException/FileNotFoundException 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆