|
Pete O`Hanlon wrote: call Convert.ToInt32(listArray[0].ToString());
Is there any reason why you are calling ToString() ? Convert works on object too... Only meaningful thing I can think of is to provide IFormatProvider , but then again there is Convert.ToInt32 (Object, IFormatProvider) overload.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
dnh wrote: Is there any reason why you are calling ToString()
Yup - typing in away from a dev box and doing it from memory - I don't tend to use the .NET 1 list anymore.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
If the list is of int s to begin with, only a cast required.
|
|
|
|
|
Hi,
I'm trying to find all classes that implement a specific abstract base class inside an Assembly, so far I have got the following...
Assembly assm = Assembly.GetExecutingAssembly();<br />
<br />
foreach (Type type in assm.GetTypes())<br />
{<br />
if (type.IsSubclassOf(typeof(MyAbstractClass)))<br />
{<br />
Response.Write(type.ToString() + "<br />");<br />
}<br />
}
...and this seems to work OK. However, my assembly is already fairly large and may grow, and as far as I can tell this code iterates through all types in the assembly, which I feel is inefficient.
I know all my derived classes will sit inside the same namespace, so was wondering if there's a way to iterate through all types inside a particular namespace only, instead of the entire assembly?
Cheers!
|
|
|
|
|
OK, I've had enough and need to ask. I'm looking at some Interop work carried out in .Net 2.
Essentially we have a VB6 application and associated classes, some of which provide Interfaces. As part of a recent project a .Net 2.0 'plug-in' has been developed, which implements a particular Interface from the aforementioned VB6 project. This 'plug-in' is then exposed to com and made accessible back to the aforementioned VB6 Application via Interop, (I know - it's horrible).
The items from the .Net 2.0 plug-in which implement the interfaces are themselves in turn implemented by a menu item in the VB6 application. They're early bound and a specific method is called at start up and at shut down. Event logging in the .Net 2.0 application suggests all of the elements of the call at start up and shut down are run to completion. When the VB6 application is started with the menu item implementing the plug-in attached, a 'Memory could not be "read"' application error is against the VB6 app is caught by the OS, (Windows XP), after application shut down whether you do or do not click the menu item. When the VB6 application is run in debug, the error is thrown when Visual Studio is exited.
Does anyone have any idea what could be causing this?
Cheers,
NB: If the above is confusing or unclear, I can try to clarify
Rhys
"The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it"
They say a little knowledge is a dangerous thing, but it's not one half so bad as a lot of ignorance."
Terry Pratchett
|
|
|
|
|
I have populated a dataset with one table.
The data in the table looks as follows:
Index1Name Index2Name City Value
Indexk Indexk city1 2
Indexk Indexk city1 3
Indexk Indexd city1 2
Indexk Indexy city1 1
Indexy Indexk city1 1
Indexx Indexk city1
Indext Indexq city1 5
Indexs Indexs city1 6
Now I would like to have an array which gets populated from the distinct values in columns of Index1Name and Index2Name
So the array should contain something like:
Indexd Indexk Indexy Indexx Indext Indexs Indexq
Thanks
|
|
|
|
|
You can loop thru and write your own logic to fill in the array(s) you like.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
Hi,
Im using C#.Net 2003,im using windows 2000 operating system.. i retrieved all the available windows user by using the following code and listed in the listbox..
private void button2_Click(object sender, System.EventArgs e)
{
using(DirectoryEntry root = new DirectoryEntry("WinNT://node-10"))
{
foreach (DirectoryEntry child in root.Children)
{
if (child.SchemaClassName == "User")
{
listBox1.Items.Add(child.Name);
}
}
}
}
Actually i want to check is it the right user or not from the C#.Net by programmatically..
in textbox1 im entering the username and
in textbox2 im entering the password
on clicking the ok button it should check whether the entered username and password are the right one or not,if it is the right one, then in messagebox("Valid user") else in messagebox("Invaliduser").and also mention if need to refer any namespaces over here...How should i achieve this one...plz help me..its urgent...
rgrds
Kanna..
|
|
|
|
|
Dotnetkanna wrote: plz help me..its urgent...
I wish I had a dollar for every CP post that ends with that.
Why do you want to do this ? I'd be sad if it were possible to write an app that tells a user on a PC the username and password of all users on that machine. But, why would you require someone to log on using creditials they have already logged on with ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: But, why would you require someone to log on using creditials they have already logged on with ?
I was just thinking that.
|
|
|
|
|
Hi,
Thanks for your reply.I want to check is that particular user is available in that operating system or not.im not going to login.I want jus check is that user is existing or not in the operating system by programmatically.any idea please..
rgrds
Kanna..
|
|
|
|
|
Hi,
Thanks for your reply.I want to check is that particular user is available in that operating system or not.im not going to login.I want jus check is that user is existing or not in the operating system by programmatically.any idea please..
rgrds
Kanna..
|
|
|
|
|
As I said, I'd eat my hat if the system allows you to ask for the passwords of all users. The usernames cannot be hidden, they are written in the Documents and Settings folder.
What you want to do makes no sense, and is unlikely to be supported. Why would you require someone give their password to prove that the system has correctly found their username ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
Actually im doing one process for that i want to check whether the user is exists or not in the operating system..im passing the username and password to this tag,if it is the right user means the program is running well if it is the invalid user means im getting the error..before do that process i want to check whether that user is available or not..for this i want to check this one...
regards
Kanna..
|
|
|
|
|
While I am not sure this will fit what you need I do something similar in one of the applications I develop and you may be able to tweak this.
Basically this application has functionality within it that could feasible be very destructive in the wrong hands. As a result of this I need to ensure that the user sat at the machine is the actual user that is logged on. In order to do this when the application opens it prompts them to enter their windows authentication information.
Internally the code uses the following:
const int LOGON32_LOGON_INTERACTIVE = 2;
const int LOGON32_PROVIDER_DEFAULT = 0;
[DllImport("advapi32.dll", SetLastError=true)]
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
private void DoLogonCheck()
{
this.logonAttemptCount++;
IntPtr phToken = IntPtr.Zero;
bool logonRes = LogonUser(
txtDomainUserName.Text,
txtDomainName.Text,
txtDomainPassword.Text,
LOGON32_LOGON_INTERACTIVE,
LOGON32_PROVIDER_DEFAULT,
ref phToken);
if (logonRes)
{
this.DialogResult = DialogResult.OK;
this.domainUserName = txtDomainUserName.Text;
this.domainName = txtDomainName.Text;
}
else if ((!logonRes) && (this.logonAttemptCount < this.maxLogonAttempts))
{
txtDomainPassword.Text = string.Empty;
txtDomainPassword.Focus();
}
else if ((!logonRes) && (this.logonAttemptCount >= this.maxLogonAttempts))
{
System.Windows.Forms.Application.Exit();
}
}
Externally to this method the code also checks that the given user name is the same user that is under the Environment.UserName object.
As an additional level of security the form that results from successful authentication has a timeout that will close it after X seconds of inactivity. This means that if the user logs in and then gets up an walks away the application isnt open to any passer by.
In theory I believe that this code could also be used to check the logon for a user that is not currently logged on, however I have never used it that way so I cannot say for certain
|
|
|
|
|
Hi,
Thanks for ur Valuable reply.while im using ur code im getting the error on
this.logonAttemptCount++;
.
.
.
this.domainUserName = txtDomainUserName.Text;
this.domainName = txtDomainName.Text;
.
.
else if ((!logonRes) && (this.logonAttemptCount < this.maxLogonAttempts))
.
.
else if ((!logonRes) && (this.logonAttemptCount >= this.maxLogonAttempts))
Im getting error on these lines as "does not contain definition for 'logonAttemptCount'" and "does not contain definition for 'domainUserName'" and "does not contain definition for 'domainName'"...How to i solve this did i need to add any references other than this
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.DirectoryServices;
using System.Runtime.InteropServices;
using System.Web.Security;
using System.Security.Principal;
If yes, give me the detail and give me a solution to the error..plz
rgrds
Kanna..
|
|
|
|
|
those three variables are class level items, so if you want to use logon attempt counts and need to keep a record of the entered user/domain name you will need them (depending on yor class design)
As an example:
using....
using....
using....
namespace Widgets
{
class LogonCheck
{
private string domainUserName;
private string domainName;
private int logonAttemptCount;
public LogonCheck()
{
this.domainUserName = string.Empty;
this.domainName = string.Empty;
this.logonAttemptCount = 0;
}
public DoLogonCheck()
{
}
}
}
That about covers it, however depending on your design you may or may not need these or it may be better to declare these as static
|
|
|
|
|
How can I use Formula in crystal Report 9
|
|
|
|
|
Hi.
I have an auto-increment database field with 5 digits. (example. "00001", "00002", "00003")
But every time i query it using C#, and place it in text boxes or in labels, it always removes the zeros, so I always end up with just "1", "2", "3", etc.
I'm currently using microsoft access 2003. The error also occurred when I used mySQL.
Anyone know how to set form objects to recognize the zeros in the values?
Thanks in advance.
|
|
|
|
|
Its only an error if the value is a string. If it's a number at any point in the process, the 0s are meaningless, and therefore discarded.
You can use string.Format to format a string to have as many zeros as it needs to fit this format.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi every one! I've create my own C++ class and push it to the dll. I need to get only one function from it. It fills many variables of this class. I need to get them, but i don know how. One of this var is vector<string> how can i get this data? I have read the article about calling functions from dll, but i can't get data from my var.
Thanks.
|
|
|
|
|
A vector is a C++ class, you'd need to push out an array ( which is what the vector is wrapping ) instead.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
hi all
i have got two forms one up on the other..
now if i click on the form which is behind the form which is on top is going behind..
i dont want that to happen...
i want the form which is in front should take info. and then active the form behind....
please help me for the necessary..
thanks bye
|
|
|
|
|
I think you need to show a from on top. Considering form1 is the Form object that you want to keep on top of form2
use form1.TopMost = true before calling form1.Show() or form1.ShowDialog()
|
|
|
|