Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS error - Exception_Access_Violation

Status
Not open for further replies.

stnkyminky

Programmer
Oct 15, 2001
476
US
I'm experiencing an error when running a dts package from a C# application. According to the event log the error is "EXCEPTION_ACCESS_VIOLATION". The error doesn't occur each time but maybe one or two times a day. The errors didn't start happening until last week. I know this is cliche but I've not made any modifications to the application or the sql server. If anyone has experienced this problem, please share how you've solved it.

Thanks.


Background:
The application reads a list of dts packages names from a file. The user then selects which package(s) they wish to run. After selecting the packages, the user will press a button that begins calling the selected packages and executes them. This application is installed and ran from a TS session.

Scott
Programmer Analyst
<{{><
 
I don't think the C# is the cause.
I would do/check the followings:
- The .dts files are not open with exclusive access from time to time by others processes.
- Use try-catch bloc to locate exactly the line and the inner error. Could be when the task is linked to package or when running the package.
If the error occurs when running the package then you should look on the database settings :concurent tasks, table spaces, what are doing sometime the package you are executing. Maybe there is the same package which throws the error.
Code:
try
{
DTS.Task objTask = new DTS.Task();
DTS.Package objPack = new DTS.Package();
DTS.ExecutePackageTask objCustTask = new DTS.ExecutePackageTask();

//...
objCustTask.FileName = "C:\\myfile.dts";
//..
objPack.Tasks.Add(objTask); // Link task to package
//..

objPack.Execute();   // Run task
//..
}
catch ( Exception ex)
{
   string sErr = "Package: " + objCustTask.FileName + ex.GetType()+ ex.Message;
   // Log somewhere, for example in Event Log 
    WriteToEventLog(sErr,0);
}

Here is the WriteToEventLog() function:
Code:
private bool WriteToEventLog(string Msg, int logType )
{
	EventLog logObj = null;
	try
	{
		Process p = Process.GetCurrentProcess();
		string sAppName = p.MainModule.ModuleName.ToString();
		// Create the source, if it does not already exist.			
		if(!EventLog.SourceExists(sAppName))
			EventLog.CreateEventSource(sAppName, "Application");	


		logObj = new EventLog();
		logObj.Source = sAppName;

		switch(logType)       
		{         
			case 1: 
				logObj.WriteEntry(Msg,EventLogEntryType.Information,0);
				break;
			case 2:   
				logObj.WriteEntry(Msg,EventLogEntryType.Warning,0);
				break;                       
			case 0:            
				logObj.WriteEntry(Msg,EventLogEntryType.Error,0);
				break;
			default: 
				return false;     
		}
		return true;

	}
	catch (Exception e)
	{
		string sDummy = e.Message;
		return false;
	}
	finally 
	{
		logObj = null;
	}
}
-obislavu-
 
I was using a try..catch block but writing different data to the log. I've modified the code and will update you on what I find. So far no errors........

thanks.

Scott
Programmer Analyst
<{{><
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top