From: John Dinning on
(Using VS2005 C# and compact Framework. Target device is running CE5).

I am creating a simple visual control (New Control Library project for smart
device Windows CE 5), derived from Label, with a couple of extra properties.

I need to call an external dll from this control, on a timer.

When I insert the declaration for the external dll function and build the
control project, strange things happen to any project that uses this
control.

One of my new properties disappears from the properties window.
The form designer displays the error:
"The type 'Microsoft.CompactFramework.Design.UnsafeControl' has no property
named 'TType'"
(TType is my new property - an enum).

The dllImport declaration looks like this:

[System.Runtime.InteropServices.DllImport("Test.dll")]
private static extern bool GetAlphaMode();

It makes no difference if the Test.dll exists or not so the problem is not
with the dll, only with the declaration.
I am not actually calling the function - just declaring it.
If I remove these two lines, all is well again, and all properties are
visible in the designer.
With or without these two lines, the project compiles with no errors.

My first question is:
Is it ok to call a Dll from a visual component library?
If not does anyone have any idea what is going on here?

More info:
If I remove all my new properties, so the control only inherts the standard
label, the control compiles, but the default text on the label is not
'MyNewLabel1' but 'MyNewLabelLib.MyNewLabel', i.e. the library name and
class name of the component. Weird.

Any help extremely welcome.

John.


From: John Dinning on
The solution was supplied by Rick D in the dotnet.framework.compactframework
newsgroup. Thank you Rick.

"dbgrick" <dbgrick(a)discussions.microsoft.com> wrote in message
news:315C8B52-975B-4FF2-950E-DD7F30612D92(a)microsoft.com...
> 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" <john(a)NOSPAMbarcodelogic.com.au> wrote in message
news:%231f30fRxHHA.4516(a)TK2MSFTNGP04.phx.gbl...
> (Using VS2005 C# and compact Framework. Target device is running CE5).
>
> I am creating a simple visual control (New Control Library project for
> smart device Windows CE 5), derived from Label, with a couple of extra
> properties.
>
> I need to call an external dll from this control, on a timer.
>
> When I insert the declaration for the external dll function and build the
> control project, strange things happen to any project that uses this
> control.
>
> One of my new properties disappears from the properties window.
> The form designer displays the error:
> "The type 'Microsoft.CompactFramework.Design.UnsafeControl' has no
> property named 'TType'"
> (TType is my new property - an enum).
>
> The dllImport declaration looks like this:
>
> [System.Runtime.InteropServices.DllImport("Test.dll")]
> private static extern bool GetAlphaMode();
>
> It makes no difference if the Test.dll exists or not so the problem is not
> with the dll, only with the declaration.
> I am not actually calling the function - just declaring it.
> If I remove these two lines, all is well again, and all properties are
> visible in the designer.
> With or without these two lines, the project compiles with no errors.
>
> My first question is:
> Is it ok to call a Dll from a visual component library?
> If not does anyone have any idea what is going on here?
>
> More info:
> If I remove all my new properties, so the control only inherts the
> standard label, the control compiles, but the default text on the label is
> not 'MyNewLabel1' but 'MyNewLabelLib.MyNewLabel', i.e. the library name
> and class name of the component. Weird.
>
> Any help extremely welcome.
>
> John.
>