|
Is it not possible to write an own class which takes over the logging mechanism?
|
|
|
|
|
You could, but there is nothing that will call the log mechanism. You'll have to add code to every method you have already written to cal the logging class with the name of the method and the parameters that were passed. There is no built in mechanism to do this...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The following code compiles fine but when attempting to run it from debug mode, the compiler breaks on "Send(args[0]);" And generates the following exception:
An unhandled exception of 'System.IndexOutOfRangeException' occurred in UDPSender01.exe
Additional information: Index was outside the bounds of the array.
This project was setup as a simple c# console.
using System;
using System.Net;
using System.Net.Sockets;
using System.Text;
public class UDPMulticastSender
{
private static readonly IPAddress GroupAddress =
IPAddress.Parse("224.168.100.2");
private static int GroupPort = 11000;
private static void Send( String message)
{
UdpClient sender = new UdpClient();
IPEndPoint groupEP = new IPEndPoint(GroupAddress,GroupPort);
try
{
Console.WriteLine("Sending datagram : {0}", message);
byte[] bytes = Encoding.ASCII.GetBytes(message);
sender.Send(bytes, bytes.Length, groupEP);
sender.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
public static int Main(String[] args)
{
Send(args[0]);
return 0;
}
}
Thanks,
Moe
|
|
|
|
|
win32wiz wrote:
Send(args[0]);
That line will cause an IndexOutOfRangeException to be thrown if no arguments have been passed. You can specify command line arguments to be passed to the application when running in debug mode in Visual Studio by going to Project -> {Project Name} Properties... -> Configuration Properties -> Debugging and entering them on the line labeled Command Line Arguments (under Start Options).
Charlie
if(!curlies){ return; }
|
|
|
|
|
I have just started with Direct3D in C#. It's great so far, but I have a problem when I want to "fade" my scenes out... I remember I was able to use the D3DDevice::Clear function in C++, and I could interpolate the alpha channel. This does not seem to work in C#. Anyone have an idea? Is there another way which is more efficient?
Thanks.
J.
|
|
|
|
|
Hi,
I would like to know how to instantiate a class from which I do not know the type.
I have a class that contains a property in which I want to store an object of a type which is derived from Base_Class. I do not know which of the derived types my object will be.
I also want to be able to instantiate this object of unknown type at runtime.
How could I achieve this ?
-----------------------------------
Alexandre Rondeau
alexandrer@contekonline.com
|
|
|
|
|
|
I developed a C# apps to retrieve pop3 email, the result I got is something like below:
Return-Path: <user@main.com><br />
Delivered-To: user@main.com<br />
Received: (qmail 55301 invoked by uid 89); 3 Nov 2004 00:07:53 +0800<br />
Message-ID: <20041102160753.55300.user@main.com><br />
From: "Victor Tai" <user@main.com><br />
To: user@main.com<br />
Subject: Email Extream Test 11<br />
Date: Wed, 03 Nov 2004 00:07:53 +0800<br />
Mime-Version: 1.0<br />
Content-Type: text/plain; format=flowed; charset="utf-8"<br />
Content-Transfer-Encoding: 7bit
How do I separate them into line so that I can get the variable like From, To, Subject? I try to identify by "\n", but it gave me wrong result...
Thanks.
|
|
|
|
|
You should use regular expressions, which are stored in System.Text.RegularExpressions namespace.
For example
<br />
string header = (Your header),match="";<br />
Regex r = new Regex("Subject:.*");<br />
Match m=r.Match(header);<br />
if(m.Success){<br />
match = m.Value;<br />
} <br />
Now match contains the line beginning with "Subject:".
|
|
|
|
|
Does any one know if there is a way to default the ListView Checkbox Control to checked?
|
|
|
|
|
Duh, I figured it out
|
|
|
|
|
Hi there!
I create a panel and finally I can put him in a Form \o/ (thanks Stefan Troschütz )
But now I have a problem, I want to control the location of the panel in the main application. In order that I create two variables
public int locationX, locationY;
public int LocationX
{
get
{
return locationX;
}
set
{
locationX = value;
}
}
public int LocationY
{
get
{
return locationY;
}
set
{
locationY = value;
}
}
The problem is when I make the following instructions =/
panelClass panelCenas = new panelClass();
panelCenas.LocationX = 10;
panelCenas.LocationY = 50;
this.Controls.Add(panelCenas);
The program doesn´t execute the two instructions in the middle, I think that is because when I create a panel, it executes the initialize component and there isn´t any mention there to the Location of the panel
public panelClass()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.BackColor = System.Drawing.SystemColors.ControlDark;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Size = new System.Drawing.Size(50, 50);
this.TabIndex = 0;
}
How can I control the Location of it!?!
Thanks very much, Sérgio
|
|
|
|
|
Why can't you just do
panelClass panelCenas = new panelClass();<br />
<br />
panelCenas.Location = new Point(50,05);
Why do you need the extra variables?
Michael
CP Blog [^]
|
|
|
|
|
thanks you, Michael....
newbie thing
|
|
|
|
|
This is other stupid doubt
What I want to do is sometinhg like that
panelClass panelCenas = new panelClass(Location, Size, backgruondColor, etc...);
In order to do that, what I have to do in the panelClass?!
I have to erase that?!
public panelClass()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.AllowDrop = true;
//this.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
this.AutoScroll = true;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
}
Thanks you
|
|
|
|
|
Hi there!
I´m trying to make a class that inherits from a Panel and have several functions.
public class panelClass : System.Windows.Forms.Panel
{
public panelClass()
{
InitializeComponent();
}
private void InitializeComponent()
{
this.BackColor = System.Drawing.SystemColors.ControlDark;
this.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.Location = new System.Drawing.Point(64, 72);
this.Size = new System.Drawing.Size(160, 64);
this.TabIndex = 0;
}
}
In the main program I put this instructions
panelClass panelCenas = new panelClass();
panelCenas.Show();
But when I execute the program the panel that I had created don´t appear =/
What is my mistake here?!! I can´t construct a class panel?!!
Thank you very muck, Sérgio
|
|
|
|
|
Add your panel to the ControlCollection of your form or whatever control should be parent of the panel:
panelClass panelCenas = new panelClass();
this.Controls.Add(panelCenas);
www.troschuetz.de
|
|
|
|
|
The panel doesn't appear by itself, it must be child of a form.
Try doing this in your form constructor:
PanelClass myPanel = new PanelClass();
myPanel.Parent = this; Hope that helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
I am using those codes:
[ReadOnly(true)]
public string List
{
get { return m_strList; }
set { m_strList = value; }
}
I wanted to prevent the user to change the List but it changed the color black to light gray bec of readonly changed its color text. I tried to changed its text color(like ViewForeColor). No luck. what are your suggestions that how to change its text color?
|
|
|
|
|
I create a table has a money data type but when i try to insert into it from a form it give me a error convertion
varchar to money type
i use c#
i need help thanks
|
|
|
|
|
In C# the data type is decimal . You use Convert.ToDecimal to parse a string.
string str = reader.GetString(reader.GetOrdinal("Amount"));
decimal amount = Convert.ToDecimal(str); There's also a DataReader.GetDecimal() method, but the above code is to illustrate the point.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
hi,
I have a label in my application. What we can do in current senario is , we can use background color to define background color of my label. What i want is, i can able to define some portion of label to paint in one color and some portion in different color and etc. To be consize, i can able to define any number of color combination in my label. Is there any way to do this.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
i think you have to write your own label control with custom paint method.
there are no facts, only interpretations
|
|
|
|
|
Hi
I developed C# component , when I call that component in my VC.6 Code the CoCreateInstance is failing
hr = CoCreateInstance (theCLSID, NULL, CLSCTX_LOCAL_SERVER, IID_IUnknown, (void**)&pIUnk )
In the above case the CoCreateInstance is failing with the error value of -2147221164 ( Class not registered).
If I modified the code as
hr = CoCreateInstance (theCLSID, NULL, CLSCTX_ALL, IID_IUnknown, (void**)&pIUnk ) ;
everything works fine.Can any one tell why HRESILT is failing in the first case?
Thanks in Advance
kishnasarma
|
|
|
|
|
i'm not an expert on com, but did u try to register your component?
there are no facts, only interpretations
|
|
|
|