Sunday, January 21, 2018

Crystal Report is not rendering/showing/runing in localhost visual studio

Crystal report is not loading in browser, due to windows update, little workaround is required to get this issue fix.

Step1.  If crystal report is installed on your system go to following path.

C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319\crystalreportviewers13

copy the folder "crystalreportviewers13" and paste in application root folder

Step2. Go to web.config file. modify section group in this way.




<configSections>
    <sectionGroup name="businessObjects">
      <sectionGroup name="crystalReports">
        <section name="rptBuildProvider" type="CrystalDecisions.Shared.RptBuildProviderHandler,                  CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null"/>
        <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" />
      </sectionGroup>
    </sectionGroup>
  </configSections>


<businessObjects>
    <crystalReports>
      <rptBuildProvider>
        <add embedRptInResource="true"/>
      </rptBuildProvider>
      <crystalReportViewer>
        <add key="ResourceUri" value="/ERPWeb/crystalreportviewers13" />
      </crystalReportViewer>
    </crystalReports>
  </businessObjects>
 


The key value will be defined in the way



http://localhost:36409/ERPWeb//ERPWeb/crystalreportviewers13

<add key="ResourceUri" value="/ERPWeb/crystalreportviewers13" />









Thursday, September 14, 2017

OutOfMemoryException: Out of memory Saving Bitmap

OutOfMemoryException: Out of memory Saving Bitmap

If out of memory exception occurs catch the exception and write the code which is in catch block





     DataTable DT //result from DB
     MemoryStream ms;
     Bitmap bp;
            for (int i = 0; i < DT.Rows.Count; i++)
            {
                String filename = DT.Rows[i]["ID"].ToString() + ".jpg";
                string RootFolder = @"E:\FTPData\ERPWebForTest\StudentPictures";
                string path = Path.Combine(RootFolder, filename);
                try
                {
                    ms = new MemoryStream((byte[])DT.Rows[i]["DisplayImage"]);
                    bp = new Bitmap(ms);
                    bp.Save(path);
                }
                catch (Exception) //in case of out of memory exception
                {
                    ms = new MemoryStream((byte[])DT.Rows[i]["DisplayImage"]);
                    byte[] buffer = new byte[4096];
                    int byteSeq = ms.Read(buffer, 0, 4096);
                    ms.Write(buffer, 0, byteSeq);

                }

            }