Thursday, January 02, 2014

#Error in local report parameter value and expressions in Visual Studio 2010

I had faced this issue when i upgraded my VS2008 RDLC reports in VS2010 to adopt 2010 Schema (another night mare :)). I was using a local reprot to render in PDF format in my web apps and it consumes certein paramters to show in header, footer and also used in some of the expressions. Unfortunately, all my textboxes that used this paramter value displayed "#Error". I had spent almost around 3 hours on this and later realized the cause. This is due to some CAS (Code Access Security) recently implemented in .net 4.0 framework. We need to give additional permission to evaluate the expression in RDLC report. Details are mentioned here in the blog nicely.

Here is the sample code of mine. The object "report" represents local report object (LocalReport report = new LocalReport();)


ReportParameter[] parameters = new ReportParameter[4];
ReportParameter p2 = new ReportParameter("datetime_format", SessionContext.CurrentSessionDateTimeFormat);
ReportParameter p3 = new ReportParameter("date_format", SessionContext.CurrentSessionDateFormat);
ReportParameter p4 = new ReportParameter("currency", "All transactions are in " + SessionContext.CurrencyCode);
//
parameters[0] = new ReportParameter("request_no", requestNo);
parameters[1] = new ReportParameter("datetime_format", SessionContext.CurrentSessionDateTimeFormat);
parameters[2] = new ReportParameter("date_format", SessionContext.CurrentSessionDateFormat);
parameters[3] = new ReportParameter("currency", "All transactions are in " + SessionContext.CurrencyCode);
//
report.SetBasePermissionsForSandboxAppDomain(AppDomain.CurrentDomain.PermissionSet.Copy());
// Added above line to grant additional permission to execute the expression assembly
//
report.SetParameters(parameters);


Cheers...

Note: The above fix is required for the expressions/formulas to work properly in the new version.

Thursday, March 04, 2010

Microsoft® Tech·Ed Middle East 2010

Oh..at last i got the opprotunity to attend the Tech-Ed 2010 MENA. The even was very successfull, being attended by professionals from across Midde East and Africa.

I have got the wonderful chance to meet Joel and Shahid Gaglani (once again). Joel as always done sessions with smiles and Shahid was not lined up for the session (unfortunately).

The other exciting figures of the event are Scott Hanselman and Micheal Noel!. Scott is excellent in his work, his session was awesome!...You are the man!.. You made the Asp.net MVC simpler to me.

Noel, you are the ocean of knowledge. You have the stuff to speak!

The very interested tracks were on MVC and SharePoint!

Wednesday, November 04, 2009

Friday, June 05, 2009

Microsoft Search Engine - Bing

Microsoft has formally launched its new "decision engine" called Bing,
Try www.bing.com

Tuesday, May 19, 2009

How to return value from window.showModalDialog to parent window in javascript ?

Here is the example

Function to open dialog window from parent window

function showFleetDialog()
{
var oReturnValue = window.showModalDialog("/abc/page.aspx", this, "dialogWidth:800px;dialogHeight:500px;resizable:yes;");
if(oReturnValue != null)
document.getElementById('<%= txtFleetNo.ClientID %>').value = oReturnValue.FleetCode;
return false;
}

Function to retun value from dialog window
function closeThisWindow(fleetCode, fleetId)
{
var o = new Object();
o.FleetCode = fleetCode;
o.FleetId = fleetId;
window.returnValue = o;
window.close();
}

</dotnetSoldier>

Wednesday, April 22, 2009

Failed to decrypt the Web.config in asp.net

After encrypting the appSettings in web.config file using the command

aspnet_regiis -pef "appSettings" "c:\<appfolder>"
you may recieve the following error

"Failed to decrypt using provider 'RsaProtectedConfigurationProvider'. Error message from the provider: The RSA key container could not be opened."

or the site will not work since it cannot read/decrypt the web.config contents (connection string or any similiar data).

Resolution
This is because your ASP.NET application identity does not have access to the .NET Framework configuration key store. To give rights use the following command

aspnet_regiis -pa "NetFrameworkConfigurationKey" "<application pool identity account>"

Hope this helps..