TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abdulmajeed Alshari
NA
266
61.3k
"Parameter is not valid." in System.Drawing.Bitmap
Oct 14 2020 6:48 PM
I built simple application to take full screenshot each 100ms of computer's screen and set the screenshots on the PictureBox :
private
void
StartWork()
{
try
{
// width :1916 and height :1074 is the best measure to take full screenshot of whole laptotp's screen
using
(Image bitmap =
new
Bitmap(1916, 1074))
{
using
(Graphics g = Graphics.FromImage(bitmap))
{
g.CopyFromScreen(Point.Empty, Point.Empty,
new
Size(1916, 1074));
}
pictureBox1.BackgroundImage = (Image)bitmap.Clone();
pictureBox1.BackgroundImageLayout = ImageLayout.Stretch;
//Sending Function to Send every token screenshot to all connected TcpClients
// Sending(bitmap);
pictureBox1.Invalidate();
pictureBox1.Refresh();
}
}
catch
(Exception ee)
{
// MessageBox.Show(ee.Message);
}
}
calling
StartWork() in every 100ms in Tick event :
private
void
timer1_Tick(
object
sender, EventArgs e)
{
StartWork();
}
it is run well and i see the screenshots appears on PictureBox one after one but after several seconds I am facing this exception :
Data =
{System.Collections.ListDictionaryInternal}
HResult =
-2147024809
Message =
"Parameter is not valid."
Source =
"System.Drawing"
StackTrace =
" at System.Drawing.Graphics.GetHdc()\r\n at System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize, CopyPixelOperation copyPixelOperation)\r\n at System.Drawing.Graphics.CopyF...
TargetSite
= {IntPtr GetHdc()}
I was searched in simillar problems in CSharp Corner and Stackoverflow and try to change a lot of things but really i becommed tired.
please developers how solve this problem .
Thanks in Advance .
Reply
Answers (
4
)
pdf manupulation problem
ID number not update after delete items