Showing posts with label errors. Show all posts
Showing posts with label errors. Show all posts

Sunday, March 11, 2012

Custom Logger Doesn't Work in Certain cases

I am testing a set of SSIS packages, In order to test my SSIS packages for errors I have two negative test cases

1) I didn't provide checkpoint file for the checkpoint enabled package.

2) I provide a wrong configuration file

Even though I am using a script task in my "on error" event of my SSIS package. It is not executed. (Perhaps because the package doesn't even execute).

My problem is that SSIS itself puts just a simple one liner in windows event log "Package Failure Error". It does not provide which package failed, why it failed etc. Therefore the admin who gets the ticket to resolve the issue has no clue of what is going wrong and where!

Since my custom logger doesn't even run, I don't know how can I put more details into the windows event log.

How can I resolve this?

regards,

Abhishek.

Sorry to bump so soon, but I am really stuck here.

|||Loggers don't even enter the picture on malformed configuration file warnings/errors. Malformed configurations files are detected at package load time, even before validation. So, if you have a logger ( custom or stock, doesn't matter) defined inside the package, warnings like "invalid xml configuration file" won't be sent there.

The sequence for possible package execution is as follows:
1. Package Load (warnings/errors such as invalid configuration file happen here )
2. Package Validation
3. Package Execution (with validation too)

To trap package load errors, you could capture dtexec's console log output (if you're using that mechanism for package execution).

To implement your own logging; that is, to catch warnings/errors early in the package lifespan without using dtexec's console logger to do so, implement IDTSEvents (by subclassing DefaultsEvents) on package load. See Loading and Running a Local package programmatically (the capturing events from a running package section)

For example, the following will log package load,validate,and execute events, while loggers will get validate and execute events.

Code Snippet

using System;
using System.Diagnostics;
using Microsoft.SqlServer.Dts.Runtime;

namespace IS
{
class PackageRunner
{
static void Main(string[] args)
{
string pkgFileName = args[0];
ISEventsListener eventListener = new ISEventsListener();
// subclass of DefaultEvents

Application isApp = new Application();
// listen for pre-validation errors via LoadPackage
using (Package pkg = isApp.LoadPackage(pkgFileName, eventListener))
{
DTSExecResult validationOutcome = pkg.Validate(null, null, eventListener, null);
if (validationOutcome == DTSExecResult.Success)
{
DTSExecResult executionOutcome = pkg.Execute(null, null, eventListener, null, null);
}
}
Console.WriteLine("Press something...");
Console.ReadKey();
}
}
}

Checkpoint files are a different story, a missing checkpoint file setting will be logged by custom loggers and the package will not execute because of that.

Thursday, March 8, 2012

Custom Errors

Hi,

I am showing my report in the web application using Report Viewer control.In the report i have start date and End date parameters.While running the report if i give startdate as '45/66/20007' it is displaying a message which is not user friendly.Is there is any way we can handle this type of errors and display our own custom error messages.

Thanks in advance

Hello Mahima,

I was facing the same problem but I solved it through strored procedures. I passed my custom message in the RaiseError exception after the validation.

Example : This is not a solution for your problem, but I think you change the validation accordingly

IF (DATEDIFF(MM,@.StartReceivedDate,@.EndReceivedDate) > 12)

BEGIN

SET @.DateErrMsg = 'The Date Range should fall with in an year, Please correct the range.'

RAISERROR (@.DateErrMsg,18,1)

END

Hope this helps.

|||

Hi,

I try to implement that when the condition occured, it is displaying like in this way:

Query execution failed for DataSet1.

An error occured during local report processing

under this our raise error message is displaying.

Is there any way only to display our message which in raise error other than first 2 lines.

Thanks in advance

|||

I am using the (ReportErrorEventArgs e) from Microsoft.Reporting.WinForms namespace.

The way I have displayed our Raise Error exception is through the Message box.

Example:

MessageBox.Show(e.Exception.GetBaseException().Message, "Some message",MessageBoxButtons.OK, MessageBoxIcon.Error);

Then

