471,337 Members | 1,057 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

DllImport and Control Library project

(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.
Jul 13 '07 #1
1 4938
The solution was supplied by Rick D in the dotnet.framework.compactframework
newsgroup. Thank you Rick.

"dbgrick" <db*****@discussions.microsoft.comwrote in message
news:31**********************************@microsof t.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" <jo**@NOSPAMbarcodelogic.com.auwrote in message
news:%2****************@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.

Jul 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Paul Duncan | last post: by
2 posts views Thread by Brian Anderson | last post: by
2 posts views Thread by nospam | last post: by
5 posts views Thread by =?Utf-8?B?U2FsYW1FbGlhcw==?= | last post: by
3 posts views Thread by Dan Holmes | last post: by
6 posts views Thread by vivekanandaprasanth | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.