|
what can i do to solve this prob?
NullReferenceException was unhandled
Object reference not set to an instance of an object
Thanks
|
|
|
|
|
This means that the object you are manipulating upon is null.
|
|
|
|
|
hung1984 wrote: what can i do to solve this prob?
Learn programming.
Sorry, but this is a question like Why am I wet after washing?.
Regards
Thomas
www.thomas-weller.de
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. Programmer - an organism that turns coffee into software.
|
|
|
|
|
something like this :
class xxx{
private int zzz;
public void yyy(){
zzz=1000;
}
}
...
xxx www=null;
www.yyy();
hope it helps
dhaim
ing ngarso sung tulodho, ing madyo mangun karso, tut wuri handayani. "Ki Hajar Dewantoro"
in the front line gave a lead, in the middle line build goodwill, in the behind give power support
|
|
|
|
|
hung1984 wrote: Object reference not set to an instance of an object
Instanciate the object (by using new or giving it a value depending on the object) before the line that is throwing the exception, ideally when you declare it.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hello everyone,
1.
I am playing with Active Directory on Windows Server 2003. But I cannot find many
samples for using C# to use Active Directory API to do management and audit work?
2.
BTW: is there a web-based management GUI for Active Directory which I can use it
remotely?
thanks in advance,
George
|
|
|
|
|
You may want to look into PowerShell from Microsoft.
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 Blog
|
|
|
|
|
Thanks Thomas!
I have a further question. I have a couple of web sites, which has their separate own username and password stored in database for each individual web sites.
I want to implement single sign on function which store all username and password into a single place. Do you think Active Directory is a good choice for me to implement single sign on function? If yes, are there any reference documents about how to implement single sign on function by using Active Directory?
thanks,
George
|
|
|
|
|
I have absolutely no clue when it comes to website databases. I am under the impression that AD is completely separate from the website login information.
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 Blog
|
|
|
|
|
Thanks Thomas!
Current legacy sites are designed in a way which,
- either use IIS or Apache, most of them are using IIS (90%);
- each legacy web sites maintains a separate database table which stores site separate specific user name and password (e.g. using a USER table). My question is if I move all user credential to Active Directory, and I also want to keep authentication work transparent to each sites. My question is whether there is any ways which could save each web sites from coding authentication and just change some configuration will make authentication work?
regards,
George
|
|
|
|
|
Hello everyone,
typeof operator gets the exact type of a variable. My purpose is to check whether the type of a variable derives from a specific base class, any ideas of how to use typeof to solve this issue? Or using some other solution other than using typeof?
thanks in advance,
George
|
|
|
|
|
if (myobject is base)
should do it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Thanks Christian!
You are so smart!
regards,
George
|
|
|
|
|
You don't use typeof to get the type of a variable. Either use variable.GetType() or typeof(YourType) .
If you just need to know whether the variable derives from a specific class, then you could check if (variable is YourBaseType) as Christian suggested. If you need to perform a cast, use the as operator. If you don't have an instance of your type, then you could use typeof(YourDerivedType).IsSubclassOf(YourBaseType) , or you could use typeof(YourBaseType).IsAssignableFrom(YourDerivedType) .
|
|
|
|
|
Cool, hosamaly!
You are so knowledgeable!
regards,
George
|
|
|
|
|
The added benefit of:
MyObject obj = (genericObject as MyObject);
over
MyObject obj = (MyObject)genericObject;
is that the first example won't throw an exception if it can't cast it, it'll set <c>obj to <c>null rather than throw an <c>InvalidCastException
I doubt it. If it isn't intuitive then we need to fix it. - Chris Maunder
|
|
|
|
|
hello
System.Double (.NET/CLR type) vs double (C# type)
My question is, when to use what?
Thanks!
dev
|
|
|
|
|
They are the same thing.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
The C# double type is just an alias for System.Double . Just like int is an alias for System.Int32 .
|
|
|
|
|
Hello,
I am just learning LINQ to SQL and so far I am excited and I am going to replace DataSet usages in my application with DBML (LINQ to SQL). Now, I am thinking about a scenario when I will change the structure of the table in my SQL server, how will my LINQ queries be updated in my code ? Will they be auto updated or I will have to do it manually in all files. If so, then what is the efficient solution for using LINQ when I have a plan to change the Database table structures !!
Regards
|
|
|
|
|
Don't change the table structure?
No mapping tool is going to automatically fix your code if you significantly change the database design. I'd suggest you consider designing your database first, then coding.
|
|
|
|
|
Hello sir,
Thanks for your reply.
As you would realize that, in future, I may need to add an extra field in a table or I may need to delete a field from a table. I think, the nature of this requirement is common to every developers, not only me. So, what is the efficient procedure to handle this situation in the future ?
One benefit of using DataSet that I was enjoying... When I changed a field in my database, I updated the dataset and as all table adapter methods stay together in the datase, I can easily track the usage of the methods in my code and fix accordingly. But when I am using DBML file, I dont see any methods (unless SPROC) in the DBML file, so I wont have any idea about how many files are using the table from the DBML. Thats why, I was wondering and thinking that, there must be a way.
|
|
|
|
|
hello,
I'm testing .NET connection pooling facility, I configured max pool size 10 and in accordance there was no exception when I oConn.Open until I opened the 11th connection.
<br />
static void Main()<br />
{<br />
string strConn = "Data Source=DEV\\SQLEXPRESS;Initial Catalog=Northwind;Persist Security Info=True;User ID=NorthwindSA;Password=xxxxx;connection reset=false;connection lifetime=5;min pool size=5;max pool size=10";<br />
<br />
IDbConnection oConn = null;<br />
ArrayList oConnections = new ArrayList();<br />
int nIndex = 0;<br />
<br />
for (int i = 0; i < 20; i++)<br />
{<br />
try<br />
{<br />
oConn = new SqlConnection(strConn);<br />
oConn.Open();<br />
oConnections.Add(oConn);<br />
<br />
Thread.Sleep(100);<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine("iteration: " + i + ", " + ex.Message);<br />
nIndex = i;<br />
break;<br />
}<br />
finally<br />
{<br />
<br />
}<br />
}<br />
<br />
Console.WriteLine("max number connection established: " + nIndex + ", preparing to dispose connections openned");<br />
<br />
foreach (IDbConnection oConn2 in oConnections)<br />
{<br />
if (oConn2 != null)<br />
{<br />
try<br />
{<br />
oConn2.Close();<br />
}<br />
finally { }<br />
}<br />
}<br />
oConnections.Clear();<br />
<br />
return;<br />
}<br />
However - one thing I am not sure is - I'm watching Perfmon \ SQL Server General Statistics \ User Connections. The counter is showing "3" before and after test. The fact that my test application fires up 10 new connections (min=5,max=10) does not seems to have anything to do with Perfmon counter.
Thanks
dev
|
|
|
|
|
Trying doing a query with each of the connections as see what happens.
Also, the PerfMon counter you're using is looking at the connections inside SQL Server. It's not looking at them from your code's point of view.
You might find it interesting to look at both sides at the same time. Start looking at the .NET Data Provider for SQL Server counters.
|
|
|
|
|
I am trying to correlate oConn.Open with Perfmon counter...
dev
|
|
|
|