|
having this error after closing a socket. immediately after closing an asynchronous socket I get this exception. vs 2005 does not show any line to debug
|
|
|
|
|
You are right. It comes just after closing asynchronous operation and no line information is given. What approach you followed to solve the problem... any idea ?
|
|
|
|
|
I'm using the color picker to allow a user to specify a background color and I want to set the text color to be the inverse.
I thought the Color object had an inverse property but it doesn't.
Does anybody know how to do this?
|
|
|
|
|
Inverse:
Color c = Color.FromArgb(255 - BackColor.R, 255 - BackColor.G, 255 - BackColor.B);
You may also want to try choosing black, or white depending on the brightness like this:
Color c = BackColor.GetBrightness() > 0.5 ? Color.Black : Color.White;
|
|
|
|
|
It's easy, but not very useful. You just make a new color from the components of the color:
Color.FromArgb(255 - color.R, 255 - color.G, 255 - color.B)
As I said, it's not very useful, as the inverse of some colors is so close to the color that you text will be unreadable. The inverse of medium gray, for example, is so close to medium gray that the text will be invisible.
---
b { font-weight: normal; }
|
|
|
|
|
i faced the same problem before
what i did was that if the diffrence between (color.r) and (255 -color.r)
is less than 50 i just add 50( approx or may be 100 i didnt remember exact) to the result color and same for g and b and result was the solution of invisiblity problem
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
In the Proramming C#;it is said:
"C++ programmers take note: you must explicitly mark the declaration of any method that overrides a virtual method with the keyword override. "
But in this Code"public override void DrawWindow( )",When I delete the override it also run fine!
And I also hope you can tell me wether this book(Programming C# Fourth Edition) is better Or the Beginning with visual C#2005?
If you guys have other wonderful books,Please recommend some to me!
|
|
|
|
|
If you don't explicitly write override before a function name, the compiler assumes that you meant to create a new function.
See also this link from MSDN[^]:
"By default, C# methods are not virtual — if a method is declared as virtual, any class inheriting the method can implement its own version. To make a method virtual, the virtual modifier is used in the method declaration of the base class. The derived class can then override the base virtual method by using the override keyword or hide the virtual method in the base class by using the new keyword. If neither the override keyword nor the new keyword is specified, the compiler will issue a warning and the method in the derived class will hide the method in the base class. For more information, see Compiler Warning CS0108[^]."
In short, the code will compile just fine (perhaps with a warning), but it might produce results that you weren't expecting. Hope this helps!
|
|
|
|
|
i need the information abt how to transfer the values from a particular file, which is in one form, to their respective text boxes which is other form
|
|
|
|
|
string content = File.ReadAllText(file) will read the contents of a file into a string .
Do whatever you want with this string then
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
|
Hi,
I have written a program in which I use a dll that is not .NET.
If I use the part of the program that is only .Net, it works fine. Also if I use only the part that uses the dll. BUt if I use in order the .Net part and then the dll, it gives me an AccessViolationException.
This is a MultiThreading Environment.
I modified the prog so the two part doesn't have anything in common, but it didn't help.
So those are the questions:
- Does the FrameWork move objects? So if I register an event in my dll with a reference, it can be not valid after a while?
- How can I get the memory position of an object?
This is part of the class that imports the dll:
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void SM_MONITOR_PROC(string scanner_id, int evnt, int param);
private delegate void SM_IMAGE_PROC(string scanner_id, int width, int height, System.IntPtr ptrImg, int resolution, int param);
private delegate void SM_STATE_PROC(string scanner_id, int state, int param);
[DllImport("scanman.dll")]
private static extern int SMInitialize();
[DllImport("scanman.dll")]
private static extern int SMFinalize();
[DllImport("scanman.dll")]
private static extern int SMGetScannerCount();
[DllImport("scanman.dll")]
private static extern int SMGetScannerId(int index,System.Text.StringBuilder id, int len);
[DllImport("scanman.dll")]
private static extern int SMStartCapturing(string scanner_id, SM_IMAGE_PROC image_proc, SM_STATE_PROC state_proc, int param);
[DllImport("ssl.dll")]
private static extern int UseDirectCallbacks(int use);
[DllImport("scanman.dll")]
private static extern int SMStopCapturing(string id);
Then I associate a function with the event SM_IMAGE_PROC like this:
SMStartCapturing(ID, new SM_IMAGE_PROC(image2), new SM_STATE_PROC(state), 0);
- The last thing is: I'm using this structure:
Main Class -> ClassManager
-> ChildClass
When I create the childClass, I pass to it the ClassManager instance, so then it can use some methods that I need from there.
What I'm thinking of is that somehow the position of ClassManager changes and ChildClass tries to get the old reference.
Any Idea?
or Any Idea of where else Can I look for an answer?
|
|
|
|
|
ilmarga wrote: Does the FrameWork move objects?
Yes, garbage collection also compacts the heap, so the actual address of active objects can move as the result of a GC.
If you need to insure an address does not change, you must "pin" it. see this for more info[^].
|
|
|
|
|
Hi;
is there a dll or any thing usefull for getting the bytes sent and recieved over the internet just like the windows status dialog when you connect to the net.
I connect through DSL.
I want to get the amount bytes recieved and sent.
thanks,
Riazi
|
|
|
|
|
As I know there is no API for this purpose. It is used very common, may be someone has his own code and want to share;)
|
|
|
|
|
Hello,
I'm new to C# .Net 2, though not to programming, and I'm having some trouble with an object I've created.
ProductStatus is an object that i have used implemented as a List<T> . It is filled from a database, each new record is a new ProductStatus .
My question is, how do I return a sepecific entry from the list, using <T>.Contains for instance, but without having to pass an entire ProductStatus in? For instance just passing in the Name, or it's ID number.
If anyone could recommend some reading about Generics and Collections in C#, that would be just fudgin awesom-o, too.
thanks
|
|
|
|
|
nevermind I used Dictionary<T> in the end.
|
|
|
|
|
For future reference, you can use the generic List's Find method. For example, if you had a list of strings, and you wanted to find the first string starting with "hello", it'd look like this:
string startsWithHello = myStrings.Find(MyCriteriaFunction);
...
bool MyCriteriaFunction(string input)
{
return input.StartsWith("hello");
}
Alternately, you can use anonymous methods to do this in a more concise manner:
string startsWithHello = myStrings.Find(delegate(string input)
{
return input.StartsWith("hello");
});
The next version of C# includes syntax for writing lambda expressions, which simplifies this further:
string startsWithHello = myStrings.Find(s => s.StartsWith("hello"));
Additionally, the next version of the .NET framework will include System.Query.dll, allowing for language integrated query syntax. C# 3 takes advantage of this, and will allow you to write something like this:
string startsWithHello = from s in myStrings where s.StartsWith("hello");
|
|
|
|
|
dear all
i tried to use the WebBrowser and i used the code
webBrowser.Navigate("C:\\m.mht")
but the file didnt previewed in the form
Mohamed Magdy
|
|
|
|
|
I have been working on a custom control, and it's almost finished, but i don't know how to turn the .cs class file into a .dll. Can you help me?
rzvme
|
|
|
|
|
If you have an VS project, open the project settings, select the first tab called Application and choose Class Library as output type.
If you want to compile with csc.exe directly take a look at its command line options in MSDN. There is one (/o if I recall correctly) that allows you to select the output type.
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
if you have extra code in the same project remove that code or create a new class library project and copy your files in that projects folder include them build it and you have it
if you want the release version of your dll then build it in release mode and you have it
It is Good to be Important but!
it is more Important to be Good
|
|
|
|
|
Hi,
Within my background worker's DO_WORK method, I have following code,
......................................................<br />
webBrowser1.navigate("http://www.google.com");<br />
while(weBrowser1.ReadyState != RedyState.Complete)<br />
Application.DoEvents()<br />
....................................................
Now, when the background worker is being executed, webbrowser1 is being loaded with the mentioned website nicely without any problem. But the problem is, when it checks the ReadyState, it stays uninitialized forever and never reaches ReadyState.Complete and thus, the thread never exists. I checked the code with so many website url so there is no chance that I am having problem to load google.com.
I dont have this problem when the same code is being executed in the standard main thread. Only problem when the code is being run in a background worker thread.
Please help... and your co-operation is appreciated.
Emran
-- modified at 3:23 Sunday 5th November, 2006
|
|
|
|
|
Why don't you register to the WebBrowser.DocumentCompleted event instead of actively waiting for the ReadyState property to become Complete .?
It's always complicated to access visual controls from threads other the one they were created on. Take a look at this article to get a general idea how to bypass. What's up with BeginInvoke?[^]
Furthermore the call of Application.DoEvents from a worker thread isn't necessary as the use of the worker thread already keeps your application responsive (in a much nicer way than DoEvents).
"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." - Rick Cook www.troschuetz.de
|
|
|
|
|
bashiwala wrote: while(weBrowser1.ReadyState != RedyState.Complete)
Should that not be ReadyState.Complete?
|
|
|
|