|
By default, the CurrentPrincipal on the thread is GenericPrincipal. If you set the CurrentPrincipal to WindowsPrincipal it should be the same as doing a RunAs. You can access the property off of the current thread (System.Threading.Thread.CurrentPrincipal). You can also set this at the AppDomain level, but you can only do this once during the entire life of the application domain. By doing it at the domain level, you inherit the WindowsPrincipal througout all threads within that application domain.
|
|
|
|
|
ok im not too familiar with CurrentPrincipal.. so could i plz have a code example to show me how to pass credentials to a remote computer to access their registry thanks
|
|
|
|
|
Getting credentials to see if a user is in a particular role is easy.
Passing credentials from one system to another to access registry information is not. If it was easy, we'd have one more security patch to be applied to Windows because it would be such an easy hack.
If there were a real business justification for doing something like this, then about the only way I could think of was to have the user install an agent and access the agent via remoting.
This signature left intentionally blank
|
|
|
|
|
Hi,
I am using two model dialog boxes named "StartUp" and "AddNewItem" from the main Form named "Form1" with the following code
frmStartUp = new StartUp();
frmStartUp.ShowDialog();
if (frmStartUp.DialogResult == DialogResult.OK)
{
// Doing Something
frmStartUp.Dispose();
}
else if(frmStartUp.DialogResult == DialogResult.Cancel)
{
frmStartUp.Dispose();
}
same is the code for the second dialog box (AddNewItem).
When i click on the Cancal button of the second dialog box it gives the following excpetion
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll
Additional information: External component has thrown an exception.
whereas clicking the cancal button of the first dialog box (StartUp) does not give any exception.
what the problem with it.
Thanks in Advance
Omar Rehman
|
|
|
|
|
try this:
frmStartUp = new StartUp();
if (frmStartUp.ShowDialog == DialogResult.OK)
{
// Doing Something
frmStartUp.Dispose();
}
else
{
frmStartUp.Dispose();
}
|
|
|
|
|
Hello. I require some assistance in measuring an image. Currently I am able to measure a stadard line (horizontal, diagonal and vertical). Now, I would want to measure a non standard form. What I would want to do is to click from one point to another continuously and each clicked point will be assigned to a standard incremental node name (ex: A, B,..Z). Then, the software will record the coordinate of each nodes into a table. I really need sonebody;s help in this since I am rather new with this software. Thank you.
M
|
|
|
|
|
Well, it sounds to me like you have a bunch of small lines and you want to add their lengths, am I right ? That sounds fairly straighforward to me, or have I missed something ? If you store the co-ordinates in an arraylist, you can make that a data source for a data grid.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Christian
Thanks for the answer but since I am rather new with this C# programming I would relly much appreciate it if you could assist me on the programming codes. I honestly have no idea how to do this.
M
|
|
|
|
|
at the top:
using System.Collections
in your class:
ArrayList points = new ArrayList();
when someone does a click
points.Add(ptMousePos ( however you get the point in the event ));
Then you can go through the array, and work out your lengths from each point pair, and create a form with a datagrid, and just have something like
theGrid.DataSource = points;
theGrid.DataBind();
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I really appreicate you fast reply. It sounded so easy for you. Like counting 1,2,3. Won't be easy for me since I'm a first time user. Anyway, thanks for the reply. I appreciate it very- very- very much. I'll try and give it a go.
M
|
|
|
|
|
Dear Christian
I am really- really sorry to be bothering you again but I ave tried to program the codes but am unable to get anywhere near what I wanted (due to the fact that I'm a first time user). Do you have a running application so as I can study the code rather then having to develop the code. Thank you again and I honestly am really- really sorry for bothering you.
I apologize again.
M
|
|
|
|
|
No need to apolgise, that's what this forum is for. Why don't you post some code, so I can have a look at it. What's it doing, and what do you want it to do differently ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Chritian
I'll be very honest with you. I am a control and Electrical person who has no prior ecperience in high level language. NONE what so ever. Currently, what I'm doing is trying (really hard) to undertand people's programming codes (that's how I study this language) in addition to study the basic concept of C#. Since I am really- really new,I am unable to develop any codes cause it's hard enough for me to understnd the coding itself he!he!. Now I only manage to open and save file. I am still finding a way (whihc I doubt) to program the application stated before. Anyway, Christian I appreciate your fast responses an d you ever find codes that;s relevant to my rewuirements, please email them to me okay. Thank you again.
M
|
|
|
|
|
Hello
I want to make a preferences/settings dialog where you can click on a node in a treeview and then the controls to the right where you can change the settings change. How do I make this? Do I have alot of panal controls, fill them with what I want and then make one visible and the rest invisible or are there a better way?
Tips and ideas are very appreciated!
Thanks in advance!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Implement every settings page as a separate UserControl.
When clicking on a tree node destroy the control currently visible and create
a new one corresponding to your entry.
You might want to consider having a settings class that will subscribe to events inside the controls on your UserControls to store the values of your preferences. However if the amount of settings groups/subgroups is not that great, I would recommend using the traditional tabbed dialog design instead.
|
|
|
|
|
i draw some rectangle into my form and when i minize the rectangles disappeared how to slove this problem ?
|
|
|
|
|
Are you using the OnPaint event, and drawing it every time the form repaints?
|
|
|
|
|
1.Overide OnPaint Event and write all the painting algorithm inside this.
2. Use graphics object obtained from PaintEventArgs's Graphics property. This will ensure non-flickering during painting.
protected override void OnPaint ( System.Windows.Forms.PaintEventArgs e )
{
Graphics g = e.Graphics;
}
Do revert back whether it could solve your problem or not?
Regards,
Jay.
|
|
|
|
|
Hi everybody.
I got a WinSock related question. This is mainly about C#. I find C# to be very strage in this problem... maybe because I'm a begginer in C#. I'm using the GetData method to retrieve some data a socket received. Here is the data about this method:
Void axWinsock.GetData (ref object data, object type, object maxLen)
In Visual Basic .Net the last two parameters are optional. But in C# you MUST provide them, otherwise the function will not work. I tried this... (in Socket_DataArrival)
object oRData;
oRData = "";
Socket.GetData(ref oRData, (object) null, (object) null);
After casting nulls to objects it worked, but I`m not sure if this is how I can avoid using those parameters. I`m not sure if the function will work.
But the big question is... HOW DO I GET THAT DATA OUT OF my object variable, oRData. Pfff... I tried casting it to a string but that doesn't work. In fact,
object oRData;
oRData = "";
IRC.GetData(ref oRData, (object) null, (object) null);
MessageBox.Show ("Test");
When using a breakpoint... the GetData method gets executed, but surprise surprise... the Message Box is never displayed. It's just like the GetData method crashes the entire DataArrival event.
I`m totally puzzled ... anybody know anything?
Thank you in advance, have a nice day/night
The Greater Mind Balance
|
|
|
|
|
How do I open up a windows shell folder properties dialog from dotNet?
I would prefer doing it purelly managed, but if required there's no real reason not to use interop (as I suppose I'd have to)
|
|
|
|
|
My console project is named UsingConfigSettings in C#, and wanted to store the database connection in an application config file. I added an application config named "UsingConfigSettings.exe.config" in my project. Here is its contents:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="constring" value="server=localhost;database=Northwind;uid=sa;pwd=;"/>
</appSettings>
</configuration>
I even copied it in the bin\debug folder in my C# console application, but it still doesn't work. I acccess it in the console as:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public class UsingConfigSettings
{
public static void Main()
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings["constring"]);
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM Customers";
cmd.Connection = con;
con.Open();
SqlDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
Console.WriteLine("{0} - {1}", reader.GetString(0), reader.GetString(1));
}
con.Close();
Console.ReadLine();
}
}
but it won't work, it always issued a message of:
"An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll
Additional information: The ConnectionString property has not been initialized."
If I don't use any config file, and replace the code above, it works fine:
SqlConnection con = new SqlConnection("server=localhost;database=Northwind;uid=sa;pwd=;");
Please help.
|
|
|
|
|
Hi all,
How can we query xml data between two dates by using XPath.
For example:
I have an XML file like this
"<Employees>
<Employee>
<Name>xxxx</Name>
<DateOfJoin>'2000-04-12T10:12:30'</DateOfJoin>
</Employee>
<Employee>
<Name>yyyy</Name>
<DateOfJoin>'2001-04-12T10:12:30'</DateOfJoin>
</Employee>
<Employee>
<Name>zzzz</Name>
<DateOfJoin>'2002-04-12T10:12:30'</DateOfJoin>
</Employee>
<Employee>
<Name>aaaa</Name>
<DateOfJoin>'2003-04-12T10:12:30'</DateOfJoin>
</Employee>
<Employee>
<Name>bbbb</Name>
<DateOfJoin>'2004-04-12T10:12:30'</DateOfJoin>
</Employee>
</Employees>"
Now I want employee names between 2002 and 2003.
Thanks inadvance.
|
|
|
|
|
Your question would be better answered in the XML/XSL Forum. Not the C# Forum...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well, I am searching for amlost 3 hours on internet for any article that shows comparison between "MSIL", "JAVA Bytecode" and "Intel Assembly Language", but couldnt even fine ONE
Anyone here to help me?
TIA
|
|
|
|
|
Thats strange, I typed "il bytecode comparison" in google and got several thousand results.
my blog
|
|
|
|