sql server - SSIS(VS 2012) Issue with VB script compounent -
i facing issue in ssis. upgraded project vs 2005 vs 2012 , of packages upgraded @ same time. of them work well, except 1 use script task check if file exists in folder before working on data flat file.
since upgrade, when launch package script task:
- if file present in folder, works well.
- if file missing, crashes after "else" clause on : dts.events.fireerror(0, "flatfile", "error loading '" + filepath + "', flat file not found", string.empty, 0) following error message:
exception has been thrown target of invocation. @ system.runtimemethodhandle.invokemethod(object target, object[] arguments, signature sig, boolean constructor) @ system.reflection.runtimemethodinfo.unsafeinvokeinternal(object obj, object[] parameters, object[] arguments) @ system.reflection.runtimemethodinfo.invoke(object obj, bindingflags invokeattr, binder binder, object[] parameters, cultureinfo culture) @ system.runtimetype.invokemember(string name, bindingflags bindingflags, binder binder, object target, object[] providedargs, parametermodifier[] modifiers, cultureinfo culture, string[] namedparams) @ microsoft.sqlserver.dts.tasks.scripttask.vstataskscriptingengine.executescript()**
and crashes on end sub following error message:
exception has been thrown target of invocation. @ system.runtimemethodhandle.invokemethod(object target, object[] arguments, signature sig, boolean constructor) @ system.reflection.runtimemethodinfo.unsafeinvokeinternal(object obj, object[] parameters, object[] arguments) @ system.reflection.runtimemethodinfo.invoke(object obj, bindingflags invokeattr, binder binder, object[] parameters, cultureinfo culture) @ system.runtimetype.invokemember(string name, bindingflags bindingflags, binder binder, object target, object[] providedargs, parametermodifier[] modifiers, cultureinfo culture, string[] namedparams) @ microsoft.sqlserver.dts.tasks.scripttask.vstataskscriptingengine.executescript()**
if disable dts.events.fireerror still got same error on end sub
here code(visual basic 2012):
imports system imports system.data imports system.math imports microsoft.sqlserver.dts.runtime <microsoft.sqlserver.dts.tasks.scripttask.ssisscripttaskentrypointattribute> _ <system.clscompliantattribute(false)> _ partial public class scriptmain inherits microsoft.sqlserver.dts.tasks.scripttask.vstartscriptobjectmodelbase enum scriptresults success = microsoft.sqlserver.dts.runtime.dtsexecresult.success failure = microsoft.sqlserver.dts.runtime.dtsexecresult.failure end enum public sub main() dim filepath string filepath = "\\localhost\mypath" if my.computer.filesystem.fileexists(filepath) if filelen(filepath) > 0 dts.taskresult = scriptresults.success else dts.events.fireerror(0, "flatfile", "error loading '" + filepath + "', flat file not found", string.empty, 0) dts.taskresult = scriptresults.failure end if else dts.events.fireerror(0, "flatfile", "error loading '" + filepath + "', flat file not found", string.empty, 0) dts.taskresult = scriptresults.failure end if end sub
end class
i expect issue not providing return status subroutine
if my.computer.filesystem.fileexists(filepath) , filelen(filepath) > 0 dts.taskresult = scriptresults.success else dts.events.fireerror(0, "flatfile", "error loading '" + filepath + "', flat file not found", string.empty, 0) dts.taskresult = scriptresults.failure end if
edit
expectations 1 thing debugging another. set break point @ step assigned filepath. root problem filelen
operation trying check size of file doesn't exist. here can see filenotfoundexception thrown , unhandled.
Comments
Post a Comment