I have a interesting problem with one of my gui's in the Forms Designer in VS2003.
When I open the form in design view my studio crashes with a Stack Overflow Exception.
When I analyze the crashed process I can see that it is executing one of the constructors of my data and comunication model classes.
Call Stack shows that these were created because the constructor of my Form registers some methods to events in the model.
The crash could be related to the fact that the model is unmanaged code provided by wrapper clases.
The crash is 100% reproduceable.
(uneccessary to say, under normal runtime conditions the same code works fine)
One solution would be to prevent this snip of code (the data and communication classes) to be executed in design time.
I don't believe it is neccessary to create an instance of them.
How can I detect that my code is executed in the designer oposed to normal execution.
I found some hints about providing custom designers and thereby changing the behavior, but issent there simply somewhere a boolean I can read, saying designtime/normal?
I converting a bmp to png using the System.Drawing.Image.Save function by passing the format PNG. Now the problem is .NET framework seems to be using zlib compression level 6 by default. If I use a command line program like pngcrush at compression level 9 I get smaller png files.
Now, is there a way to make .NET framework api produce smaller size png files?
"Applied Microsoft .NET Framework programming" by Jeffrey Richter is a very good book that deepely covers both the framework and the CLR from a general point of view (strings, events, assemblies, GAC, Garbage collector, ..), it uses C# and IL to show some code snippet, there's nothing about windows forms, XML, ADO.NET and so on.
Is it the correct way to list the domains? It is giving only the domain name in which i am a user and i log in with this user. This domain has subdomains and also along with this other domains are also there.
Imagine the following scenario:
A shared member variable "TheResult" is null.
A worker thread sets this variable with the result of its computation (and terminates).
Another frequently running thread checks for this variable beeing null or not. If it is not null, it assumes the worker thread has assigned a valid object to it and uses it.
Do I need to monitor the access to that variable, i.e. use lock in C#? Or in ohter words, can the assignment "TheResult = TempResult" be preempted, so that "TheResult" is neither null nor a valid object reference? Is the assignment of an object an atomic instruction that cannot be interrupted?
Thank for any hints.
Assigning a reference is atomic, AFAIK. But I think you need to declare "TheResult" volatile, as you are modifying its value from a different thread while frequently checking it for null value. If it is not volatile, there is a chance that checking thread reads null even *after* the worker thread sets it to the correct value.
I would have missed "volatile" without your hint (although missing the result wouldn't have been a big problem in my context). I probably will have to use Interlocked.Exchange, just to be sure it is atomic, because I don't find a guarantee.
If moving a 32 bit value is atomic, then setting a reference is. I think it should be atomic in x86 processors, as it can written as a single
mov ax, val
assembly instruction. And processor instructions are atomic, AFAIK.
In Windows Forms the ListBox class has a GetItemText method, but lacks a GetItemValue method. How to retrieve the associated value of any specified item? There is a SelectedValue property. That does not work for me because I need to get the value for any item without changing the selection of the listbox.
Actually I was using the checkedListBox class. At a certain point in the program I want to get the associated values for the items the user put a check mark on.
this might be a stupid question, but i haven't found an answer on either this forum or the MS knowledge base, so here is my problem:
On a PocketPC 2003 and using the Compact Framework, I want to create a copy from an image (an embedded resource 24bpp png), modify that copy and use it in subsequent redraws of a control (a class deriving from Forms.Control and overriding OnPaint).
For this I use the copy-contructor of the Bitmap class (dstImage is a member of the control):
dstImg = new Bitmap(srcImage);
This seems to be a valid copy of the source image, dstImage.GetPixel returns color values identical to srcImage.GetPixel throughout, and the Width and Height properties show the expected image size. However, when I render that image to the control with
protectedoverridevoid OnPaint(PaintEventArgs e)
e.Graphics.DrawImage(dstImg, 0, 0);
// An alternative that doesn't work any better//Rectangle r = new Rectangle(0, 0, srcImage.Width, srcImage.Height);//e.Graphics.DrawImage(dstImg, r, r, GraphicsUnit.Pixel);// Junxtapose original to the right of dstImg, it will have the correct size:
e.Graphics.DrawImage(srcImage, dstImage.Width + 1, 0);
then the image is only about a quarter in size of what it should be. It is not truncated (and small enough to fit in the control entirely), but scaled down. Using srcImage in the above code does not exhibit this unwanted scaling. Please note that there is code ensuring that dstImage is only attempted to be drawn when its production is finished (omitted for brevity).
I've also tried to use different means of contructing dstImg, like
dstImg = new Bitmap(srcImage.Width, srcImage.Height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(dstImg);
Rectangle r = new Rectangle(0, 0, srcImage.Width, srcImage.Height);
g.DrawImage(srcImage, r, r, GraphicsUnit.Pixel);
A final note: this problem is specific to the compact framework. If I paste the above snippets in a 'full' framework app and run it, both original and copy show correctly. I suspect this behaviour might result from some mismatch of the DPI settings, however you can't seem to access these members (HorizontalResolution and VerticalResolution) in the CF? What am I missing/doing wrong?
Any help and subtle pointers to possible stupidity on my part would be appreciated,
I hear about we can run .Net on Win98 but I just worry about the performance.
And Howabout Run .Net on Win95?
Because I have a hundred of client PCs (Pentium100, Ram32) and I love .NET, I don't want to build vb6 application for this new project.
I am new to using Hooks, and am trying to write a process that will run through all processes that are running on a particular computer and for each one determine if there is a visible window and if that window has the focus. I am pretty sure that I will need to use a "Hook" to do this, however I have no clue where to begin. Does anyone have any suggestions as to where to start/what methods will be useful in determining this? Also, will this be possible using the Process class?
Jeffrey Richter wrote a program to enumerate running processes and return information on them in his book, "Programming Applications for Microsoft Windows". The application was called ProcessExplorer, and was written for Windows 2000 (pre-.NET). You could use the same methods and do it all with Platform Invoke.
I'm a student of computer who liked C,C++ very much so,in order to preogram under windows selected MFC C++,however not long after I got more familier with VC++ 6, I heard news about .NET.
I started looking at it's best languages including C# and Managed C++.
But Most of them disapointed me! I belive most of them are more like "Borland Delphi" to C++.
I wanted to ask code project programmers following questions: will all others move to .Net? Will "MFC like" programming die? Is Microsoft going to lose her C++ programmers? I know it's too late to ask these questions:zzz: but it's late because I was trying to learn at least one PL from .Net and now I see it's not a lovely work!
Hamed Mosavi wrote: I belive most of them are more like "Borland Delphi" to C++.
That's not surprising - Microsoft hired the guy that created Delphi to create C#
Hamed Mosavi wrote: will all others move to .Net?
Not all, no. Althought I think that many people will still make the move.
Hamed Mosavi wrote: Will "MFC like" programming die?
I don't understand what "MFC like" programming is. MFC (Microsoft Foundation Classes) is a framework that sits on C++ that allows you to create various types of applications. The .NET Framework is similar but it is used by managed languages, such as C#, VB.NET or Managed C++, that allows you to build various types of applications.
Hamed Mosavi wrote: Is Microsoft going to lose her C++ programmers?
No. There are many things that cannot be written in a managed language. There are many applications that have been evolving for years in C++ that won't be re-written for C# as C# has various interop abilities in order to allow legacy applications to integrate.
Hamed Mosavi wrote: I was trying to learn at least one PL from .Net and now I see it's not a lovely work!
It depends on your point of view. I switched in 2001 to .NET and I love it. I love the ease that I can create applications. I love that it allows me to integrate with older software. I love the fact that writing code that queries databases is so much easier that it was.
I totally agree. For all its problems, .NET shines because of the BCL. It simply lets users program at a higher level. It's been very well designed too. The number of times I've expected a method to be in a certain class, only to find it precisely there with the same name, it's really stunning.
Thanks alot for your answers.
I think my weak English once again made some problems,Sorry!;P
When I say "MFC Like!!" I mean : when I want to write a new app, I go towards New MFC Project, Select the type (Single Doc,...) and have a template to work on.
one more thing: You mentioned that you moved to .Net because it's easier. "I love the ease that I can create applications"
Could you tell me please how is it easier when there is not any editor for creating dialogs, any single doc or multiple doc template, however I found "form creator template".
Finally if you want the fact, the reason that I didn't move to Delphi when I started learning a Visual Language was that I hated Delphi, and that was one of the best reasons I selected VC++! Now!!
once again I appreciate you for your acswers and excuse me if my english is very bad!
Last Visit: 31-Dec-99 19:00 Last Update: 3-Dec-23 6:58