Re: Graphics.GetHdc causes InvalidOperationException
From: Richard Morris (khiron_at_community.nospam)
Date: 06/28/05
- Next message: Kay Bryan: "Microsoft Anti-Spyware"
- Previous message: Dominick Baier [DevelopMentor]: "Re: ADO.NET security in Windows App?"
- In reply to: Nicole Calinoiu: "Re: Graphics.GetHdc causes InvalidOperationException"
- Next in thread: Nicole Calinoiu: "Re: Graphics.GetHdc causes InvalidOperationException"
- Reply: Nicole Calinoiu: "Re: Graphics.GetHdc causes InvalidOperationException"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Tue, 28 Jun 2005 03:36:11 -0700
Hi Nicole,
Thanks for answering. The problem is that assigning Full Trust to
assemblies with MS strongkey is not enough. Is it possible that some
assemblies which come from MS aren't signed with their key?
Here is the code of my test control:
public class Class1 : Control {
public Class1() {
SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.DoubleBuffer |
ControlStyles.ResizeRedraw |
ControlStyles.SupportsTransparentBackColor, true);
}
protected override void OnPaint(PaintEventArgs e) {
// serurity exception
IntPtr hdc = e.Graphics.GetHdc();
e.Graphics.ReleaseHdc(hdc);
Brush brush = Brushes.White;
Pen pen = Pens.Black;
e.Graphics.FillRectangle(brush, ClientRectangle);
e.Graphics.DrawRectangle(pen, ClientRectangle);
e.Graphics.DrawString("hello", Font, Brushes.Black,
ClientRectangle);
}
}
Then it is put inside a user control, which is then embedded in an HTML:
<HTML>
<BODY bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">
<OBJECT id="MyControl1" height="200" width="200"
classid="http:WindowsApplication2.exe#WindowsApplication2.UserControl1"
VIEWASTEXT></OBJECT>
</BODY>
</HTML>
Would you like to take a closer look at this scenario? I could send you a
sample project and screenshots showing the problem.
Thanks
- Next message: Kay Bryan: "Microsoft Anti-Spyware"
- Previous message: Dominick Baier [DevelopMentor]: "Re: ADO.NET security in Windows App?"
- In reply to: Nicole Calinoiu: "Re: Graphics.GetHdc causes InvalidOperationException"
- Next in thread: Nicole Calinoiu: "Re: Graphics.GetHdc causes InvalidOperationException"
- Reply: Nicole Calinoiu: "Re: Graphics.GetHdc causes InvalidOperationException"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|