|
I'm using 1.0 framework with SP2. With less than a week to go v1.1 seems a bit risky + we have lots of other apps on v1.0 that need to ship together. I'm developing & testing on XP pro but we deploy onto Win2K advanced servers. Fully patched & serviced packed in both cases.
I've also made an interesting discovery:
I've downloaded the SciTech memory profiler which I've attached to the Service. Things continue to leak as usually during the test, however after I create the first snapshot, it seems to start garbage collecting correctly!!!! I dont know what the profiler does but you can see that is makes some forced GCs which kick things into action. I've tried to do this myself in code by forcing collection but it didnt work. What could be causing things to suddenly work when the profiler first does something?
|
|
|
|
|
solidstore wrote:
I've downloaded the SciTech memory profiler which I've attached to the Service. Things continue to leak as usually during the test, however after I create the first snapshot, it seems to start garbage collecting correctly!!!! I dont know what the profiler does but you can see that is makes some forced GCs which kick things into action. I've tried to do this myself in code by forcing collection but it didnt work. What could be causing things to suddenly work when the profiler first does something?
Forcing collection doesn't work? Strange. It seems that you have some form of dangling pointers. You've said you are mixing remoting + COM. Can you isolate one of them, like, creating a "pure" remoting client and a "pure" COM client, to see where is the problem, or if the problem comes with mixing them?
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
good idea! do you mean create a C# exe to test the Remoting by creating the objects natively? And create another C++ client to create the COM objects but without setting up the remoting configuration?
Other tests just in:
I've just tried make my service run under my local administrator account (instead of SYSTEM) and the memory performance counters appear normal (although my process no longer show up in the perfmon list - I'm having to use _Global_).
Could the user account being used affect GC?
Why has my process/service disappeared from perfmon now I've changed the user account?
|
|
|
|
|
|
Also is Remoting and COM Interop OK with the same object? Or should I create one object thats exposed to COM which internally calls my remote component?
|
|
|
|
|
Are you using COM objects in your service, like ADO recordsets?
They can be a big source for memory leaks, because all the GC can see is the managed allocated memory, which is small, basically a pointer to a small wrapper. But, on the side of the COM object, it may be taking several MB of RAM.
So, to assure a COM object is correctly garbage collected, you need to call System.Runtime.Interop.Marshal.ReleaseComObject on a loop until it returns 0.
Another common source for memory leaks under a GC environment is forgetting to call Dispose on the IDisposable objects.
My latest article: GBVB - Converting VB.NET code to C#
|
|
|
|
|
see reply to leppie above - many thanks
|
|
|
|
|
When our code is running as a normal C# process, garbage collect can be seen
working using perfmon during a test. Running the same code but as a service,
garbage collection does not appear to kick in? However when attaching the
Memory Profiler the service returns to expected garbage collection as viewed
from perfmon.
What could cause my code running as a process (and profiled service) to have
a nice shallow zig-zag perfmon trace of #bytes in heap. Yet when its run as
a service the #bytes in heap rises very steeply indeed and no sign of the
garbage collector's zig-zag?
The code is fully managed and I'm not using any COM objects. I am exposing object within my assembly to COM and via Remoting
|
|
|
|
|
Hi, I was wondering if anyone knew about a grid for windows forms that could do the following
I want that the user enters a value in the grid and that for every value he enters appears a combo box in the cell next to the value he entered
There is no data binding, the user manually has to enter a value, and for each value there has to be a combo box next to it from which he can make a selection
Then I can iterate through the grid and get what he typed and selected
Thanks in advance
|
|
|
|
|
You can use the SourceGrid that is available on this site. It provides the functionality that you have requested and isn't data bound.
|
|
|
|
|
Hey,
Ive been writing a simple image viewer program in C# and wanted to add the option to save a loaded image to another format. In the tiff format though its been a pain, i want to read in the tiff image's format, and give the option of changing that format. So far i do not know how to read an images properties, can anyone help?
Heres the proto source code ive done (bulit up mostly from CodeProject articles )
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace ImageViewer
{
public class MyForm : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
protected MenuItem _itemNativeSize;
protected MenuItem _itemWindowSize;
protected int _filterIndex = -1;
protected Bitmap _myBitmap;
protected bool _nativeSize = true;
public MyForm()
{
InitializeComponent();
// set the initial text and size of the window
this.Text = "Image Viewer 0.0";
this.ClientSize = new Size(640, 480);
....
}
private void OnOpenImage(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if(_filterIndex != -1)
ofd.FilterIndex = _filterIndex;
if(ofd.ShowDialog() == DialogResult.OK)
{
String filename = ofd.FileName;
if(filename.Length != 0)
{
_filterIndex = ofd.FilterIndex;
try
{
_myBitmap = new Bitmap(filename);
this.Text = "Image Viewer - " + filename;
this.AutoScroll = true;
this.AutoScrollMinSize = _myBitmap.Size;
this.Invalidate();
}
catch
{
MessageBox.Show(String.Format ("{0} is not " +
"a valid image file", filename), "Error");
}
}
}
}
private void OnSaveImage(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save Image As";
if(sfd.ShowDialog() == DialogResult.OK)
{
sfd.AddExtension = true;
String filename = sfd.FileName;
if(filename.EndsWith(".png"))
_myBitmap.Save(filename, ImageFormat.Png);
else if(filename.EndsWith(".tiff") || filename.EndsWith(".tif"))
_myBitmap.Save(filename, ImageFormat.Tiff);
else if(filename.EndsWith(".bmp"))
_myBitmap.Save(filename, ImageFormat.Tiff);
else if(filename.EndsWith(".jpeg") || filename.EndsWith(".jpg"))
_myBitmap.Save(filename, ImageFormat.Jpeg);
else if(filename.EndsWith(".gif"))
_myBitmap.Save(filename, ImageFormat.Gif);
else
MessageBox.Show("Unknown file type");
}
}
private void OnExit(object sender, EventArgs e)
{
this.Close();
}
protected override void OnPaint(PaintEventArgs e)
{
if(_myBitmap != null)
{
Graphics g = e.Graphics;
if(_nativeSize)
{
g.DrawImage(_myBitmap,
this.AutoScrollPosition.X,
this.AutoScrollPosition.Y,
_myBitmap.Width, _myBitmap.Height);
}
else
{
g.DrawImage(_myBitmap, this.ClientRectangle);
}
}
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new MyForm());
}
}
}
|
|
|
|
|
Hey All,
I have been printing to a Zebra barcode printer previously in vb6. I was able to print just a test line of text by using something similar to the following,
printer.print "This is a test"
I am trying the same little test using cSharp with this statement,
e.Graphics.DrawString(textToPrint, printFont, Brushes.Black, 0, 0);
This being an event that is called when my printPage_PrintDoc event is being fired. The printer seems to recognize that it is receiving text, and then just prints out a blank label. I even checked the ribben to ensure that its just not printing off of the label somewhere, as if I had bad x,y coordinates. Any suggestions would be greatly appreciated.
Thanks,
Ryan
|
|
|
|
|
Curious how a person would go about adding Visual Inheritance _after_ you have already created the forms. I am currently working on an MDI application and I decided to use VI on the majority of those forms.
Is there a way to add the inheritance after the fact ?
Rocky Moore <><
|
|
|
|
|
WinForms inherit from From as shown in top of your class' source code...
public class frmAbout : System.Windows.Forms.Form
Just make yourself another form (your new base form, somewhere down the line inheriting from System.Windows.Forms.Form) and replace the inheritance in your existing class.
It should look something like this:
public class MyNewBaseForm : System.Windows.Forms.Form<br />
{<br />
}
and
public class frmAbout : MyNewBaseForm
Should come up in the visual designer too...
|
|
|
|
|
Arjan Einbu wrote:
Should come up in the visual designer too...
Didn't come up nor at runtime. That is why I asked, trying to figure out what is missing. I even tried closing out all designers and closing VS.NET then reloading. Still no go.
Rocky Moore <><
|
|
|
|
|
Arjan Einbu wrote:
Should come up in the visual designer too...
For some reason, when I copied the project to another directory it lost the background image settings and the buttons on the form to be inherited happend to be off the view of the form. When I would run the application it did not show the background nor the buttons (since they were clipped). The designer still showed everything proper for the base window until today when I booted the system and went into the designer.
Anyway, now works as I thought it would have the first time.
Rocky Moore <><
|
|
|
|
|
How to Open the default browser from a listview from the doubleclicked column.
The Problem is i can create a new Process with IE but is there any other solution build in .net namespaces ?
Martin Lierschof
Junior Programming Assistant
World-Direct.at eBussines Solutions GmbH
mail²: martin.lierschof@world-direct.at
|
|
|
|
|
System.Diagnostics.Process.Start("http://www.codeproject.com");
It still starts a new process...
|
|
|
|
|
hmm thanks i found it allready, but i get this errormessage: "The requested section was not present in the activation context" on this url: "ftp://ftp.pku.edu.cn/pub/faq/rec.answers/mensa/";
Martin Lierschof
Junior Programming Assistant
World-Direct.at eBussines Solutions GmbH
mail²: martin.lierschof@world-direct.at
|
|
|
|
|
I have 2 forms. Once the first loads, the second is loaded, but hidden. I am trying to pass a string from Form1 to Form2, but have no idea how this is done. I cannot change the constructor in Form2 to have this string, as the string would not have been decided yet. I hope you understand what I mean. Does anyone have any ideas? Is there anything like a session variable?
|
|
|
|
|
Well, if you are display the second form from the first one then you just add a property to the second form.
You can also use a static global (eek.. Yep Global) class with a static property for the data you wish to pass. In most of my current apps, I have a static class called "ApplicationData". It holds any information that will be required by several classes (or forms). It is also where I hold in memory configuration data.
Rocky Moore <><
|
|
|
|
|
Thanks for the reply. This may sound really stupid, but I have just started coding in C#, and dont know how that is done. I thought if I set a global attribute in one class, that I can then call that one from another class. But I cant reference it directly, so was not sure of anyway to do it. But your way sounds good, however, I dont know how to do that. Have you seen any samples on this type of thing?
|
|
|
|
|
Well, in my applications I have a global static class such as:
public class ApplicationData<br />
{<br />
public static string aSharedString=string.Empty;<br />
public static string userName = string.Empty;<br />
public static int user_ID = -1;<br />
public static string currentDocumentName = "RalphyBoy.txt";<br />
}
It can be cleaned up with properties if you like or to add code for locking if thread saftey is a concern.
In my applications, this would have methods to read/write configuration data along with possibly to persist state of an application when required.
It is true that C# does not have any globals but it is also true that they do, it is that you wrap them up in a nice neat class and access the static instance of the class.
Rocky Moore <><
|
|
|
|
|
Using VC,the element events can be get by the following code,how can I get the html element events using c#?
STDMETHODIMP CEventSink::Invoke(DISPID dispidMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS* pdispparams,
VARIANT* pvarResult,
EXCEPINFO* pexcepinfo,
UINT* puArgErr)
{
switch (dispidMember)
{
case DISPID_HTMLELEMENTEVENTS2_ONCLICK:
OnClick();
break;
default:
break;
}
return S_OK;
}
Thanks.;)
|
|
|
|
|
Take a look to this article
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=312
|
|
|
|