I am hiding the " Query execution failed for DataSet1.

An error occured during local report processing

our raise error message is displaying."

with this expression : ReportErrorEventArgs.Handled = True.

In our requirement we need a messagebox to display ,but I am sure we can find a way to hide the first two lines and dispay only Raise Error execption message.

Hope this helps.....

|||

Hi,

Can you please tell me in which event you are handling this.

Can you please give me the detailed example or any other link which speciefied this event handling.

Thanks in advance

|||

It is the ReportError event for the ReportViewer.

private Microsoft.Reporting.WinForms.ReportViewer rptvSelReport;

Example:

private void rptvSelReport_ReportError(object sender, ReportErrorEventArgs e)

{

MessageBox.Show(e.Exception.GetBaseException().Message, DIALOG_FORM_CAPTION,MessageBoxButtons.OK, MessageBoxIcon.Error);

e.Handled = true;

Cursor.Current = Cursors.Arrow;

}

We have used this in our dev. environment and its working fine.

Let me know if you need any help....

|||

Hi,

Thanks for the information.I will try this and i will ask you when i have problem with this,

Thanks

|||

Custom Errors

Hi,

I am showing my report in the web application using Report Viewer control.In the report i have start date and End date parameters.While running the report if i give startdate as '45/66/20007' it is displaying a message which is not user friendly.Is there is any way we can handle this type of errors and display our own custom error messages.

Thanks in advance

Hello Mahima,

I was facing the same problem but I solved it through strored procedures. I passed my custom message in the RaiseError exception after the validation.

Example : This is not a solution for your problem, but I think you change the validation accordingly

IF(DATEDIFF(MM,@.StartReceivedDate,@.EndReceivedDate)> 12)

BEGIN

SET @.DateErrMsg ='The Date Range should fall with in an year, Please correct the range.'

RAISERROR(@.DateErrMsg,18,1)

END

Hope this helps.

|||

Hi,

I try to implement that when the condition occured, it is displaying like in this way:

Query execution failed for DataSet1.

An error occured during local report processing

under this our raise error message is displaying.

Is there any way only to display our message which in raise error other than first 2 lines.

Thanks in advance

|||

I am using the (ReportErrorEventArgs e) from Microsoft.Reporting.WinForms namespace.

The way I have displayed our Raise Error exception is through the Message box.

Example:

MessageBox.Show(e.Exception.GetBaseException().Message, "Some message",MessageBoxButtons.OK, MessageBoxIcon.Error);

Then

I am hiding the " Query execution failed for DataSet1.

An error occured during local report processing

our raise error message is displaying."

with this expression : ReportErrorEventArgs.Handled = True.

In our requirement we need a messagebox to display ,but I am sure we can find a way to hide the first two lines and dispay only Raise Error execption message.

Hope this helps.....

|||

Hi,

Can you please tell me in which event you are handling this.

Can you please give me the detailed example or any other link which speciefied this event handling.

Thanks in advance

|||

It is the ReportError event for the ReportViewer.

private Microsoft.Reporting.WinForms.ReportViewer rptvSelReport;

Example:

private void rptvSelReport_ReportError(object sender, ReportErrorEventArgs e)
{
MessageBox.Show(e.Exception.GetBaseException().Message, DIALOG_FORM_CAPTION,MessageBoxButtons.OK, MessageBoxIcon.Error);
e.Handled = true;
Cursor.Current = Cursors.Arrow;
}

We have used this in our dev. environment and its working fine.

Let me know if you need any help....

|||

Hi,

Thanks for the information.I will try this and i will ask you when i have problem with this,

Thanks

|||

Wednesday, March 7, 2012

custom error page

Hello,
Is there a a way to catch general errors on ssrs and display a custom error page to the user?

The goal is that if a user try to access a report when the ssrs is down, He won't see the RS general error but a custom notice from me.

Thanks.

If you are using report manager (which is an ASP.NET web application), I guess you can do that by configuring your custom error page in web.config file available in Program Files\Microsoft SQL Server\MSSQL.X\Reporting Services\ReportManager folder. Set mode="on" for customErrors tag and define the custom error page as you do for any other ASP.NET web application.

