﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Reporting Services / Reporting Services 2005 Development  / Error in Printing the document using SQL CLR Stored Procedure / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 24 May 2012 10:48:20 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Error in Printing the document using SQL CLR Stored Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic645943-1063-1.aspx</link><description>Dear Sir,Have you solved your last problem in sending print job to a printer from SQL Server Procedure?could you please inform me about any likely solution?ThanksArmin</description><pubDate>Wed, 14 Mar 2012 08:35:39 GMT</pubDate><dc:creator>armin.bahamin</dc:creator></item><item><title>RE: Error in Printing the document using SQL CLR Stored Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic645943-1063-1.aspx</link><description>Hi,    Now the error comes while calling the Print Method is   Value cannot be null.  Parameter name: type.Here is my code for printing.      private static byte[] _documentToPrint;        private static int _documentToPrintCurrentPage = 0;        private static string strErrMsg = ""; public String PrintImage(string printerDestination, out string status, byte[] image)        {            try            {                // FaxId = MyFaxID;                _documentToPrint = image;                PrintDocument printDoc = new System.Drawing.Printing.PrintDocument();                printDoc.PrinterSettings.PrinterName = @"\\printserver\HR Canon iR5070"; //printerDestination;                //wire event                printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);                strErrMsg = "Calling Print Method | " +  printDoc.PrinterSettings.PrinterName + "|";                [b]printDoc.Print();[/b] //Exception occurs here                status = "File Printed";                return status;            }            catch (Exception ex)            {                _documentToPrintCurrentPage = 0;                strErrMsg = strErrMsg + ex.Message + "-&amp;gt;" + _documentToPrint.Length.ToString() + "-&amp;gt;  Print Image Method";                status = strErrMsg;                strErrMsg = "";                return status;            }        }        private void printDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)        {            strErrMsg = strErrMsg + "inside printDoc_PrintPage | ";            MemoryStream ms = new MemoryStream(_documentToPrint);            Bitmap bm = (Bitmap)Bitmap.FromStream(ms);            Graphics g = e.Graphics;            try            {                int pagesFound = bm.GetFrameCount(FrameDimension.Page);                if (pagesFound &amp;gt; 0)                {                    bm.SelectActiveFrame(FrameDimension.Page, _documentToPrintCurrentPage);                    _documentToPrintCurrentPage++;                    if (_documentToPrintCurrentPage &amp;gt;= pagesFound)                    {                        e.HasMorePages = false;                        _documentToPrintCurrentPage = 0;                    }                    else                        e.HasMorePages = true;                    g.DrawImageUnscaled(bm, 0, 0);                }            }            catch (Exception ex)            {                _documentToPrintCurrentPage = 0;                strErrMsg = strErrMsg + ex.Message + "--&amp;gt;" + _documentToPrint.Length.ToString() + " -&amp;gt; printDoc_PrintPage Method";                throw ex;                       }        }What could be the issue?</description><pubDate>Thu, 29 Jan 2009 09:06:55 GMT</pubDate><dc:creator>Gunjan</dc:creator></item><item><title>RE: Error in Printing the document using SQL CLR Stored Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic645943-1063-1.aspx</link><description>Hi All,       I resolved that error by creating the assemblyCREATE ASSEMBLY [System.Drawing]FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll'WITH PERMISSION_SET = UNSAFEInitially I was creating the assembly from my network path, that's why it was throwing an error.Now trying to print the image, still that is pending...:)Let me see I will keep posting the question or solution for this post.Thanks</description><pubDate>Thu, 29 Jan 2009 08:17:58 GMT</pubDate><dc:creator>Gunjan</dc:creator></item><item><title>Error in Printing the document using SQL CLR Stored Procedure</title><link>http://www.sqlservercentral.com/Forums/Topic645943-1063-1.aspx</link><description>Hi,       I am trying to print the Image using SQL CLR Stored procedure. I have used the PrintDocument class of .NET. In that I have used the object of System.Drawing class.       To access the Assembly I have created the assembly of System.Drawing in my sql server database. But when I am executing the stored procedure it is throwing the following error:A .NET Framework error occurred during execution of user-defined routine or aggregate "BRCOffer_ProcessBRC_Email": System.IO.FileLoadException: Could not load file or assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050)System.IO.FileLoadException:   at StoredProcedures.BRCOffer_ProcessBRC_Email().Can I print the image from SQL CLR Stored Procedure or not?Please help.Thanks.</description><pubDate>Thu, 29 Jan 2009 07:56:15 GMT</pubDate><dc:creator>Gunjan</dc:creator></item></channel></rss>
