|
You're right. I've both Frameworks installed, but I've already tested the fully-qualified type name. I've also tested the Project on an other machine, having only the .NET 1.1 Framework installed. Nothing worked
But I found an other solution :
Assembly a = Assembly.LoadWithPartialName ("System.Drawing");
Type t = a.GetType ("System.Drawing.Size");
I hope that will work until I've more time to examine the problem.
Thanks anyway.
Nice "Geek-Code-Block" I think I will also include one in my Profile.
|
|
|
|
|
Please help me ! I want to communicate bettwen a service and an application . But i don't know how to .
q
|
|
|
|
|
Use .NET Remoting.
Just search for "remoting" and/or "services" here on CP. Remember to look out for "obsolete" samples. (Ie. code written with a beta version of the framework.)
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
I want to experiement with COM+ application load balancing. What do I need to get started?
a. two machines with Win2000/2003 installed
b. What else do I need?
Would you recommend any article/references/book?
Thanks.
|
|
|
|
|
I am trying to load data to an string variable in the next way:
.
.
.
string s = "";
string text = "";
do {
If ( text have some conditions)
s = s + text + "\n";
text = reader.ReadLine( );
}
while (text != null);
.
.
Then I need to show string "s" to user using a multiline textbox created with Web Forms. The problem is that the previous loop lasts many, many minutes. It tries to load 2MB but in a slow manner, I imagine that the memory allocation is the problem. I need textbox for copy/paste purposes.
Is there anyway to enhance the speed of s = s + text + "\n"; ???
Best regards.
|
|
|
|
|
System.Text.StringBuilder is a little faster:
StringBuilder s = new StringBuilder();
string text = "";
do {
If ( text have some conditions)
s.AppendFormat("{1}\n", text);
text = reader.ReadLine( );
}
while (text != null);
|
|
|
|
|
Corinna,
Wouldn't this be even a little faster?
StringBuilder s = new StringBuilder();
string text;
while ((text = reader.readLine()) != null) {
if ( <condition> )
s.Append(text).Append('\n');
}
Regards,
Jeff Varszegi
[edit] Forgot to include the condition! I'm gonna test the impact of AppendFormat() versus the extra method call. JKV [/edit]
|
|
|
|
|
I was interested enough to run a performance test because I never used AppendFormat before, and I know that StringBuilder is highly optimized. I ran this code in Debug mode in VS .NET 2003 on my laptop:
StringBuilder sb;
string text = "abc";
int x, y;
long startTime, endTime;
<br>
startTime = DateTime.Now.Ticks;
for(y = 0; y < 5000; y++) {
sb = new StringBuilder(10000);
for (x = 0; x < 250; x++) {
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
sb.Append(text).Append('\n');
}
}
endTime = DateTime.Now.Ticks;
Console.WriteLine(((endTime - startTime) / 10000) + " ms using Append()");
<br>
startTime = DateTime.Now.Ticks;
for(y = 0; y < 5000; y++) {
sb = new StringBuilder(10000);
for (x = 0; x < 250; x++) {
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
sb.AppendFormat("{0}\n", text);
}
}
endTime = DateTime.Now.Ticks;
Console.WriteLine(((endTime - startTime) / 10000) + " ms using AppendFormat()");
It printed these results:
<font color="#000066">1682 ms using Append()</font>
<font color="#000066">7801 ms using AppendFormat()</font>
Interestingly enough, creating a separate variable to hold the format string and using that in calls to AppendFormat increased the run time of the second section a little. I still know next to nothing about the IL, but I'm sure there's some good explanation for this.
Regards,
Jeff Varszegi
|
|
|
|
|
I've create an inherit class of dataGrid and add it to form by press of a button. the class will dispose after sending a value to the form by dblclick. The problem is, I dont want to load the class everytime i press the button. I want it to work like load/unload when button press. Is there anyway to check control or class existence?
// this is how i add the class to form by button press
private void button2_Click(object sender, System.EventArgs e)
{
myLOV aLOV = new myLOV();
aForm.Controls.Add(aLOV);
}
PS: Working Environment is .NET Compact Framework on Windows CE 3.0
|
|
|
|
|
if (aLOV == null)
aLOV = new MyDataGrid();
if (aForm.Controls.Contains(aLOV))
aForm.Controls.Remove(aLOV);
else
aForm.Controls.Add(aLOV); Declare aLOV as a field in your class - most likely a private field like all the other controls.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Great thats works... THANKS
but there's something... weird.
the class show only flashes on the first load, but normal after that. is there anyway to solve this ???
THANKS... a lot
|
|
|
|
|
Bhangorix wrote:
the class show only flashes on the first load, but normal after that
I don't understand what you mean? If you mean you want it to be loaded initially, then instantiate it and add it to the controls collection in your constructor (or, like the VS.NET designer does it, in InitializeComponent ).
If this isn't what you mean, please elaborate.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
i mean... when this proc
if (aLOV == null)
aLOV = new MyDataGrid();
if (aForm.Controls.Contains(aLOV))
aForm.Controls.Remove(aLOV);
else
aForm.Controls.Add(aLOV);
call for the the first time, it just flashes.
but never mind, i've work something else that is different but a litle like that one. THANKS anyway
|
|
|
|
|
Basically, i want to know if there is a way to convert an Image to an Icon in C#. I tried the Icon constructor which accepts a Stream object and a Memory stream accepts a byte[], but i wasnt sure how to convert an Image to a byte[].
I am loading a .png file into memory to show a status, but i also have to show the same image in the form's icon and i dont want to have a .ico and a .png file for every status.
Thanks for the help.
|
|
|
|
|
Why don't you load an icon and convert it to a bitmap? Icon.ToBitmap does it.
(Don't know how to do it the other way round...)
|
|
|
|
|
Mybe Im just stupid, but I cant work out how to insert a new line in the text I wish to enter into a textBox (multiline = true) on the COMPACT FRAMEWORK.
\r \n, nope , I need some help.
tia
|
|
|
|
|
Greets,
You should be able to insert a newline as a CR/LF pair, but I would use the System.Environment.Newline static member to add the newline based on the environment.
If you're referring to adding a newline while entering text into one, perhaps Ctrl-Enter may help.
Regards,
Joe
|
|
|
|
|
When a Windows app starts, it typically calls WinMain where it passes the desired window state as the 4th parameter (nCmdShow).
How is this value retrieved in .NET? I've searched the Application object and it doesn't seem to be there.
Thanks!
Alvaro
Can I ask you a question?
|
|
|
|
|
Check the Form.WindowState property of your application form (main form). If you read the documentation for the property, however, it'll tell you that the initial value is always FormWindowState.Normal until the Window is shown.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
If you read the documentation for the property, however, it'll tell you that the initial value is always FormWindowState.Normal until the Window is shown.
So then how can I retrieve it before the window is shown? Surely the runtime must keep it somewhere so it can change the WindowState property right before showing the form. Perhaps there's a Win32 API that holds this information about a process, but I can't find it.
Thanks,
Alvaro
Can I ask you a question?
|
|
|
|
|
The runtime doesn't expose near as much as what Win32 would. Otherwise ListViews would support grouping, working areas, multiple column sorting, and filter columns. It doesn't. Forms would support drop-shadows. They don't. In these and many other cases, you have to P/Invoke code and often defines structs and enums/consts. These are wrapper classes - and early ones at that.
If you need the window state before the application window (main form) is shown in a purely .NET manner, you're sunk.
You could P/Invoke GetWindowPlacement and redefine the WINDOWPLACEMENT struct in the Windows Manager functions (see MSDN Library for this function for more information). It requires an HWND , which you can easily get from Form.Handle (inherited from Control ). Something like this:
[DllImport("user32.dll")]
private static extern bool GetWindowPlacement(IntPtr hWnd, ref WindowPlacement placement);
internal struct WindowPlacement
{
public int length;
public int flags;
public int showCmd;
public POINT ptMinPosition;
public POINT ptMaxPosition;
public RECT rcNormalPosition;
}
internal POINT
{
public long x;
public long y;
}
internal RECT
{
public long left;
public long top;
public long right;
public long buttom;
}
WindowPlacement placement = new WindowPlacement();
placement.cbSize = Marshal.SizeOf(placement);
if (GetWindowPlacement(this.Handle, ref placement))
{
int nCmdShow = placement.showCmd;
}
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Heath Stewart wrote:
The runtime doesn't expose near as much as what Win32 would. Otherwise ListViews would support grouping, working areas, multiple column sorting, and filter columns. It doesn't. Forms would support drop-shadows. They don't. In these and many other cases, you have to P/Invoke code and often defines structs and enums/consts. These are wrapper classes - and early ones at that.
What's the explanation for all these things lacking? I mean, on one hand you'd think it's because they didn't have sufficient time to include everything. While on the other, it looks like a ploy to keep our apps tied to the OS, diminishing the possibility of one day running them on other platforms.
I guess the important question is, is Microsoft planning on filling the missing pieces in future releases?
Heath Stewart wrote:
You could P/Invoke GetWindowPlacement and redefine the WINDOWPLACEMENT struct in the Windows Manager functions (see MSDN Library for this function for more information). It requires an HWND, which you can easily get from Form.Handle (inherited from Control).
That did it! Thanks for taking the time to answer Heath.
Regards,
Alvaro
He who laughs last, thinks slowest.
|
|
|
|
|
Alvaro Mendez wrote:
What's the explanation for all these things lacking?
Perhaps the fact that they could never wrap everything. Look at MFC - it doesn't wrap everything either. There are practically limitless possibilities and they couldn't possibly provide support for everything because there's always different ways of doing things and different reasons for using different code.
Alvaro Mendez wrote:
I guess the important question is, is Microsoft planning on filling the missing pieces in future releases?
I don't know. Probably not. WinFX in Longhorn will wrap a lot of other functionality but, once again, probably not everything because it would be almost impossible to do such as I mentioned before.
The BCL includes stuff that most applications need. When you start worrying about things like Windows position or drawing a Window frame title, you're already typing an application to a particular OS because that stuff is handled different in different Windows managers like Windows, KDE, Gnome, Aqua, etc.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I am looking to change the newly imaged computer's name and add that computer to domain. Can any one help me to do this?
Thanks
CJ
|
|
|
|
|
What, with C#? This definitely is not worth it. It requires redefining a lot of structures already defined for C++ in the Platform SDK and P/Invoking a lot of function calls. And for what? Something that's done very rarely? If nothing else, doing this in VC++ would be much faster and easier to do. Use the right tools for the right job. Now when Longhorn comes around, many of these functions and structures should already be wrapped - but for right now, you'd have to do it all and it's definitely not easy!
Just do it the old fashion way. Right-click on "My Computer", go to "Computer Name" and read the directions. In most cases, your domain administrator doesn't allow you to do this yourself so talk to your IT department.
If you're not looking to do this programmatically, you're in the wrong forum big time! This is for C# programming questions.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|