Shyam

|||

More details on how to use custom error pages in a web application:

You can use defaultRedirect attribute of customErrors tag to tell the application to go to another custom web page by default if any error occurs. Also you can define error pages for specific types of errors like 401, 402 etc. and add them as error tags inside this customErrors tag. En example would look like this:

<customErrors mode="on" defaultRedirect="/error.html">
<error statusCode="403" redirect="/accessdenied.html" />
<error statusCode="404" redirect="/pagenotfound.html" />
</customErrors>

where error.html, accessdenied.html and pagenotfound.html are the files that you create and place in the appropriate folder on report manager virtual directory.

Shyam

|||Hi Sundar,

Thats exctly what I did after I read your previus post Smile

Hope it will work fine. I now have to do some tasting.

Thanks for the solution!

custom error page

Hello,
Is there a a way to catch general errors on ssrs and display a custom
error page to the user?
The goal is that if a user try to access a report when the ssrs is
down, He won't see the RS general error but a custom notice from me.
Thanks.Absolutely possible as we have it implemented.
Absolutely no idea how it was achieved as I'm not a developer :(
Sorry
"nicknack" <roezohar@.gmail.com> wrote in message
news:1174999816.602638.279850@.y80g2000hsf.googlegroups.com...
> Hello,
> Is there a a way to catch general errors on ssrs and display a custom
> error page to the user?
> The goal is that if a user try to access a report when the ssrs is
> down, He won't see the RS general error but a custom notice from me.
> Thanks.
>

Friday, February 24, 2012

Custom Code Error

I'm receiving an #ERROR where I've call a function created in the custom code section. The reports works fine in development debug mode, only errors after deploying to SSRS. Note the custom code contain code that access the database using the SYSTEMS.DATA.SQLCLIENT namespace classes. Is there a security access problem in SSRS reports server?I had the same problem..
I've created a custom assembly for that..

Imports System.Data.OracleClient
Imports System.IO

'Important to get it work within a report
<Assembly: System.Security.AllowPartiallyTrustedCallers()>

Public Class DB

'Write do Database
Public Shared Function writeBack(ByVal FehlerID As Integer) As String
Dim perm As New OraclePermission(Security.Permissions.PermissionState.Unrestricted)
perm.Assert()

Dim conn As New OracleConnection
conn.ConnectionString = "Data Source=DB;Unicode=True;user=scott;password=tiger;"
conn.Open()
Dim oracleCommand1 As New System.Data.OracleClient.OracleCommand
oracleCommand1.Connection = conn
oracleCommand1.CommandText = "update ben_mailversand set gesendet=1 where fehlerid=" & FehlerID
oracleCommand1.ExecuteScalar()
conn.Close()
writeBack = oracleCommand1.CommandText
End Function
End Class

Thats not exactly brilliant but I found no other way..

in rspolicy.conf you have to set this assembly to fulltrust..
|||

There is a reason why you will need to assert FullTrust permissions in the OracleClient case: If you read the MSDN documentation for the OraclePermission class and the SqlClientPermission class and compare them, you will notice the following statement:
"This class [i.e. OraclePermission] is intended for future use when the .NET
Framework Data Provider for Oracle is enabled for partial trust scenarios.
The provider currently requires FullTrust permission."
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdataoracleclientoraclepermissionclasstopic.asp

Note: The managed provider for SQL Server is enabled for partial trust scenarios, therefore it
is sufficient (and advisable) to just assert the SqlClientPermission when using it in custom assemblies.

-- Robert

|||

Thanks for your post, it led me in the right direction. I struggled for awhile but I've finally gotten it to work.

These are the items that took me awhile to figure out:

1. Placement of custom assemby on ReportsServer:

Must be placed in this directory "prior" to deploying report.

C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting Services\ReportServer\bin

2. rssrpolicy.config FullTrust entry:

There are two way to enter this for signed or unsigned assemblies, you need to enter the correct method.

Thanks again,

Mike