|
Wow, never seen that one before You learn something new everyday, thanks
|
|
|
|
|
leppie wrote: Wow, never seen that one before
do you really mean it ?
|
|
|
|
|
N a v a n e e t h wrote: do you really mean it ?
Yes, no joke. I have never needed that
|
|
|
|
|
Ohh then I am delighted that I could able to help you. Thanks.
|
|
|
|
|
|
<pre> I am trying to access a C DLL from C# .The problem i am facing when i pass a structure to the C dll function .I am passing the structure by out Keyword.here is the code
--------------------------------------------------OneStruct .dll----------------------------------------------------------------
#include<iostream.h>
#include<conio.h>
#include<malloc.h>
#include<string.h>
extern "C"
{
typedef struct
{
unsigned long * var1;
float * var2;
}Esp;
typedef struct
{
char * var3;
char * var4;
}Real;
__declspec(dllexport) void GetValue(Esp * villa,Real * rud) //when function gets called i added the watch on villa and it shows me that CXX0017:Error:Symbol 'villa' not found
{
rud->var3 = (char*)malloc(50);
memset(rud->var3, 0x00, 50);
rud->var4= (char*)malloc(50);
memset(rud->var4, 0x00, 50);
strcpy(rud->var3, "robhino");
strcpy(rud->var4,"zidane");
unsigned long a=9999;
villa->var1=&a;
float b=15.6f;
villa->var2=&b;
}
}
--------------------------------------------------------------------------------------------------------------------------------
----------------------------------HandleOneStruct----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
namespace HandleOneStruct
{
[StructLayout(LayoutKind.Sequential)]
public struct Esp
{
public IntPtr var1;
public IntPtr var2;
}
[StructLayout(LayoutKind.Sequential)]
public struct Real
{
public string var3;
public string var4;
}
class LibWrap
{
[DllImport("OneStruct.dll")]
public static extern void GetValue(out Esp villa,out Real rud);
}
class Program
{
static void Main(string[] args)
{
Esp villa;
Real rud;
//villa.var1=Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof (Esp)));
//villa.var2 =Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(Esp)));
//villa.var1 = new IntPtr(11);
//villa.var2 = new IntPtr(19);
LibWrap.GetValue(out villa,out rud);
Console.WriteLine(rud.var3);
Console.WriteLine(rud.var4);
Console.Read();
}
}
}
---------------------------------------------------------------------------------
When i debugg this code i am getting value of rud structre variable as robhino zidane correctly but the value of villa structre varibale are 12345,12346(some address i guess).where as i want the value villa->var1=9999 and villa->var2=15.6f.i really don't know how to get the values of var1=9999 and var2=15.6f .can anyone guide me how to get the desired result.what i need to do to run this code successfully .Is there any other way to run this code please tell me.
Give me usefull link for this topic if possible ?One more thing if i want to intialize IntPtr varible with long value or long * then how can i do this?
Any help Appreciated.
Thanks in Advance.
</pre>
|
|
|
|
|
You need to Marshal the IntPtr to int or float.
|
|
|
|
|
Hello everyone,
When I use bu or bm to set a breakpoint into a process running C#, there is always error message like -- "Operation not supported by integrated managed debugging."
How to make WinDbg support .Net application debug?
(I made a search to find some similar questions, but not quite helpful.)
thanks in advance,
George
|
|
|
|
|
Acording to Wikipedia, there's an extension for debuggin CLR apps.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Can you provide a link please? Or keywords to search?
regards,
George
|
|
|
|
|
|
Thanks Simon!
I have using .load to load the SOS package. And I have tried I can use extension commands like
!threads.
But when I use bu or bm to set a breakpoint, for example, bu Foo (Foo is a function in class FooUtility), there is error message like -- "Operation not supported by integrated managed debugging.
". How to solve it?
regards,
George
|
|
|
|
|
Sorry, I've no idea what the problem is. I'm no WinDbg expert.
I'd recommend getting a good guide, like the John Robbins book and starting with a simple app.
Simon
|
|
|
|
|
Thanks all the same, Simon!
Do you have any suggestions for a more specific forum?
regards,
George
|
|
|
|
|
|
Thanks all the same, Simon!
regards,
George
|
|
|
|
|
Hello,
I have a DataGridView with a DataGridViewCheckBoxColumn. I want to be
able to have the checkbox display in an indeterminate state, so I've
set the ThreeState property to True. However, I want the indeterminate
state to only be set programatically - whenever the user clicks the
checkbox, it should only toggle between Checked and Unchecked.
Now, this is the default behaviour of a standard CheckBox control - as
detailed in the CheckBox.ThreeState property documentation:
"the CheckState property value can only be set to the Indeterminate
value of System.Windows.Forms.CheckState in code and not by user
interaction"
How would I achieve this with DataGridView? I'm committing the changes
to the checkbox cells immediately by catching the
CurrentCellDirtyStateChanged event and calling CommitEdit as suggested
in the documentation for DataGridView. However, if I try catching the
indeterminate state in this event or in CellValueChanged, and setting
Value to CheckState.Unchecked, the cell's Value property changes but
the display does not update until the control loses focus or another
row is selected.
As this is the default for the CheckBox control, I'm sure it can't be
that difficult to get the DataGridView to do it. What am I missing?
Thanks in advance for your help,
Steven
|
|
|
|
|
Hi
I have a desktop application with a back-end as web service. Web service is hosted on server with Windows Authentication option.
All users do settings in provided setting form using desktop application and hit test connection and it succeeds for all except one user. When this unique user click test button he gets 401: access denied message. if he copy that web service URL in web browser and enters same credentials as in setting forms it works. So only the application fails to connect with web service.
Any help would be highly appreciated to resolve this issue.
Best Regards
Rizwan Bashir
|
|
|
|
|
Check the text encoding.
BTW why not hook up the debugger and see what happens?
|
|
|
|
|
Hi
Thanks for reply. its our client and we cannot force/request him to install .Net on his machine for us. So what ever we can do we have to use our development machine and then deploy on his machine.
if Text Encoding would have any problem then it must be with all users.
Best Regards
Rizwan Bashir
|
|
|
|
|
Rizwan Bashir wrote: if Text Encoding would have any problem then it must be with all users.
That's a bad assumption! Your use could fail because it has a 'ê' in its name and the server translates it incorrectly.
|
|
|
|
|
Hi
Thanks for reply and sorry I never thought of special character in username and password, I have mailed client about this and as soon as he will reply I shall definately update you.
Thanks again for a wonderful clue.
Best Regards
Rizwan Bashir
|
|
|
|
|
hi
it is not the problem, user has confirmed that his username is alphaNumeric like usr7980 and password is totally numeric. So encoding is no more applicable. Any other idea's
Best Regards
Rizwan Bashir
|
|
|
|
|
Rizwan Bashir wrote: Any other idea's
Not off the top of my head, sorry
|
|
|
|
|
Hi,
I have a question about static.
I have the following class:
public class Members
{
static public string Administrator = "A";
}
Because I would mark the variable Administrator as a Const, I changed the class to the following:
static public class Members
{
public const string Administrator = "A";
}
In my eyes, the behavior is the same in accessing the variable, only that you are not able to change the Variable.
Is this correct? Or do I need to use the keyword readonly instead of const?
Than I would have:
public class Members
{
static public readonly string Administrator = "A";
}
So, help me out by saying what is the best practice here.
Thanks.
|
|
|
|