473,473 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Can I use GDI+ in a Service?

If I use GDI+ within a service, what problems can I expect? Why can't GDI+
be used within a service?

http://msdn2.microsoft.com/en-us/lib...m.drawing.aspx

"Classes within the System.Drawing namespace are not supported for use
within a Windows or ASP.NET service. Attempting to use these classes from
within one of these application types may produce unexpected problems, such
as diminished service performance and run-time exceptions."

Sep 29 '06 #1
4 5239
Hello

Services in Microsoft Windows are generally console applications that are
designed to run unattended. Therefore, services do not typically have a
user interface. However, the service may require interaction with the user
in some instances. We strongly recommend that services do not run as
interactive services if the services run in an elevated security context
such as SYSTEM.

For the Windows user interface, the desktop is the security boundary. Any
application that is running on the interactive desktop can interact with
any window that is on the interactive desktop, even if that window is not
displayed on the desktop. This behavior is true for every application,
regardless of the security context of the application that creates the
window and regardless of the security context of the application that is
running on the desktop. The Windows message system does not allow an
application to determine the source of a window message.

Because of these design features, any service that opens a window on the
interactive desktop is exposing itself to applications that are executed by
the logged-on user. If the service tries to use window messages to control
its functionality, the logged-on user can disrupt that functionality by
using malicious messages.

So, for security issue, we don't recommend to use user interface or GDI in
a windows service application.

If there is anything unclear, please feel free to let me know.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 2 '06 #2
This didn't answer my question. This response says why I shouldn't build
user interaction into a service. That's not what I asked.

I want to know why I shouldn't use System.Drawing in a service. I want to
build a service that creates various drawings or renderings on demand. There
is no interactive user, no windows, no windows messages involved in the
service I want to build. MSDN says not to use System.Drawing in a service.
Why?

Is your answer that MSDN is misleading -- it's just fine to use
System.Drawing in a service as long as I'm not using it for GUI type user
interaction?

"Luke Zhang [MSFT]" wrote:
Hello

Services in Microsoft Windows are generally console applications that are
designed to run unattended. Therefore, services do not typically have a
user interface. However, the service may require interaction with the user
in some instances. We strongly recommend that services do not run as
interactive services if the services run in an elevated security context
such as SYSTEM.

For the Windows user interface, the desktop is the security boundary. Any
application that is running on the interactive desktop can interact with
any window that is on the interactive desktop, even if that window is not
displayed on the desktop. This behavior is true for every application,
regardless of the security context of the application that creates the
window and regardless of the security context of the application that is
running on the desktop. The Windows message system does not allow an
application to determine the source of a window message.

Because of these design features, any service that opens a window on the
interactive desktop is exposing itself to applications that are executed by
the logged-on user. If the service tries to use window messages to control
its functionality, the logged-on user can disrupt that functionality by
using malicious messages.

So, for security issue, we don't recommend to use user interface or GDI in
a windows service application.

If there is anything unclear, please feel free to let me know.

Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 4 '06 #3
Hello,

It is not absolute that we cannot use System.Drawing in a Windows Service.
MSDN just warn that we don't recommend you use it in a Windows Service, and
there are may be some unexpected problems if you implement that.

In fact, I indeed saw many problems on using System.Drawing in Windows
Service. There is a solution for such problems: Enable "allow service to
interact with desktop" option of the Windows Service. However, this is not
guaranteed to fix all of the problems. And, as I said before, this may
bring security issue,

If there is anything unclear, please feel free to let us know.
Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 5 '06 #4
Don
Let me repeat once again that I am not implementing any user interactivity in
my service. So I don't understand why there would be a need to enable "allow
service to interact with desktop".

What kinds of problems, not associated with user interactivity, can I expect
by using System.Drawing in a service? And is there a way to work around
those problems?

"Luke Zhang [MSFT]" wrote:
Hello,

It is not absolute that we cannot use System.Drawing in a Windows Service.
MSDN just warn that we don't recommend you use it in a Windows Service, and
there are may be some unexpected problems if you implement that.

In fact, I indeed saw many problems on using System.Drawing in Windows
Service. There is a solution for such problems: Enable "allow service to
interact with desktop" option of the Windows Service. However, this is not
guaranteed to fix all of the problems. And, as I said before, this may
bring security issue,

If there is anything unclear, please feel free to let us know.
Sincerely,

Luke Zhang

Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Oct 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Maqsood Ahmed | last post by:
Hello! We have experienced following exception in our application that runs over .net v1.0, I had gone through the internet to find an answer about it but failed to do so. I had found a comment...
6
by: James dean | last post by:
I have heard that the video drivers in GDI+ are a big performance issue. But is this only an issue with something like Games Programming i think...is this wrong?. What about a drawing application...
1
by: James dean | last post by:
Could someone explain how this works. I think the graphics card is used to do blitting and drawing shapes like rectangles. How does it draw using the Graphics card on the PC and why is this feature...
6
by: James dean | last post by:
I want a good site that will show clearly how much more functionality GDI+ has. I cannot seem to find anything other than sites that list "some" of the new functionality that GDI+ offers. A...
7
by: | last post by:
We create VC++ programs that does some GDI drawing functionality. I discovered GDI+ and this seems to be a big step forward, and appears to be standard available in Windows XP and Windows Server...
0
by: Brian Keating | last post by:
hi there i've a test program that creates a treeview and destroys it over and over, i keep track of the gdi object count for the process and see if they are ok. However when i switch on...
7
by: Marcin Rzeznicki | last post by:
Hello, Do you think it is legitimate practice to mix GDI+ and GDI calls (via Get/ReleaseHDC()) in paint event of a control? I've heard there is possibility of performance loss while "locking"...
7
by: Tarren | last post by:
Hi: I need to render text graphics using custome font. I am running into issues where PrivateFontCollection will hang sometimes when I instantiate it. PrivateFontCollection fc = new...
1
by: hemant | last post by:
I am trying to Caputre the screen in windows service with the GDI Api of Win32 in vb.net 1. CreateDc 2. CreateCompatibleDC 3. CreateCompatibleBitmapDc 4. Bitblt 5. SelectObject 6. ...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.