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

问题描述

您好我有运行没有任何问题,如果我把它放在一个.vbs文件并运行它。后续的VBS

 暗淡objshell
设置objshell =的CreateObject(Shell.Application)
objshell.NameSpace(C:\ TEMP)CopyHere。(objshell.NameSpace(C:\ TEMP \ Test.zip)项目())
设置objshell =什么
 

但是,如果我剪切并粘贴到在2008年SSBI脚本任务,它与错误运行

 错误:为0x1的脚本任务:System.Reflection.TargetInvocationException:异常被抛出调用的目标。 ---> System.Runtime.InteropServices.COMException(0x80020003):找不到成员。 (从HRESULT异常:0x80020003(DISP_E_MEMBERNOTFOUND))
   在Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(对象o,类型和放大器; OBJTYPE,字符串名称,对象[] ARGS,字符串[] paramnames,布尔OptimisticSet,CALLTYPE UseCallType)
   在Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(对象实例,类型类型,字符串成员名,对象[]参数,字符串[] ArgumentNames,类型[] TypeArguments,布尔OptimisticSet,布尔RValueBase,CALLTYPE CALLTYPE)
   在Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSetComplex(对象实例,类型类型,字符串成员名,对象[]参数,字符串[] ArgumentNames,类型[] TypeArguments,布尔OptimisticSet,布尔RValueBase)
   在ST_a4312d30d99b4cc4b02a2198afbc77d9.vbproj.ScriptMain.Main()
   ---内部异常堆栈跟踪的结尾---
   在System.RuntimeMethodHandle._InvokeMethodFast(对象的目标,对象[]参数,SignatureStruct和放大器; SIG,MethodAttributes methodAttributes,的RuntimeTypeHandle typeOwner)
   在System.Reflection.RuntimeMethodInfo.Invoke(obj对象,的BindingFlags invokeAttr,粘合剂粘合,对象]参数,CultureInfo的文化,布尔skipVisibilityChecks)
   在System.Reflection.RuntimeMethodInfo.Invoke(obj对象,的BindingFlags invokeAttr,粘合剂粘合,对象]参数,CultureInfo的文化)
   在System.RuntimeType.InvokeMember(字符串名称,的BindingFlags的BindingFlags,活页夹粘结剂,对象目标,对象[] providedArgs,ParameterModifier []调节剂,CultureInfo的文化的String [] namedParams)
   在Microsoft.SqlServer.Dts.Tasks.ScriptTask.VS​​TATaskScriptingEngine.ExecuteScript()
任务失败:脚本任务
 

我认为必须有一些配置SSBI内要设置的只是默认情况下,为了使这个工作运行代替。没关系,如果我将不得不使用C#来代替。但就不要问我使用和安装任何第三方的东西。该系统运行的是Windows 7与.NET 4.5安装。

请帮忙!谢谢!

解决方案

我想通了配置,但它是有点复杂的。

  1. 打开脚本任务,编辑脚本。当脚本编辑窗口打开,将上面的脚本来分主要有少许变化:

    变为

  2. 转到项目 - > st_xxxxx属性,签名,签署打勾装配,选择新建,输入任意文件名,取消选中保护我的文件使用密码。

  3. 去引用,添加,COM,选择微软壳牌控制和自动化,OK。

    **你应该看到一个弹出说找不到模板信息......,就忽略这个问题。 **

  4. 选中刚刚添加,并期待在右下角属性部分中,确保强名称微软壳牌控制为True。

    (如果你还没有做第2步,这应该是假的,重做第2步,并确保这是真的)

  5. 打开我的电脑,然后转到生成微软壳牌的路径控件DLL(见突出显示的路径,通常是C:\用户\ XXXXXXX \应用程序数据\本地的\ Temp \ SSIS \ yyyyyyyyyyyyyyyyy \ OBJ \调试\ Interop.Shell32.dll)。将其复制到其他地方(因为它的原始路径yyyyyyyyyyyyyy是随机生成的,每次你编辑你的脚本,导致该DLL签署了每次)。

  6. 回到项目 - > st_xxxxx属性,删除突出微软壳牌控制。单击添加,浏览,选择您刚才复制的Interop.Shell32.dll,确定。同样,确保强名称属性为True。如果不是这样,从第2步重新操作。

  7. 不过,在参考文献,在导入的命名空间,向下滚动到勾选框旁边的SHELL32。

  8. 去签名,勾去掉登录大会。转到项目资源管理器右上方,删除您在步骤2中创建的密钥文件(xxxx.snk)(删除工程资源管理器中的关键文件,而不是从你的文件夹,请确保它不包含在你的项目资源管理器了,或你的脚本任务不会运行)。

  9. 保存并关闭脚本编辑窗口。

  10. 定位于您的电脑的Gacutil.exe。你应该把它连同SSIS的安装。它在C:\ Program Files文件(x86)的\微软的SDK \的Windows \ v7.0A \ BIN \ 64。键入GACUTIL的-i路径您在步骤5中复制Interop.Shell32.dll。

在所有这些步骤,你的脚本任务应运行没有问题。当然,如果你使用的是其他的COM引用需要这些步骤。让我知道,如果有一些更容易的方法来完成这项工作。希望这有助于。

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:\Temp\Test.zip").Items())
Set objshell = Nothing

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

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.

Please help! Thank you!

解决方案

I figured out the configuration but it is somewhat complicate.

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

    becomes

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

  3. 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. **

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

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

  5. Open My Computer and go to the path of the generated Microsoft Shell Controls dll (see the highlighted Path, usually it is C:\Users\xxxxxxx\AppData\Local\Temp\SSIS\yyyyyyyyyyyyyyyyy\obj\Debug\Interop.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).

  6. 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.

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

  8. 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).

  9. Save all and close the Script Editing window.

  10. Locate "gacutil.exe" in your computer. You should have it together with the installation of SSIS. Its under C:\Program Files(x86)\Microsoft SDKs\Windows\v7.0A\bin\x64. Type gacutil -i "path ofyour copied Interop.Shell32.dll in step 5".

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异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-16 01:52