|
Here is the code I'm having trouble with:
Type oBB = Type.GetTypeFromProgID("MyNamespace.MyClass");
Object o = Activator.CreateInstance(oBB);
Object oResult = oBB.InvokeMember("BuildBook", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[]
{ (int)Job.JobID, @"\\folder\in\" + Job.FinalFile.ToString(), Convert.ToBoolean(Job.Contribidx) });
Type oRes = oResult.GetType();
String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, o, null);
The problem is that when I check sName, it gives me the cName property of MyClass rather than the cName property of the object returned by BuildBook. Does anyone see any obvious mistakes in my code?
|
|
|
|
|
Shouldn't the statement:
String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, o, null);
be
String sName = (String)oRes.InvokeMember("cName", BindingFlags.GetProperty, null, oResult, null);
-Phil
|
|
|
|
|
You da man Phil...you da man!
|
|
|
|
|
In the constructor of my main form, I do some checking.
If it doesn't pass the check, I give a MessageBox then I
want to quit the program. As I have the code now, I get
an ObjectDisposeException. What is the proper way to
quit the program?
public Form1()
{
InitializeComponents();
if(.......){
....
....
this.Close();
}
}
|
|
|
|
|
dino2094 wrote: In the constructor of my main form, I do some checking.
If it doesn't pass the check, I give a MessageBox then I
want to quit the program. As I have the code now, I get
an ObjectDisposeException. What is the proper way to
quit the program?
Override OnLoad , and do the checking there. I had the same problem and it took me awhile to figure it out.
|
|
|
|
|
|
If it is for the main form would it be better to have the exit program logic in the void main() method of the program rather than of the form.
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[ ^]
|
|
|
|
|
I have two lists. One is a list of NT user accounts. The other is a list of files on a share.
In C# I need to run a test that proves that each user has access to each file.
Note: I don’t have the account passwords.
minmanmax
|
|
|
|
|
Check out the System.Security namespace.
|
|
|
|
|
Nope. System.Security is for adding/revoking permissions on objects. It also can be used to iterate thru and objects ACLs. And of course, lots of other cool things. I have found nothing in there that will solve my problem
|
|
|
|
|
I thought that there was a collection of classes for checking user permissions on files and directories? In fact I've used them myself for checking (albeit the current) user's permissions on files.
Perhaps it's not in the System.Security namespace.
|
|
|
|
|
You are correct, Ed. The key word here is current. If I had the passwords, I could do this using the System.Security namespace by running the checking method under the users credentials.
If you can figure out how this can be done with out the password, I will throw you a parade around my desk.
|
|
|
|
|
I'm just browsing through documentation here and from what I remember so sorry if I'm completely wrong.
If you create an instance of FileSecurity or DirectorySecurity with the location you want to check, this just requires the path. Since both are derived from FileSystemSecurity they have methods to retrieve AccessRule s and AuditRule s. Both these functions require a IdentityReference which is the base class of NTAccount which to create an instance requires a username and optionally a domain name so you don't need a password.
|
|
|
|
|
Thanks Ed for looking at this. below is a samle that works with FileSecurity. It will list all the FileSystemAccessRules for a file. What I cant seem to figure out is how to show the results for a user that is a memeber of a group and that group has permission.
public static void ViewFileRights()
{
// Get security information from a file.
string file = @"c:\temp\FOO.TXT";
FileSecurity fileSec = File.GetAccessControl(file);
ShowFileSecurityInfo(fileSec);
Console.Read();
}
public static void ShowFileSecurityInfo(FileSecurity fileSec)
{
foreach (FileSystemAccessRule ace in
fileSec.GetAccessRules(true, true, typeof(NTAccount)))
{
Console.WriteLine("\tIdentityReference.Value: {0}", ace.IdentityReference.Value);
Console.WriteLine("\tAccessControlType: {0}", ace.AccessControlType);
Console.WriteLine("\tFileSystemRights: {0}", ace.FileSystemRights);
Console.WriteLine("\tInheritanceFlags: {0}", ace.InheritanceFlags);
Console.WriteLine("\tIsInherited: {0}", ace.IsInherited);
Console.WriteLine("\tPropagationFlags: {0}", ace.PropagationFlags);
//Console.WriteLine("\tfoobar.Value: {0}", ace.IdentityReference.CompareTo();
Console.WriteLine("GetAccessRules-----------------\r\n\r\n");
}
}
|
|
|
|
|
|
Can anyone teach me on Get and Set property in a class, and how these variables in get n set are used by other class members
Thx
|
|
|
|
|
Get and Set are used in properties. So for instance, if you have a class with a Name property, you can delcare that as follows:
<br />
private string msName;<br />
public string Name<br />
{<br />
get { return msName; }<br />
set { msName = value; }<br />
}<br />
You use the Get to access the private member variable, and the Set to assign to the private member variable.
If you have an instance of your class you can use it as follows:
<br />
myObject.Name = "your name here";<br />
MessageBox.Show(myObject.Name);<br />
-- modified at 14:50 Friday 30th March, 2007
|
|
|
|
|
jayceepoo wrote: You use the Get to access the private member variable, and the Set to assign to the private member variable.
Not necessarily. It can be used with any field, not just the private ones.
Also, there doesn't even need to be a field there at all:
public string MyName
{
get
{
return "Colin";
}
}
|
|
|
|
|
|
|
Hey everyone:
I am using BCGControlBar.net and basically I have a pane which I want to attach my own form to. Because it is not in the toolbox, I haven't the slightest how to do this. Is there a way?
Regards,
James
Did I post well? Rate it! Did I post badly? Rate that too!
|
|
|
|
|
How do I make the following property correct?
C#<br />
<br />
public partial class MyUserControl: UserControl<br />
{<br />
private DataGridView _DataGridView<br />
<br />
[Category("Data"), DefaultValue(null)]<br />
public DataGridView DataGridView<br />
{<br />
get { return _DataGridView; }<br />
set { _DataGridView = value; }<br />
}<br />
}
I want this to behave like the Control.ContextMenuStrip does. If a contextMenuStrip1 on a form is assigned to a ContextMenuStrip property, then deleted from the form, the property resets to "(none)", but my _DataGridView isn’t resetting to "(none)".
Thanks in advance,
S
|
|
|
|
|
I wrote a line to an XML element and the line was
Doe John A & Jane. When i looked at the generated XML, it looked like this:
<name>DOE JOHN A & JANE
How do i get around that and make it look like:?
<name>DOE JOHN A & JANE
|
|
|
|
|
|
How would i get to the end of an item in a string array?
I have :
string[] test;
test[5] has the data that i want and the data looks something like
"This is a test at My house".
I am trying to get to the end of this string and get the last word.
So i try to use Length like this
int start = test[5].IndexOf("My")+2;
int end = test[5].Length;
string MyString = test[5].Substring (start, end);
I build fine but when i run, it blows up saying string out of bounds.
Anyone know how i should be doing this and maybe why this does not work?
Thanks,
|
|
|
|