Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Using user32.dll . Nothing happens
joggs
#1 Posted : Sunday, June 20, 2010 2:53:23 AM(UTC)
Groups: Member
Joined: 6/20/2010(UTC)
Posts: 4

Hi,
I'm trying to post a message to another application using the lines below in my asp.net helper file:
[DllImport("user32.dll")]
internal static extern int PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);

It works when running it in visual studio but not using cassini running as a service running as local system. Nothing happens, no error, nothing.

Sounds like an access problem but I'm not sure how to solve it. Trying to run the cassini service as my admin user makes no difference.

Ultidev Team
#2 Posted : Sunday, June 20, 2010 6:35:07 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi there!

Please take a look at Windows Event Viewer - you may find some error information there. However, if the code that calls PostMessage() does not throw an exception and GetLastError() comes back clean, then we unfortunately may not have a ready answer for you, especially if running Cassini service under your current user account does not help (with UAC turned turned off on Windows 7, Vista and Server 2008).

If in the end it turns out to be access/permissions issue, then instead of running Cassini under more powerful account, please consider creating a ServicedComponent hosted in COM+ process to elevate privileges only for the small portion of the code. If your are shipping redistributable application with UltiDev Cassini, then this is the only proper way to run code under higher privileges because changing user account for entire service makes less secure, especially if other redistributable applications are running under Cassini.

Best regards,
UltiDev Team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
joggs
#3 Posted : Sunday, June 20, 2010 8:11:36 AM(UTC)
Groups: Member
Joined: 6/20/2010(UTC)
Posts: 4

Thanks for the fast response,
I noticed that the problem could be that using User32.dll and PostMessage from a service is not recommended and will not work.
If i run your webserver from a commandprompt it works.
The problem with that I guess, is that I don't know how to embed and register the exe files and dlls so everything will be installed from the setup project in the same nice way as you show with the service in your setup tutorial.
/Jörgem


Ultidev Team wrote:
Hi there!

Please take a look at Windows Event Viewer - you may find some error information there. However, if the code that calls PostMessage() does not throw an exception and GetLastError() comes back clean, then we unfortunately may not have a ready answer for you, especially if running Cassini service under your current user account does not help (with UAC turned turned off on Windows 7, Vista and Server 2008).

If in the end it turns out to be access/permissions issue, then instead of running Cassini under more powerful account, please consider creating a ServicedComponent hosted in COM+ process to elevate privileges only for the small portion of the code. If your are shipping redistributable application with UltiDev Cassini, then this is the only proper way to run code under higher privileges because changing user account for entire service makes less secure, especially if other redistributable applications are running under Cassini.

Best regards,
UltiDev Team.
Ultidev Team
#4 Posted : Monday, June 21, 2010 4:52:39 AM(UTC)
Ultidev Team

Groups: Administration
Joined: 11/3/2005(UTC)
Posts: 2,253

Thanks: 28 times
Was thanked: 60 time(s) in 59 post(s)
Hi!

Hmm.. Running an app under UltiDev Cassini launched from command prompt should produce exactly the same result as running UltiDev Cassini service under the same user account. Could you please let us know if you have tried to run the service under the same user account?

Best regards,
UltiDev team.
Please donate at http://www.ultidev.com/products/Donate.aspx to help us improve our products.
joggs
#5 Posted : Monday, June 21, 2010 11:05:34 AM(UTC)
Groups: Member
Joined: 6/20/2010(UTC)
Posts: 4

Unfortunately it does not work when running as a service under the same user.
I've read about security issues trying to access 'desktop processes' from a service for vista and newer operating systems.

I have the same problem running it on IIS. Only works using the developer server in visual studio (which is cassini?)

Ultidev Team wrote:
Hi!

Hmm.. Running an app under UltiDev Cassini launched from command prompt should produce exactly the same result as running UltiDev Cassini service under the same user account. Could you please let us know if you have tried to run the service under the same user account?

Best regards,
UltiDev team.
Rss Feed  Atom Feed
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.