|
Hallo - i hope somebody can help me....
i want to call a c-function with this code:
struct StrBox
{
char str[30];
};
struct StructBox
{
StrBox * box;
};
DLLIMPORT char * TestStrBox(StructBox *sb);
i used this c#-code to call it:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
struct StrBox
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 30)]
public string str;
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
struct StructBox
{
[MarshalAs(UnmanagedType.LPStruct)]
public StrBox box;
};
...
StructBox b = new StructBox();
b.box.str = "Hallo Welt!!!";
string str = TestStrBox(b);
but if execute it, i get:
Ausnahme System.TypeLoadException wurde im ausgeführten Programm ausgelöst:
Cannot marshal field 'box' of type 'marshal.StructBox': Invalid managed/unmanaged type combination (this value type must be paired with Struct).
So i think it have a problem, with the struct in the struct... but the struct HAVE to be in the struct
(this is just a test, who reflects a real issue).
Hope... somebody have an idea.
Sooo. Many thx in advance
|
|
|
|
|
Hi,
your C# code has a struct in a struct, your C++ code has a struct pointer in a struct.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Aahhh... ok!!
But how can i declare it in c#, that it is handled like a Pointer to a struct (is IntPtr the right way?)
|
|
|
|
|
Hi,
if the only thing you want to happen is passing a pointer, then IntPtr is the right type.
but that will not marshal the object pointed to, since IntPtr does not carry type information for you. You will have to explicitly marshal using Marshal.PtrToStructure() somehow.
I always try and avoid those complex marshal jobs. When both sides are mine, passing data is
implemented for minimal complexity, that's the only way I know to avoid everything getting copied
across the managed/unmanaged border.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:55 AM
|
|
|
|
|
Hello folks.
I have a quick question, so here it is: can I restart a form back to it's original state as if it was newly opened without referencing a parent form or closing it? If so, how?
Thanks dudes and dudettes!
|
|
|
|
|
Never tried it, but perhaps if you:
- set this.components = null
- remove all controls from this.Controls
- call InitializeComponent
|
|
|
|
|
Holy crockpot!
It works:
components = null;
Controls.Clear();
InitializeComponent();
Are you some kind of suprogrammer?
Thanks, Mika!
|
|
|
|
|
Lodeclaw wrote: Are you some kind of suprogrammer
Now I have to ask a stupid question: What's a subprogrammer?
Lodeclaw wrote: Thanks, Mika
You're welcome
|
|
|
|
|
Not subprogrammer. Don't make me explain my terrible pun.
|
|
|
|
|
Ah, I misread it
|
|
|
|
|
I am working on a project to design database system of a library using oracle as backhand and c# as forehand but i don't know commands to connect
c# form with oracle database.
kindly send me command lines.
|
|
|
|
|
Read this[^]
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
LMAO, how did you ever find the same link as me, it took me so long to actual get a google result for what the OP wanted - I guess thats why they always turn to CP lol
|
|
|
|
|
musefan wrote: I guess thats why they always turn to CP lol
Well, The good thing is that he wasn't asking for the source codez and it wasn't urgent. So I just asked him to read that article. Did I do something wrong?
Be careful, there is no Undo Button(Ctrl+Z) in life.
|
|
|
|
|
No, I was just making a comment on how easy it is to find a search result that fits thier needs, yet they never seem to try for themselves
|
|
|
|
|
|
It depends on the technology you are using to connect. Are you using ODP.NET or ODBC for instance? If ODP, you'd create instances of OracleConnection and OracleCommand objects. Your connection string would be based on the entry in TNSNAMES.ORA that you are aiming to connect to. So, suppose the SID was MYORA, then your connection string might look like this "Data Source=MyOra; User ID=NamedUser; Password=Password;"
|
|
|
|
|
Hi all,
I am looking for MCTS[70-536,70-526,70-528] papers....where should i get this content
pages...if you people have anything this info please post a link or you may post info to my mail and one more actually am a c# developer so is there any chances to get vb.net questions above mentioned papers please let me know this info very urgent ...........
thank you in advance.....
|
|
|
|
|
|
Find somebody who has them, bop him on the head, take the papers.
|
|
|
|
|
(entered using FF3)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Friday, June 10, 2011 11:55 AM
|
|
|
|
|
Yeah, yours worked and mine does some times.
|
|
|
|
|
Hello guys.
I have a file with SDF extension ( database ).
I'm gonna see content of it ! I couldn't see it with VS2008 SP1 or SQL Express 2008 SP1.
How can I see it ?
Thanks in advance.
|
|
|
|
|
Have you tried using the System.Data.SQLClient classes and specifying the .SDF file as the data source
Other than that dont know what to suggest
|
|
|
|
|
Hi musefan.
musefan wrote: Have you tried using the System.Data.SQLClient classes and specifying the .SDF file as the data source
Actually I've known it and I've used it for using the database in my project.
But I'm gonna trace my program and see the content of the database after each query, so I need a program like MSSQL to see content of the database .
As I said I've used SQL Express and VS2008 , but they didn't show anything.
Thanks anyway
|
|
|
|