如何在SSIS中运行Excel宏时修复System.NullReferenceException错误?
我在SSIS 2008上设置了一个包,其中包含一个运行excel宏的vb脚本。它在Business Intelligence Development Studio(BIDS)2008上运行,但仍然出现以下错误:如何在SSIS中运行Excel宏时修复System.NullReferenceException错误?,ssis,Ssis,我在SSIS 2008上设置了一个包,其中包含一个运行excel宏的vb脚本。它在Business Intelligence Development Studio(BIDS)2008上运行,但仍然出现以下错误: Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceExcept
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at ST_e916156b0e6449b58e21905bd635ecf0.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.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature 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 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Executed as user: 'myusername'.
Code: 0xFFFFFFFF
Source: Run macro script excel macro Description: Microsoft Excel cannot access the file 'book1.XLS'.
There are several possible reasons:
? The file name or path does not exist.
? The file is being used by another program.
? The workbook you are trying to save has the same name as a currently open workbook.
End Error
DTExec: The package execution returned DTSER_SUCCESS (0).
Started: 11:18:15 Finished: 11:18:19
Elapsed: 3.775 seconds.
The package executed successfully. The step succeeded.
另外,当我使用SQL agent运行包时,作业成功,但宏未执行,并且出现以下错误:
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at ST_e916156b0e6449b58e21905bd635ecf0.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.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature 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 System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
Executed as user: 'myusername'.
Code: 0xFFFFFFFF
Source: Run macro script excel macro Description: Microsoft Excel cannot access the file 'book1.XLS'.
There are several possible reasons:
? The file name or path does not exist.
? The file is being used by another program.
? The workbook you are trying to save has the same name as a currently open workbook.
End Error
DTExec: The package execution returned DTSER_SUCCESS (0).
Started: 11:18:15 Finished: 11:18:19
Elapsed: 3.775 seconds.
The package executed successfully. The step succeeded.
但是,我可以完全访问本地服务器和网络,并且尝试在32位和64位上运行,但没有成功
如何解决此问题?您可以尝试的事项:
根据我个人的经验,Excel在使用SSI时总是很棘手的。从错误消息中可以看到,请验证是否可以排除与问题相关的以下信息
- 检查运行SQL Server代理服务的用户帐户。您可以通过导航到
\Windows开始
\控制面板
\管理工具
来完成此操作。查找名为SQL Server Agent()的服务服务
- 确保该帐户可以访问存储Excel文件的文件夹
- 确认您没有打开Excel文件
- 在SQL Server代理作业上,单击执行包的步骤。如果您正在SQL Server Integration Services包的类型下运行该包,请确保选中了“执行选项”选项卡上的“用户32位运行时”框
- 也可以手动双击包文件(.dtsx)。这将带来执行包的DTEXEC实用程序。如果您使用的是配置文件,请在“配置”选项卡上附加配置文件。运行包。如果它在凭据下的DTEXEC实用程序中运行,而不是在SQLServer代理下运行,我通常会发现这与权限问题有关