gilproject
جمعه 26 خرداد 1391, 17:24 عصر
من یه تابع واسه گرفتن عکس از صفحه وب دارم. البته تو برنامه تحت ویندوز کار میکنه. وقتی میارم تو asp.net ارور میده
public System.Drawing.Bitmap CaptureWebPage(string URL)
{
System.Windows.Forms.WebBrowser web1 = new System.Windows.Forms.WebBrowser();
web1.ScriptErrorsSuppressed = true;
web1.ScrollBarsEnabled = false;
web1.Navigate(URL);
while (web1.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete )
System.Windows.Forms.Application.DoEvents();
System.Threading.Thread.Sleep(2000);
int width = web1.Document.Body.ScrollRectangle.Width;
int height = web1.Document.Body.ScrollRectangle.Height;
web1.Width = width;
web1.Height = height;
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height);
web1.DrawToBitmap(bmp, new System.Drawing.Rectangle(0, 0, width, height));
return bmp;
}
این هم ارورش:
ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.
public System.Drawing.Bitmap CaptureWebPage(string URL)
{
System.Windows.Forms.WebBrowser web1 = new System.Windows.Forms.WebBrowser();
web1.ScriptErrorsSuppressed = true;
web1.ScrollBarsEnabled = false;
web1.Navigate(URL);
while (web1.ReadyState != System.Windows.Forms.WebBrowserReadyState.Complete )
System.Windows.Forms.Application.DoEvents();
System.Threading.Thread.Sleep(2000);
int width = web1.Document.Body.ScrollRectangle.Width;
int height = web1.Document.Body.ScrollRectangle.Height;
web1.Width = width;
web1.Height = height;
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(width, height);
web1.DrawToBitmap(bmp, new System.Drawing.Rectangle(0, 0, width, height));
return bmp;
}
این هم ارورش:
ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment.