|
The NetType you're talking about is actually System.Type[^] . You can get it using Object.GetType[^], Assembly.GetTypes[^] etc. For example, if you want to fill a combobox with all public types in your assembly, you can do:
using System.Reflection;
private void InitializeTypes(){
cmbBlah.Items.Clear();
Assembly currentAss = Assembly.GetCurrentAssembly();
Type[] publicTypes = currentAss.GetExportedTypes();
foreach (Type type in publicTypes){
cmbBlah.Items.Add(type.ToString());
}
}
Welcome to the wonderful world of reflection!
Merry Christmas!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
After a bunch of ASync socket calls, I get the exception below. Google-ing it came up with only 4 hits, 2 from the same person, none with answers.
This is happing in a server application, so if no one has a solution, is there another way to run a TCP server (average of 500 simultaneous, sustained connections. Max possible connections is about 5000, but VERY unlikely) without having a thread for each client, that would be great.
-------------------------------------------------------
"The Undo operation encountered a context that is different from what was applied in the corresponding Set operation. The possible cause is that a context was Set on the thread and not reverted(undone).".
at System.Threading.SynchronizationContextSwitcher.Undo()
at System.Threading.ExecutionContextSwitcher.Undo()
at System.Threading.ExecutionContext.runFinallyCode(Object userData, Boolean exceptionThrown)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteBackoutCodeHelper(Object backoutCode, Object userData, Boolean exceptionThrown)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.ContextAwareResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
|
|
|
|
|
Update:
You can see my socket connection class code Here.
The exception occurs while executing a method in another class called from inside "OnDataRecieve".
-- modified at 5:35 Friday 30th December, 2005
|
|
|
|
|
My DataGrid is serviced by a DataTable. Suppose I would like to make a red background for rows 3 and 5 in this DG. How to make it?
|
|
|
|
|
hi all,
iam able to sending mails using SMTP sever..
but now,how can i send my inbox mails to my database?
can any one know it?
thanks in advance...
byeeeeeeeeeee
sree
|
|
|
|
|
How can i send file from computer A to computer B
|
|
|
|
|
Windows Sockets...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
You must learn network programming for this.
TcpListener,TcpClient,Socket,NetworkStream Classes defined for network programming in Visual C#
This classes in System.Net.Sockets namespace.
|
|
|
|
|
I'm writing a program that does a lot of heavy computing. I eventually want this program to run as a screen saver. But because of all the heavy computer the program does, after a few minutes of running, the fan turns on - wasting energy and making noise, two things a screen saver shouldn't do.
So far I've tried various ways of putting the current thread to sleep for some time, to give the computer a rest, but I haven't had very much succes. Is there a better way to slow down my program or as least (safely) manage it so the fan doesn't come on?
Thanks,
Drausin
|
|
|
|
|
Fan? Which Fan?
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
I think he means the fan on his processor - you know, the thing that cools it down and stops it from overheating.
My: Blog | Photos
"Man who stand on hill with mouth open will wait long time for roast duck to drop in." -- Confucius
|
|
|
|
|
You could try modifying your process priority. I don't know if this will reduce the absolute processor load or if it's just relative to other processes...
Regards,
mav
|
|
|
|
|
You can try System.Threading.Thread.CurrentThread.Sleep(somemillisecondsvalue); in your working loop...
Merry Christmas!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Yea, I ended up doing that - putting a sleep function into my loop (as opposed to on a separate thread w/ a timer), and it seemed to work pretty well.
Thanks everyone,
Drausin
|
|
|
|
|
Hello all,
I am reading different types of files from DB & Storing at perticular place.
My code is as follows...
<br />
FileStream fs = new FileStream(sFileName, FileMode.Create, FileAccess.Write);<br />
BinaryWriter bw = new BinaryWriter(fs);<br />
<br />
bw.Write(buffer);<br />
bw.Flush();<br />
<br />
bw.Close();<br />
fs.Close();
This is code is not writing proper data only in case of .sql files
Why .sql not writing properly, anybody help me. If there is any alternate in C# inform me.
regards
GV Ramana
|
|
|
|
|
Might be useful if you described what you mean when you say :
Gali Ramana wrote: sql not writing properly
what are yu expecting? What are you getting?
Absolute faith corrupts as absolutely as absolute power
Eric Hoffer
All that is necessary for the triumph of evil is that good men do nothing.
Edmund Burke
|
|
|
|
|
I have a service in a remote system that has a fixed port number.
Does any body has a simple code how to check if service is running using C#
Any help will be greatly appreiated
|
|
|
|
|
I think the best way is to just try to connect. If the Sevice is listening then the connect will succeed else it will fail. If it fails, Service is not running.
Hope this helps...
---
With best regards,
A Manchester United Fan
The Genius of a true fool is that he can mess up a foolproof plan!
|
|
|
|
|
Hi
I have been working with C# for the past few years and I am currently looking for another C# position. My current job involves working with the C# language and a large API. Thus I haven’t had too much exposure to some of the key areas of .NET.
So I am trying to identify a few key areas to study in preparation for interviews. Hopefully with the help of CodeProject articles
I am thinking about looking at:
- Brushing up on C# - boxing and a few other intricacies
- Web Services
- ADO.NET
- Perhaps looking at studing for some MCP Exams. Any one have any opinions on them? Worth while?
Any suggestions on key areas and resource would be much appreciated.
Cheers
Rich
|
|
|
|
|
One thing to think about for certification is that they are releasing new certifications for develops next year based on .NET 2.0. For these certs, they are separating out people that do websites from window development from enterprise architects. So you will have to decide if you want to take exams based on .NET 1.1 or 2.0.
I would say to look at ADO.NET.
Steve Maier, MCSD MCAD
|
|
|
|
|
If you'd like to take a test that may identify some weaknesses, then the C# Fundamentals and C# tests from BrainBench have no cost. They might help pinpoint some areas of C# that you could then study.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
DataSet DS = new DataSet();
foreach(string Q in Query)
{
string Error="";
DataTable DT = RunQuery(DSNName,Q,out Error);
if(DT==null)
DT = new DataTable();
DT.ExtendedProperties.Add("Query",Q);
DT.ExtendedProperties.Add("Error",Error);
DS.Tables.Add(DT);
}
retXml = DS.GetXml();
StreamWriter SW = new StreamWriter("c:\\temp\\PreXml.txt",false);
SW.Write(retXml);
SW.Close();
In the above code I iterate through a string array of queries and populate Datatables and their ExtendedProperties. But when I then write the XML to a file, I cannot find anything about the ExtendedProperties within the XML. I've also tried to load the XMl back into a DataSet, but again no ExtendedProperties are there. Any help or suggestions ?
|
|
|
|
|
This may sound like a dumb question, but how do I set an icon for a program I just made. I've already put the icon on the upper left menu on the form window, but I don't know how to set the icon for the program itself (like what you click to open it). Whenever I search I only find information on the control box icon.
I'm sure its super easy and I'm just not finding it (using C# 2005 EE).
|
|
|
|
|
It should be available by right clicking your project (the exe) and then selecting properties. This should open a nice window with some options for you. In the tab 'Application' you will find 'Resources'. Here you can set the icon file for the application.
|
|
|
|
|
Does anyone know how to allow a user to change the password in an MS Access database? My connection string (at least the path and password) is set programatically, read in from an encrypted file when the application loads, but I need to enable to user to change both the path and password for the database if necessary. Selecting the path is easy enough, but I'm not sure how to reset the password. Any help would be appreciated. Thanks.
|
|
|
|