|
Thanks for the reply, I will look into reflection...
|
|
|
|
|
Is it possible given two strings (class name and method name) to dynamically create an instance of the class and get a delegate pointing to the method?
For example (almostcode):
<br />
public delegate void ActionHandler(Message m);<br />
<br />
string className = <br />
"Exony.Runtime.StateServices.Test.States.Stopped";<br />
<br />
string actionName = "OnStart";<br />
<br />
Type t = Type.GetType(className);<br />
<br />
object instance = t.Assembly.CreateInstance(t.FullName);<br />
<br />
ActionHandler handler = ?CREATE_DELEGATE?(instance, actionName);<br />
<br />
fsm.Handlers += handler;<br />
<br />
Thanks in advance,
James.
|
|
|
|
|
Doh.... If you look hard enough there is nearly always something in the FCL to do the job...
ActionHandler handler = <br />
Delegate.CreateDelegate(typeof(ActionHandler), instance, actionName)
Thanks anyway...
James.
|
|
|
|
|
hi there
i have a problem using a text box
i have a text multiline box (accepts return = true) and TextBox1.Text=varText.
varText is a text with many lines (in fact is an XML source indented)
if i show the text with MessageBox.Show(TextBox1.Text) it looks fine but in the edit box instead of 'new line' i have '|'
what can i do?
any idea?
thanks in advance for your help
|
|
|
|
|
i had the same problem but i solved it like this:
msgbox.text = "texttext\r\n";
and it worked for mem so i suggest u should try that!
// trones
|
|
|
|
|
thank you for your answer, trones
i solve the problem this way:
char cr=(char)13;
char lf=(char)10;
string strCR,strLF,strCRLF;
strCR=cr.ToString();
strLF=lf.ToString();
strCRLF=strCR+strLF;
art=art.Replace(strLF,strCRLF);
textBox1.Text=art;
|
|
|
|
|
How can I find out if the computer is connected with a TCP-Network?
I don't want to find out if TCP is installed successfull, but I want to find out if there is a working TCP conntection to a network without using any IP adresses (that means on every computer without knowing anything about the existing network), etc.
There must be a solution, but I can not see the right method (
Can you help me?
|
|
|
|
|
Hi!
It's me again! I guess you need the IP-Adress of the Computer to find out if the connection is working
|
|
|
|
|
I wanna provide a MC++ lib for C# user. One function is: bool ReadString(string str)
I must write it in MC++ for some former code ReadBuffer.
I write it like something below, but failed in get the StringBuilder or String's char buffer. The marshal must be something wrong, can't pass the compiler.
bool ReadString(String * &str)
{
void * pBuffer;
int num;
ReadBuffer(&pBuffer, num);
StringBuilder* sb = new StringBuilder(64*1024);
MultiByteToWideChar(0,0,pBuffer, num, [MarshalAs(UnmanagedType.LPWStr)]sb, 64*1024);
str = sb->ToString();
}
Can anything lend me a hand?
|
|
|
|
|
I think this would be better asked in the MC++ forum.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
novachen wrote:
I wanna provide a MC++ lib for C# user. One function is: bool ReadString(string str)
Do you mind if I ask why you are writing a library in MC++ to read a string. This can easily be done in C#, especially if other parts of the project will be written in C#. Could you provide further info?
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Nick Parker wrote:
Do you mind if I ask why you are writing a library in MC++ to read a string.
In fact, the function is provided for a gzip lib. My ReadString's function is extract the text from the gz file. And because the dotnet use the Unicode char, i have to transform single byte into unicode (double bytes form). So the win32 api is used. When use the API, the address of buffer must provided, so i need some marshal on the String or StringBuilder.
Did i say it clearly now ?
|
|
|
|
|
novachen wrote:
Did i say it clearly now
yep - I knew I had an article bookmarked for something like this. Check out Mixing Managed and Unmanaged code[^]. Hope this helps.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
i had host a email web service on a win2000 server. one of the parameter of the web service method call is "string filename". this "filename" will passed into
System.Web.Mail.MailAttachment class constructor to send email.
now, i have another standalone application which run on win98 computer. my standalone application want to send a image file which located in win98 computer.
can i just call the web service ws.SendMail("yccheok@yahoo.com", "c:\live.jpg"); without first explicit transfer the image file to win2000 server?
thank you.
regards
yccheok
|
|
|
|
|
No, you can't do that. What you can do however is use the new Web Services Development Kit and read this article on DIME[^] to do what you want.
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
previously, i had an application that use a COM object to grap image from web cam. i try to enhance my application by using the Windows Media Encoder 9 Series SDK to do live video streaming.
i realize that whenever i stop my image capturing thread and run WM live video streaming thread, my application has no problem at all the access the web cam device. however, whenever i try to stop WM live video streaming thread, the COM object unable the use the web cam device. it seems that the camera device still hold by the WM thread. the WM thread goes like this......
-----------------------------------------------------------------------
public void StartWM()
{
if(WMThread != null)
{
if(WMThread.IsAlive)
{
StopWM();
}
}
if(cameraThread != null)
{
if(cameraThread.IsAlive)
{
StopCamera();
}
}
WMThread = new Thread(new ThreadStart(_StartWM));
WMThread.Priority = ThreadPriority.Lowest;
WMThread.Start();
}
public void StopCamera()
{
if(cameraThread != null)
{
cameraThread.Abort();
while(cameraThread.IsAlive);
cameraThread = null;
}
}
public void StopWM()
{
if(WMThread != null)
{
WMThread.Abort();
while(WMThread.IsAlive);
WMThread = null;
}
if(Encoder != null)
{
Encoder.Stop();
//HOW TO MAKE SURE ENCODER
//IS COMPLETELY RELEASE ITS //WEB CAM DEVIDE HANDLE
//BEFORE IT PROCEEDS TO
//NEXT //STATEMET???????
//while(Encoder.IsAlive); <-
//- of course this
//wont work
Encoder = null;
}
}
private void _StartWM()
{
try
{
// Create WMEncoderApp and WMEncoder objects.
if(Encoder == null)
{
Encoder = new WMEncoder();
}
//encoder initialize
//code goes here for live
//video
//broadcasting
//Start the encoding
//process.
Encoder.PrepareToEncode(true);
Encoder.SynchronizeOperation = false;
Encoder.Start();
}
catch(Exception ex){}
}
-----------------------------------------------------------------------
whenever i wish to start the camera thread, i must first make sure the wm thread first release its handle to web cam. hence, i used to call StartCamera.
public void StartCamera()
{
if(WMThread != null)
{
if(WMThread.IsAlive)
{
StopWM();
}
}
if(cameraThread != null)
{
if(cameraThread.IsAlive)
{
StopCamera();
}
}
cameraThread = new Thread(new ThreadStart(_StartCamera));
cameraThread.Priority = ThreadPriority.Lowest;
cameraThread.Start();
}
-----------------------------------------------------------------------
inside _StartCamera, i will construct a camera COM object and capture image using that COM object. however, the COM object unable the use the web cam device whenever it wants to grap image
i suspect that the web cam is still hold by encoder. how can i make sure web cam is released by encoder after i call Encoder.Stop()?
thank you.
regards
yccheok
|
|
|
|
|
i had build a light weighted http server and recently realize that there is some bugs inside.
in my constructor, i initialize the TcpListener and the thread for receiving incoming request as follow:
----------------------------------
myListener = new TcpListener(port);
myListener.Start();
//start the thread which calls the method 'StartListen'
myThread = new Thread(new ThreadStart(StartListen));
myThread.Start() ;
----------------------------------
in my StartListen
----------------------------------
while(isRunnable)
{
//Accept a new connection
Socket mySocket = myListener.AcceptSocket() ;
if(mySocket.Connected)
{
//make a byte array and receive data from the client
Byte[] bReceive = new Byte[1024] ;
int i = mySocket.Receive(bReceive,bReceive.Length,0); //BUGS??
// rest of the code goes here
----------------------------------
sometimes, when i use a web broswer making an HTTP/GET request, my web broswer takes 5 minutes to download the contents from the computer that run light weighted server(LWS) and still get no responde. it seems that it can establish a TCP/IP connection to the LWS but get no response from the LWS.
finally, i realize that LWS will halt at the line.
-----------------------------------
int i = mySocket.Receive(bReceive,bReceive.Length,0); //BUGS??
-----------------------------------
this happen "sometimes". where "sometimes" LWS works fine and "sometimes" LWS dont :P
can anyone point me out how can i solve this problem? thank you in advance.
regards
yccheok
|
|
|
|
|
hi, all
How to invoke DLL in C#?
thanks very much
|
|
|
|
|
This column should help:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp09192002.asp
|
|
|
|
|
I'm having a problem double buffering my form. I use
<br />
SetStyle(ControlStyles.UserPaint, true); <br />
SetStyle(ControlStyles.AllPaintingInWmPaint, true);<br />
SetStyle(ControlStyles.DoubleBuffer, true);<br />
and the last line gives me a System.ArgumentException. The additional info is Invalid argument used... I checked out the MSDN and it says to use them like this. They are inside the Form() constructor. Anybody have any clue why this is happening?
|
|
|
|
|
public Form1()
{<font color="green">
<code>InitializeComponent();</code>
<font color="green">
<code>SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);</code>
}
This code itself does not cause a compile time error, as I placed the code inside a blank application itself and it compiles fine, you may have other issues inside your constructor.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
I figured it out I was looping the call to the OnPaint() and inside I used a graphics object. I mistakenly Dispose()'ed of the PaintEvenArg instead of the graphics object.. I guess it doesn't like that because I took the call to Dispose() out and it works fine now
|
|
|
|
|
You have to do it like this:
SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
Each successive call to SetStyle eleminates the previous setting and changes it to the new one. So, essentially, your just calling SetStyle(ControlStyles.DoubleBuffer). Because double buffering has to be used in conjunction with UserPaint and AllPaintingInWmPaint, you get the error Invalid Argument Used. Using a bitwise or, you combine the values of all three into one setting.
Hope this helps.
|
|
|
|
|
Hi!
I'm looking for some samples how to write an IRC client in C#.
Have someone any samples?
thx!
|
|
|
|
|