|
So I have been trying with not much luck to get Instances to work with my custom Performance Counters. I've looked everywhere I could think of, and the documentation isn't even close to good on how to create and then use instances with my custom counters. Perhaps I'll have to post an article on what worked for me so I can get feedback on what I should have done I found a newsgroup posting that claimed you had to reboot to get the instances to appear for a new custom counter. Only recently after rebooting did I get my instances to register when my application begins, I had tried everything short of rebooting to get them to appear in perfmon.
Now the issue with my instances is that the Instance names are all in lower case. I have not set them to be like this, is this a known issue? The Microsoft applications that have Performance Counter Instances don't use all lower case Instance names, so why must I? I want to be cool.
My code to create an instance looks like this:
PeformanceCounter PC1 = new PerformanceCounter("MyCategory", "Some Counter", "Value One", false);
I can then do things like increment and set the raw value, but in perfmon (and through the enumerating instance names with c# code) the instance name is; "value one". The Category and Counter names have the proper casing I used, but the Instance Name does not. This happens with all of the Instance names I try to use with my custom counter. Thanks in advance for any advice.
|
|
|
|
|
I am trying to design a new class Library but have questions about separate logic from base class(with base namespace BaseNamespace).
I have the base namespace BaseNamespace and inside it the nested namespace System. And inside System there is a normal class for action - File. I think about the size of this base class and its different namespaces. It cannot be to use #region statement for better handling. I need to write the logic of File (for example) to another class(own class file). There is no problem with it, if I call such methods, attributes a.o from another class, but is there a general design guide for builing huge class libraries ?
namespace BaseNamespace<br />
{<br />
namespace System<br />
{<br />
public class File<br />
{<br />
}<br />
}<br />
}
|
|
|
|
|
|
Hello All,
Doing a really simple import of a csv file using odbc. A sample line of that file may look like this:
200,-,0,-,461020,-,0,.,30,-,0
For some reason, it doesnt seem to want to import the '-' character, it actually returns a 0 on a tostring of that character. I did try converting it tochar. Any suggetions on how I get the actual value?
Thanks,
Ryan
|
|
|
|
|
Hi,
I would like to delete some lines from a textfile. Can I delete
or modify lines in a textfile or should I create a new file and copy the new content to it?
Thank's for answers!
Br,
Levi
|
|
|
|
|
omnisLevi wrote:
should I create a new file and copy the new content to it
That's exactly what you should do. Read every line from your source file, and if you want it in the destination, write it; Otherwise, skip it.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hi,
i am trying to use a DLL(LibPl.dll) which was written C++. I imported the native Methods via DLLImport:
<br />
[DllImport(DllFileName)]<br />
internal static extern uint PL_new_term_refs(int n);<br />
When I use this Method (PL_new_term_refs) in the Main Application everything works fine.
But if exactly the same Code is called via an event/delegate it is not working
anymore. What I get is the following Error:
<br />
An unhandled exception of type 'System.NullReferenceException' occurred in aflib.dll<br />
<br />
Additional information: Object reference not set to an instance of an object.<br />
<br />
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.<br />
at ArteFACT.Rule.libpl.PL_new_term_refs(Int32 n)<br />
It seems that it can't find the static method at all.
Does anybody have an Idea what it could be? Because I could not really
find anything on the web and debugging didn't really help as well.
Thanks in advance,
Chris
|
|
|
|
|
I've created a windows service that as the time passes it start to consume a lot of memory. I'm using a managed zlib library for compression (one published here). I tried to force a garbage collection but it doesn't work. Question is: can I send a restart command to the service from within the service ?
Mauricio Ritter - Brazil
MSN: mauricioritter(atsign)hotmail.com
English is not my native language so, if you find any spelling erros in my posts, please let me know.
|
|
|
|
|
No you can't. A service doesn't "restart", but first "stops" then "starts". This will kill your service, but it won't start back up again because your code has been stopped.
A MUCH better method would be to find out why your code is leaking and fix it, instead of taking the "lazy" way out and ignoring it. 99% of the time, you're not releasing unmanaged resources, by calling .Dispose on your objects or because you forgot to call an unmanged function of your component that tells it to released its unmanaged resources. Either that, or you're using a buggy, unmanaged components.
The garbage collector will collect and free managed resources only. It can't do anything about unmanaged resources allocated by unmanaged components, even if those components are wrapped in managed code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Is there anyway that I can isolate my unmanaged call ? I tryed to use appdomains but it didn't work...
Mauricio Ritter - Brazil
MSN: mauricioritter(atsign)hotmail.com
English is not my native language so, if you find any spelling erros in my posts, please let me know.
|
|
|
|
|
That is still no solution for leaky code. There is just no excuse for leaving a leak in there like that. You have to go over the calls you're making to the unmanaged library and make ABSOLUTELY SURE, without a shadow of a doubt, that you're properly releasing those unmanaged resources. The documentation on the library your using will most likely help with that.
You said your using a library downloaded from CodeProject. Post a message in the aritcle's forum that you downloaded the library from. Maybe there's a known bug and a fix for your problem there. Check with the auther and ask where the underlying unmanaged code came from and if there any doc's on it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
About leaky code...
I suggest you get yourself a profiler. True lifesaver. There are bugs that are nearly impossible to find without one. Try the one from SciTech... memprofiler.com[^]. They also have a great tutorial on the website.
Alex Korchemniy
|
|
|
|
|
hi
i got some of the word events from mocrosoft.com using c#,but i want scrollbar events for word in c#,could u plse help me on this topic!!!!
lllisha
|
|
|
|
|
Hi there ,
Am wants to achieve OVERLAPPED I/O so am using these
ReadFile, n Accept fuctions n am getting problem can anyone help me about using these functions or
can anyone send me A simple Client Server Application using
ReadFile, Accept methods in C#.net
if someone interested than i will send ma code for correction
Regards.....
Babar
Babar
|
|
|
|
|
Here is the code for my problem.Copy paste it and then try to drag item from listView to TreeView.sometimes code works and soem times it does not works at all.Please help
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Drag_n_Drop_ListView_To_TreeView
{
///
/// Summary description for Form1.
///
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TreeView treeView1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.Label label1;
///
/// Required designer variable.
///
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
///
/// Clean up any resources being used.
///
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()
{
System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("Item1");
System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Item2");
System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Item3");
System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("Item4");
this.treeView1 = new System.Windows.Forms.TreeView();
this.listView1 = new System.Windows.Forms.ListView();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// treeView1
//
this.treeView1.AllowDrop = true;
this.treeView1.HideSelection = false;
this.treeView1.ImageIndex = -1;
this.treeView1.Location = new System.Drawing.Point(0, 0);
this.treeView1.Name = "treeView1";
this.treeView1.Nodes.AddRange(new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node0", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node3", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node4", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node5")})}),
new System.Windows.Forms.TreeNode("Node6")}),
new System.Windows.Forms.TreeNode("Node1", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node7", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node8", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node9", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node10")})})})}),
new System.Windows.Forms.TreeNode("Node2"),
new System.Windows.Forms.TreeNode("Node11", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node12", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node13", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node14", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node15")})}),
new System.Windows.Forms.TreeNode("Node16", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node17", new System.Windows.Forms.TreeNode[] {
new System.Windows.Forms.TreeNode("Node18")})})})})});
this.treeView1.SelectedImageIndex = -1;
this.treeView1.Size = new System.Drawing.Size(168, 304);
this.treeView1.TabIndex = 0;
//
// listView1
//
this.listView1.Items.AddRange(new System.Windows.Forms.ListViewItem[] {
listViewItem1,
listViewItem2,
listViewItem3,
listViewItem4});
this.listView1.Location = new System.Drawing.Point(168, 0);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(352, 304);
this.listView1.TabIndex = 1;
this.listView1.View = System.Windows.Forms.View.List;
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 312);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(208, 16);
this.label1.TabIndex = 2;
this.label1.Text = "Drag n Drop From ListView To TreeView";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(520, 333);
this.Controls.Add(this.label1);
this.Controls.Add(this.listView1);
this.Controls.Add(this.treeView1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
///
/// The main entry point for the application.
///
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Load(object sender, System.EventArgs e)
{
listView1.ItemDrag+=new ItemDragEventHandler(listView1_ItemDrag);
treeView1.DragEnter+=new DragEventHandler(treeView1_DragEnter);
treeView1.DragDrop+=new DragEventHandler(treeView1_DragDrop);
}
private void listView1_ItemDrag(object sender, ItemDragEventArgs e)
{
string strItem = e.Item.ToString();
// Start the Drag Operation
DoDragDrop(strItem, DragDropEffects.Copy | DragDropEffects.Move);
}
private void treeView1_DragEnter(object sender, DragEventArgs e)
{
// Handle the Drag effect when the listbox is entered
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
private void treeView1_DragDrop(object sender, DragEventArgs e)
{
// Get the Data from the DragEventArguement
string dummy = "hello";
string s = (string)e.Data.GetData(dummy.GetType());
// Parse out the type information
s = s.Substring(s.IndexOf(":") + 1).Trim();
System.Drawing.Point p = new Point(e.X,e.Y);
TreeNode selectedNode = treeView1.GetNodeAt(e.X,e.Y);
// Find the node at this position
TreeNode DropNode = this.treeView1.GetNodeAt(p);
// if the node exists, insert a new node with the dropped string
// into the second tree
if (DropNode != null)
{
TreeNode DragNode = new TreeNode(s);
MessageBox.Show(s);
treeView1.Nodes.Insert(DropNode.Index+1, DragNode);
}
}
}
}
|
|
|
|
|
can custom datasets be used in rdl while generating it programmatically ?
Prithiv Thirugnanasambsandam Vasudevan
|
|
|
|
|
|
My user profile is not Admin.
I wrote a code that sends ping,
it works when I logon with admin password,
but doesn't work when I logon with my user (that is not admin).
Thanks..
|
|
|
|
|
|
Thank you for your reply!
Ok. I got it. I need admin account.
Actually My problem is ;
I wrote a small server (listens tcp port),
when a client's cable unplugged, I want my server detect this,
and says this client is disconnected,
Do you know how can I do it?
thank you very much...
|
|
|
|
|
The server cannot detect this at all. As I put in your other post, PING'ing the client is not a reliable method considering the client might be behind a firewall or NAT that won't let ICMP traffic through it.
The only thing you can do is build in a "keep alive" where the client must send these "keep alive" requests to the server every so often. If the server stops receiving these requests from the client within a specified time period, it can assume that the client is no longer connected.
I don't know how much traffic or how many clients you're expecting, but this has scalability limitations. If you get enough clients connected, you could conceivably have 80%, or more, of the traffic going to the server just "keep alive"'s, resulting in very slow performance.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
That's Right. but my problem is that my clients may anyone. I mean. any client who knows my server IP and Port Number can connect to my server.
that is clients cannot send me message that they are online or something.. because they don't know the way I search them...
They can only send me string messages and my server display it on the received screen.. (of sure incoming messages are token as bytes no problem at this fact at all)..
As a result, server has to detect which clients are online or not! by a way ping or something..
By this way , I know that all the work done by server and server has much work to do.. But I have to...
Thank you very much for reply..
Greetings....
Alper.
Software Developer.
|
|
|
|
|
Your client may be anyone, anywhere on the planet?
Since you're trying to determine if the client disconnects unexpectedly, I'm assuming that you have to keep state information for the duration of the client session. Is this correct?
Are you writing a client piece to this also? If so, then you could include code that would send a "keep alive" request back to the server so the server knows it's still connected. After a certain timeout, if no "keep alive" request has been received by the server, you can assume the client either lost communication or terminated the client for some reason.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Unfortunately I'm writing only the Server Part,
and the clients are electronic cards that
has the client code in their EP-ROM and flash memory.
If their battery gets low or power-off my or their network cable unplugged, my server has to detect it.
Because the memory is very important for the EP-ROM based electronic cards client. Any Keep-Alive Send code couldnt be added into the clients.
Again Thank you very much...
|
|
|
|
|
You could have put that little tidbit into your original post!
Now, your options are extremely limited...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|