Search

Categories

On this page

Statistics

Total Posts: 9
This Year: 0
This Month: 0
This Week: 0
Comments: 42

Feeds

RSS 2.0 | Atom 1.0 | CDF

Contact

Send mail to the author(s) E-mail

 

Sign In

# Thursday, 30 October 2008
Thursday, 30 October 2008 17:48:29 (W. Europe Standard Time, UTC+01:00) ( Q & A )

If you have any general question about a topic and you can't find any article I wrote about it, please post it here and I'll try to answer it for you (no guarantees ;-)).

But please, if there is an article of the topic you're question is about, post it there.

 

Comments [3] | | # 
Related posts:
Thursday, 30 October 2008 17:51:49 (W. Europe Standard Time, UTC+01:00)
[[COPIED from About Me]]

Hi Martijn Thie,

i am right now programming a C# dll for a vb app. I got a problem to use a struct defined in C# dll by the vb app. Here is my code:

The error information is type mismach when i compile the VB APP. Any idea , where come from this error. Thanks very much.

// C# DLL code
namespace CallerSpace
{

public interface Icall
{
void getSentence(myDATA d);
}

[StructLayout(LayoutKind.Sequential)]
public struct myDATA
{
public int time;
public int Status;
}

public class CALL: Icall
{

public void getSentence(myDATA d)
{
......
}

}

}

// VB Application code
Sub Main
Dim call As CallerSpace.Icall
Set call = New CallerSpace.CALL

Dim mdata As myDATA
mdata.Status = 1
mdata.time = 122

call.getSentence(mdata) // here: error > type mismatch

End Sub

bag
Thursday, 30 October 2008 18:04:23 (W. Europe Standard Time, UTC+01:00)
Hi Bag,

I'm not quite sure, but it might be the:
"Dim mdata As myDATA"

Maybe you want to declare it like this:
"Dim mdata As CallerSpace.myDATA"

I'm sorry that I can't be sure right now. As I'm attending the PDC 2008 in Los Angeles, United States right now, time is not on my hand. As there are many great new topics here and many great sessions I have to fly... :)

So, please try it. If it doesn't work, I'll try to help you later on...

Friday, 31 October 2008 11:24:15 (W. Europe Standard Time, UTC+01:00)
Hi Mrtijn Thie,

sorry i posted the question under "about me". And thanks for your time and your reply.

I have solved the problem last night. I pass the struct a reference. Then It works.
But I do not know why I can not pass the struct. Maybe my question is: how to pass values from C# dll to VB app, or vise versus.

PS:U are at the PDC 2008 right now? That cool.

Have a nice trip in the USA!


// C# DLL code
namespace CallerSpace
{

public interface Icall
{
void getSentence(ref myDATA d); // here I pass the struct as a reference
}

[StructLayout(LayoutKind.Sequential)]
public struct myDATA
{
public int time;
public int Status;
}

public class CALL: Icall
{

public void getSentence(ref myDATA d) // add "ref" here
{
......
}

}

}
bag
Name
E-mail
Home page

Comment (Some html is allowed: i, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview