|
Thanks, I don't know how to use C# realize the graphic.I never use C# do the graphic(static or 3D) so,This is my question., I'm looking for a help.
|
|
|
|
|
led mike wrote: Kind of early in the year to be setting the bar so high for Reply of the Year Award isn't it?
It sets a standard for me to try and beat.
|
|
|
|
|
I don't think any of the standard components can do this. You could look at the available commercial charting/data visualization libraries. If none of them can provide anything useful, or you can't afford their sticker prices you'll have to write your own visualization control.
Otherwise [Microsoft is] toast in the long term no matter how much money they've got. They would be already if the Linux community didn't have it's head so firmly up it's own command line buffer that it looks like taking 15 years to find the desktop.
-- Matthew Faithfull
|
|
|
|
|
Hello All,
just few month ago started to program in C#. It's a great world there!
But I have quite some code written in C/C++, which I want to re-use in my C# development.
In C I have a function exported from a DLL. The function is declared as
EXPORT int my_foo(my_type **Devices, int *nrDevs);<br />
That library is compiled with calling convention Cdecl
I need to call that function in my C# code.
I do the following...
<br />
internal static class MyGreatFunctions<br />
{<br />
[DllImport("my_good_old_stuff.dll", CallingConvention = CallingConvention.Cdecl)]<br />
internal static extern int my_foo(ref IntPtr pDevs, ref int nDevs);<br />
}<br />
<br />
public class MyClass<br />
{<br />
public MyClass()<br />
{<br />
int nDevs = 0;<br />
IntPtr pDevs = IntPtr.Zero;<br />
int r = MyGreatFunctions.my_foo(ref pDevs, ref nDevs);<br />
}
When my_foo is called I got AccessViolationException "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
The other functions (with no double pointers) are called fine. What do I miss here? Why do I get this AccessViolationException? Please! Help!!
PS
It's WinXP Pro Sp2
.NET 2.0
|
|
|
|
|
Hi
have you tried the InAttribute and OutAttribute ?
i'm not sure if they're really required in order to work properly but it's worth a try...
<br />
[DllImport("my_good_old_stuff.dll", CallingConvention = CallingConvention.Cdecl)]<br />
internal static extern int my_foo([In,Out] ref IntPtr pDevs, ref int nDevs);<br />
to find out where the error does occur it might be an idea to do
cout outputs in your dll saying what' you're doing and call the dll then from a console app...
greets
m@u
|
|
|
|
|
thanx!!
In, Out didn't help (but I learned something new)
but cout'ing helped.
BTW, does anybody know how to debug managed/unmanaged code?
I just want to step-in (F11) into unmanaged code from managged... (call using PInvoke)
Regards,
Alex
|
|
|
|
|
I never really tried, but i could imagine, if you add your c++ project to the whole solution and set a breakpoint in your c++ method you might be able to do step-in..
without breakpoint it 's possible that it won't step-in because there's much code between without loaded symbol - information. As far as i know, visual studio can not do step in if there's code between calls that has no symbol informations...
|
|
|
|
|
|
Hi!
I know your IAXClient very well! It's awesome masterpiece!
I don't use it. I break it apart - it's my hobby kidding...
btw, libiaxclient interface has changed. I "hybridized" new iaxclient, with your code and existing DotNetWrapper stuff. just for fun, since I don't earn by C# codding...
Kind regards,
Alex
|
|
|
|
|
i have written window service in C#. After installation when i try to start the service. Following error occur:
"Error 1053: The service did not respond to the start or control request in timely fashion."
In my Onstart method, i am making only one thread and starting it.
And if i try to uninstall the service following exception thrown:
"Exception occurred while initializing the installation:
System.BadImageFormatException: Could not load file or assembly 'file:///C:\Docu
ments and Settings\Administrator\Desktop\GG\GG\GameGetter.exe' or one of its dep
endencies. The module was expected to contain an assembly manifest.."
Any idea how can i run that service?
|
|
|
|
|
Waqas Badar wrote: Any idea how can i run that service?
That file is a service? When you say you are running it, are you just doing a Process.Start() on it? If you are, you can't start a service like that. You have to register a service on the system, and let the service manager start it.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
can anyone explain me how to log keystrokes through windows service?
|
|
|
|
|
Can you convince us that this isn't going to be a "keylogger", something that is a severe security risk??
|
|
|
|
|
How do I convince you, that I'm not going to violate security?
only thing I can say, that if u believe then plz help me...
Actually I’m working on this from past few days, and getting a problem when trying to create a windows service.
Service.cs is not allowing to add namespace System.Windows.Forms, so that I can get the key codes, so if anyone help me regarding this it will be very helpful.
|
|
|
|
|
Somnath Sen wrote: Service.cs is not allowing to add namespace System.Windows.Forms, so that I can get the key codes, so if anyone help me regarding this it will be very helpful.
That is for a good reason. Services aren't supposed to have a UI, as they aren't supposed to have any user interaction. They are used for running backround operations without user interaction. Good luck convincing anyone you aren't writing a keylogger.
"If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer
I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")
|
|
|
|
|
Somnath Sen wrote: How do I convince you, that I'm not going to violate security?
You can't. It's as simple as that. We're not simply going to take your word for it.
|
|
|
|
|
Somnath Sen wrote: How do I convince you, that I'm not going to violate security?
You can't. It was a facetious question.
The System.Windows.Forms namespace will do you no good. It won't capture keystrokes system-wide. For that, you need to use the Win32 API and setup a certain callback. I refuse to say exactly what you have to do simply because there is no legitimate, nor legal, reason to write a "keylogger".
|
|
|
|
|
Consider the following code...
<br />
<br />
string text;<br />
foreach ( something )<br />
{<br />
if ( something )<br />
{<br />
text = "closing";<br />
someForm.FormClosing += delegate( object sender, FormClosingEventArgs e )<br />
{<br />
MessageBox.Show( text );<br />
};<br />
}<br />
<br />
if ( something_else )<br />
{<br />
text = "closed";<br />
someForm.FormClosed += delegate( object sender, FormClosedEventArgs e )<br />
{<br />
MessageBox.Show( text );<br />
};<br />
}<br />
}<br />
The foreach will have a something, and then a something_else, in this order. So, what will happen here, is that both events will trigger a MessageBox displaying "closed" text. To fix this, I passed the string text inside the foreach, and the issue isn't an issue anymore.
Now... can anyone explain me why does this happen? The delegate uses the reference instead of the value?
Gonçalo A.
|
|
|
|
|
Your question doesn't make any sense because you used terms that don't mean anything in the context that you used them in. You didn't fire an events, nor did you handle any. You didn't "pass in" a string called "text" inside the foreach .
On top of that, you didn't supply a complete code sample. In what method does this code show up?? What does the complete foreach look like?? Don't replace expressions with something and something_else . Your question is directly related to what those expressions really are.
|
|
|
|
|
Actually, no.. it has nothing to do with the something or something_else... that's why I didn't post it.
I'll try to simplify the code...
<br />
string text;<br />
<br />
if ( 1 )<br />
{<br />
<br />
text = "closing";<br />
someForm.FormClosing += delegate( object sender, FormClosingEventArgs e )<br />
{ MessageBox.Show( text ); };<br />
<br />
}<br />
<br />
if ( 1 )<br />
{<br />
<br />
text = "closed";<br />
someForm.FormClosed += delegate( object sender, FormClosedEventArgs e )<br />
{ MessageBox.Show( text ); };<br />
<br />
}<br />
Hope this clears out.
Gonçalo A.
|
|
|
|
|
Kensho wrote: Actually, no.. it has nothing to do with the something or something_else... that's why I didn't post it.
Kensho wrote: Hope this clears out.
No, it doesn't. What you described cannot happen with the "code" snippets you posted. Good luck...
|
|
|
|
|
Cannot... or won't?? You tried it?
Oh, there's just one detail on the code... replace the '1's with 'true'. Forgot that small detail in c#.
Just Create a form, and on the constructor, after the initializations, add these lines:
<br />
string text;<br />
<br />
if ( true )<br />
{<br />
text = "closed";<br />
FormClosed += delegate( object sender, FormClosedEventArgs e )<br />
{ MessageBox.Show( text ); };<br />
}<br />
<br />
if ( true )<br />
{<br />
text = "closing";<br />
FormClosing += delegate( object sender, FormClosingEventArgs e )<br />
{ MessageBox.Show( text ); };<br />
}<br />
And tell me if the output isn't "closing", "closing".
Gonçalo A.
|
|
|
|
|
Once again, the issue, as you described it, cannot occur with the code you posted. There is some tiny, yet important, little detail that's missing, (which you are ommiting because you think it's not important) that is probably causing this. If both if statements are using the same static value (NOT return values from two calls to the same function with the (supposedly) same data), then what you describe is not possible.
|
|
|
|
|
Cannot, or it doesn't happen? Or... if it could not happen, then why, instead of just... cannot happen.
Try it. Just as I described on my previous post. Create a new project, with a form, and type that out...
Even I did this, to prove myself I wasn't fooling anyone; so I am not freaking ommiting anything... sheesh...
This happens because when you add code like that, in runtime, the compiler will hold to the references and not to the values; the result is that both will grab the last value of the reference. That's why it won't happen if you switch the text variable to inside the if, or if you added static text like MessageBox( "closed" );.
Advice... do try it first, before saying it CANNOT happen. I won't hold a grudge on you if you try, I promise...
Cheers
Gonçalo A.
|
|
|
|
|
I ignored your last code post because it's not the same as your original post.
if (true)
...
if (true)
...
is NOT the same as:
if (something)
...
if (something_else)
...
Your last code post is identical in output to:
string text;
if (true)
{
text = "closed";
FormClosed += delegate( object sender, FormClosedEventArgs e )
{ MessageBox.Show( text ); };
text = "closing";
FormClosing += delegate( object sender, FormClosingEventArgs e )
{ MessageBox.Show( text ); };
}
The problem was never in the compiler, but in your logic.
|
|
|
|