|
|
You shouldn't cross post messages. It's considered rude - see forum guideline no.1.
Choose the most appropriate forum for your question and post there only. As this is an ASP.NET question, the ASP.NET forum is more appropriate.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi!
I created a new Windows Service in C# and want to set a Service Dependency.
Did it like this:
ServiceInstaller si = new ServiceInstaller();<br />
si.ServicesDependedOn = new string[] { "DependingOnThisService" };<br />
this.Installers.Add(si);<br />
Everything works fine. My Problem right now is, that I want to set this Dependency only in fact of a special "flag" in the app.config - file.
But I am not able to read from the app.config - file in the ( from System.Configuration.Install.Installer inherited) class.
I neither get an exception nor a result from the config - file (always get an empty string).
So is there a possibility to read from the app.config in this class or, if not, what is the best alternative to do this?
Hope anybody can help me!
tia
|
|
|
|
|
How can I get yes/no/cancel option from javascript.
I know a option "Confirm" but this code has two option (OK/Cancel)
|
|
|
|
|
A C# forum isn't really the best place to ask (!) but here you go[^].
|
|
|
|
|
|
I am using VS 2003 with 1.1 of the framework. (No hope of getting an upgrade )
Scenario
I am using a textbox which allows a user to input text in order to filter a list. I am using the KeyPress event for the control to save the user from having to click a separate button.
Problem
The event doesn't fire sometimes. The odd time another control (e.g. a button ) gains focus and fires it's Click event.
I have tried searching this site as well as Google to no avail.
Has anyone encountered this type of problem?
|
|
|
|
|
Other controls should only get activated if they have some kind of shortcut via alt or if they are the accept/cancel buttons (enter / esc). It might be worth checking the keypreview property of your form is set to false.
|
|
|
|
|
You might want to make sure the Form's KeyPreview Property is set to true. Getting the property information from the object browser for the property:
<quote>Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
Hi All,
I'm fairly new to C# so somewhat clueless. I'm writing an error handler class library which will receive exceptions thrown and can be configured to display and/or log the exception.
In order to display, I'm trying to use the MessageBox class so I've included a reference to System.Windows.Forms. I also added a using statement for System.Windows.Forms. When I compile, I get an error "The type or namespace name 'Windows' does not exist in the namespace 'System' (are you missing an assembly reference?)". I'm guessing that the problem has something to do with the fact that I'm working with a class library and perhaps .NET uses a different System class for class libraries. I've tried this with VS 2005 and SharpDeveloper and both give exactly the same error.
Is there a genius out there with a solution?
Thanks,
Steve
|
|
|
|
|
Hi,
to use the many classes .NET provides, you typically need to do two things:
1. add a reference, using the Solution Pane, right click on the project, choose Add Reference,
and select (in your case: System.Windows.Forms);
2. add a using statement (using System.Windows.Forms). You will notice Intellisense works
for you while you type this provided you finished step 1 first.
Some of these may happen automatically, depending on the project type you selected,
but none so for a class library.
modified on Friday, January 11, 2008 12:28:45 PM
|
|
|
|
|
Please read my original message. You'll see that I did add a reference and a using statement.
|
|
|
|
|
I think I told you everything there is to do to get it right.
Does Intellisense show Windows when you have entered "using System."?
Does Intellisense show Forms when you have entered "using System.Windows."?
Can you show some code, up to the line that causes the error?
general suggestion: tell the Visual editor to always show line numbers (see menu
Tools/Options/Text Editor/...), then debug using the line numbers the compile- or
run-time messages provide.
|
|
|
|
|
You were correct. It was my own stupid mistake (as usual). I had 2 classes in my solution; the main class and an nunit test class. I thought the error was being thrown by the main class which contained the reference, but it was actually being thrown by the test class which did not have the reference.
Thanks for you help,
Steve
|
|
|
|
|
hi
i have a method as 'GetDbUsers' and i use it like this :
this.dt = this.GetDbUsers();
body of my method is :
private DataTable GetDbUsers()<br />
{<br />
string spName = "sp_helplogins";<br />
SqlConnection con = new SqlConnection(GlobalUtil.GetConnectionString());<br />
SqlCommand cmd = new SqlCommand(spName, con);<br />
SqlDataReader dr;<br />
DataTable dtDbUsers = new DataTable();<br />
cmd.CommandType = CommandType.StoredProcedure;<br />
try<br />
{<br />
if (con.State == ConnectionState.Closed)<br />
con.Open();<br />
dr = cmd.ExecuteReader();<br />
dtDbUsers.Load(dr);<br />
foreach (DataRow row in dtDbUsers.Rows)<br />
{<br />
if (row["LoginName"].ToString() == "##MS_AgentSigningCertificate##")<br />
dtDbUsers.Rows.Remove(row); <br />
}<br />
return dtDbUsers;<br />
}<br />
catch (Exception ex)<br />
{<br />
if (con.State == ConnectionState.Open)<br />
con.Close();<br />
this.toolStripStatusLabel1.Text = ex.Message;<br />
MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);<br />
return null;<br />
}<br />
finally<br />
{<br />
if (con.State == ConnectionState.Open)<br />
con.Close();<br />
}
my problem is that when i modify the local dataTable object (dtDbUsers) in above method (remove some row), the following error has shown me :
Collection was modified; enumeration operation might not execute.
where does my problem and how to solve it ?
thanks
|
|
|
|
|
hdv212 wrote: foreach (DataRow row in dtDbUsers.Rows)
{
if (row["LoginName"].ToString() == "##MS_AgentSigningCertificate##")
dtDbUsers.Rows.Remove(row); // error in this line
}
This means that you cannot add or remove items from the collection while you're enumerating it. foreach creates an Enumerator over the collection automatically.
You can use a normal for statement and index through the collection to do this. I would highly recommend that you start at the end of the collection and work your way to index 0. This will prevent you from deleting an item and skipping the next item in the collection. This is because when you remove an item at one index, say number 5, the items in indexs 6 through whatever all move down one. So item 6 is now at item 5. When your get to the bottom of the loop and the index variable incerements, you're no longer looking at item 5, but instead you're looking at the new item 6. The new item 5 gets skipped over.
|
|
|
|
|
Hi Dave Kreskowiak
thanks for reply
my problem solved.
Many thanks.
|
|
|
|
|
hi All,
Suppose GC consists of a number of forests. with ldap search, i found a record in the GC and now want to update this record, but attribute which i want to update is not presented in GC.
how to identify forest this record belongs to and what ldap port i must use to update this record in the forest?
modified on Friday, January 11, 2008 10:46:33 AM
|
|
|
|
|
GC, forest? I don't understand what you are taking about. Are you refering to garbage collection? Give a little more detail to your question
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Hi Justin, good catch for Indian
GS is Global Catalog (GC). So GC contains info from number of Active Directory forests.
thanks,
max
|
|
|
|
|
You may wnat to actually say you're working with Active Directory and "Global Catalog" instead of GC. In .NET, GC normally stands for "Garbage Collector".
The Global Catalog does NOT hold every property of every object. It holds a small subset of properties for all objects.
Your command text probably starts with "GC://..." , correct?? Well, to get at the full record, you have to start with "LDAP://... ". The port number is there to talk to either the unsecured version of LDAP, or the secured version. What you're doing on that connection has nothing to do with the port number you use. You normally don't need to give it the port number since AD uses the stadnard LDAP ports, 389 for normal connections and 636 for SSL secured.
But, to find the object, all you have to do is return the distiguishedName of the object your looking for from the Global Catalog. The distiguishedName will tell you the full path to the object, including which domain the object is in. You can then use that you get the object from LDAP so you can modify all the properties you want.
|
|
|
|
|
Dave, you're right! i work with Active Directory and Global Catalog.
My command text always starts with "LDAP://..." but port is 3268 - port for GC.
i know that 389 port is default port for LDAP. but aslo i know that this port can be changed.
LDAP query i read from 3rd party programm and i don't know exactly would this query will point to GC or LDAP. So if query points to GC i want to find this record tin its forest. Or just LDAP://CN=<distiguishedname> will point to it?
|
|
|
|
|
robot_rock wrote: LDAP query i read from 3rd party programm and i don't know exactly would this query will point to GC or LDAP.
GC queries always start with GC:// , so if you're getting this a 3rd party app and it uses LDAP:// to begin it's command string, chances are it's not comming from the Global Catalog.
If you're sure the result is comming from the Global Catalog, and you get the distinuishedName back from the query, that name will point directly to the object in question if you use it in another LDAP command string:
LDAP:
Keep in mind though when you bind to an object, you only immediately get back some basic properties of the object. You need to tell it to retrieve either all of the remaining properties, or just specify which properties you need. After that, you can modify them and write the changes back to AD.
|
|
|
|
|
ok Dave.
as i know LDAP://distinguishedName/yourParameterList will only work if machine, from what i'm binding to object, belongs to this forest, otherwise i must specify machine name and port in LDAP query, isn't it?
thanks,
max
|
|
|
|
|
If you use the distinguishedName, the domain information is already supplied and any controller in that domain can service the request.
No, you don't have to specify the port, unless those domain controllers are not using the standard port numbers.
|
|
|
|