473,769 Members | 5,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a semaphore and specify access rights to everyone?


I'm having trouble creating a Semaphore with read-access rights for
everyone. Originally I was trying to use this code:

semaphore = new Semaphore(maxLo cks, maxLocks, "RwLock#" + name);

but when using that code to create a Semaphore instance for an
existing system semaphore (i.e., the second time the code gets hit), I
get an UnauthorizedAcc essException. So I tried specifying that
everyone has read rights:
var sec = new SemaphoreSecuri ty();
sec.AddAccessRu le(new SemaphoreAccess Rule("Everyone" ,
SemaphoreRights .ReadPermission s, AccessControlTy pe.Allow));

bool createdNew;

semaphore = new Semaphore(maxLo cks, maxLocks, "RwLock#" + name, out
createdNew, sec);
But I still get the same error.

The error occurs when running unit tests and happens even when
creating the Semaphore twice in the same process with the same user.
I'm only creating the Semaphore in .NET from this one application.

The full error is

System.Unauthor izedAccessExcep tion: Access to the port is denied.
at System.IO.Ports .InternalResour ces.WinIOError( Int32 errorCode,
String str)
at System.Threadin g.Semaphore..ct or(Int32 initialCount, Int32
maximumCount, String name, ref Boolean createdNew, SemaphoreSecuri ty
semaphoreSecuri ty)
at Common.InterPro cessReaderWrite rLock..ctor(Str ing name, Int32
maxLocks) in InterProcessRea derWriterLock.c s: line 39

Any help would be appreciated.

Thanks,

Sam


------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
Jun 27 '08 #1
0 2251

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

Similar topics

7
4358
by: Bastian Hammer | last post by:
Hi I´m wondering why there are so few examples with Semaphore. Is it obsolete? I´ve got a Class Data. It offers 2 Threads methods for updating, editing, .. a private dictionary. Now I have to make sure, that both threads are synchronal,
4
2734
by: Ron Vecchi | last post by:
I a runnning w2k3 pop3 mail server that came with iis6. I would like to write an application that progammtically creates the new mailboxes in an already established mail domain. Does anyone know how I would access this funcationality? Thanks, Ron Vecchi
6
13730
by: Chad Crowder | last post by:
Getting the following error on my production server whether the file exists or not: "System.IO.IOException: Cannot create a file when that file already exists." Here's the code generating the error (seems to be happening when I try creating a directory) If dirmgr.Exists("s:\blah\" & txt_name.Text) Then lblerror.Text = lblerror.Text & "Unable to build physical path. " &
4
2270
by: Martin | last post by:
Hi, I am getting an "Access Denied" error when attempting to browse asp.net pages. I have installed ASP.NET 1.1.4322 on a domain controller. The machine also has ASP.NET 1.0.3705 installed on it. The machine is win 2k server. IIS is installed. I have already run aspnet_regiis - i to reinstall the .net framework.
0
1264
by: Torsten Valentin | last post by:
Hi! I have to write a program that should create a new directory ("c:\test") and share that directory with read-access for everyone and read-write-access for administrators. How do I do that in VB.NET? It would help me to have the answer to the question above, but what I'd really like would be if that was possible remote, too. I mean something like this: A user is logged with Domain-Administrator rights on on a W2k Workstation which...
0
1691
by: Torsten Valentin | last post by:
Hi! I am working on a program that should create a new directory ("c:\test") and share that directory with read-access for everyone and read-write-access for administrators. How do I do that in VB.NET? It would help me to have the answer to the question above, but what I'd really like would be if that was possible remote, too. I mean something like this: A user is logged with Domain-Administrator rights on on a W2k Workstation which...
24
1733
by: Lauren Wilson | last post by:
OK, I'm confused. SOME folks here seem to be saying it IS possible to link to or otherwise access and manipulate MDB files stored on a web server (from the client) and others seem to be saying it's NOT possible. Assuming the latter is correct, shouldn't it be possible to do it with a hidden Data Access Page running on the client machine? I assume it's possible to run a DAP without revealing it to the client user -- correct?
0
1205
by: y2ktan | last post by:
Hi everyone, I had a windows application that written using semaphore and I want to convert it into WinCE. However, I found that in Compact Framework 2.0 SP2 does not contain semaphore class in System.Threading namespace. May I know that is there any way for me to use semaphore in Compact Framework? Thank you and look forward to your reply.
5
2723
by: GHUM | last post by:
hello, in my application I am using hSem = win32event.CreateSemaphore (None, 1, 1,"stringincludinginterfaceandport") rt=win32event.WaitForSingleObject (hSem, 0) if rt != win32event.WAIT_TIMEOUT: really_do_start_my_app() else:
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10039
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8869
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5297
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5445
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3955
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 we have to send another system
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.