DllImport and visual component problem

J

John Dinning

I have created a simple visual component based on a Label, with no
properties or methods added so far (using VS2005, New Control Library
project for smart device Windows CE 5).

It builds ok, I can add it to the toolbox and use it no problem in my test
project..
However, it will also required to call an existing DLL.

When I just add the two lines:
[DllImport("MyTest.dll")]
private static extern int TestFunc();

It builds ok, but the component is somehow corrupted.
The text on the label in the designer in the test project displays
"KBDStatusLabelLib.KBDStatusLabel" not "KBDStatusLabel1" as expected.
Also, if I add a property the designer displays the the Error "The type
'Microsoft.CompactFramework.Design.UnsafeControl' has no property
named 'MyProperty'"


The code for the label component is here:

namespace KBDStatusLabelLib
{
public partial class KBDStatusLabel : Label
{
public KBDStatusLabel()
{
InitializeComponent();
}
[DllImport("MyTest.dll")]
private static extern int TestFunc();
}
}

Can anyone help please?

John.
 
G

Guest

John,
Marking your control with the DesktopCompatible(true) attribute will
eliminate the Unsafe control message. You should be able to then use the
debugger to determine any additional issues.

Rick D.
Contractor
 
J

John Dinning

Rick, thank you, thank you, thank you.
A simple fix and everything is now working perfectly. That was driving me
insane.

John.

dbgrick said:
John,
Marking your control with the DesktopCompatible(true) attribute will
eliminate the Unsafe control message. You should be able to then use the
debugger to determine any additional issues.

Rick D.
Contractor

John Dinning said:
I have created a simple visual component based on a Label, with no
properties or methods added so far (using VS2005, New Control Library
project for smart device Windows CE 5).

It builds ok, I can add it to the toolbox and use it no problem in my
test
project..
However, it will also required to call an existing DLL.

When I just add the two lines:
[DllImport("MyTest.dll")]
private static extern int TestFunc();

It builds ok, but the component is somehow corrupted.
The text on the label in the designer in the test project displays
"KBDStatusLabelLib.KBDStatusLabel" not "KBDStatusLabel1" as expected.
Also, if I add a property the designer displays the the Error "The type
'Microsoft.CompactFramework.Design.UnsafeControl' has no property
named 'MyProperty'"


The code for the label component is here:

namespace KBDStatusLabelLib
{
public partial class KBDStatusLabel : Label
{
public KBDStatusLabel()
{
InitializeComponent();
}
[DllImport("MyTest.dll")]
private static extern int TestFunc();
}
}

Can anyone help please?

John.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top