473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 5084
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Paul Duncan | last post by:
diggityduncs (Programmer) Nov 13, 2003 Hello, I'm tring to use a win32/api dll in c# The vendor I received the dll from doesn't know anything about .net I received two files ACGAPI.DLL +
2
by: Brian Anderson | last post by:
Hello, is it possible to use DllImport to call a DLL in ASP.NET ? Or is it necessarry that my DLL has to be copied into \System32 ? My DLL is a native C++ 7.1 DLL (not managed, no COM, no...
5
by: Tony Johansson | last post by:
Hello! I have one solution file that consist of three project. One project that build the exe file called A One project that build a user control dll. Here we have a class called B One project...
5
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
1
by: sharmadeep1980 | last post by:
Hi All, I am facing a very unique problem while compling my project in "Release" build. The project is building in DEBUG mode but giving linking error on Release build. Here is the error:...
2
by: nospam | last post by:
Hello - I am getting a compile error "Expected class, delegate, enum". I am trying to create a Class Library in C# which wraps around an unmanaged DLL that manages a MIDI interface. In my...
5
by: =?Utf-8?B?U2FsYW1FbGlhcw==?= | last post by:
Hi, I have a user control which I like to use in several projects (winforms) in the same solution. Inside lets say Winapp1 , When adding a reference to this control, I can dynamically or statically...
3
by: Dan Holmes | last post by:
I have this DllImport attribute on an external C++ dll. What i am noticing that the dll isn't unloaded after the static method is complete. I was thinking that when the method (it is a static...
6
by: vivekanandaprasanth | last post by:
hi, I have exported a class which i have written in win32 static lib app. Now i have written a wrapper class for the same. But when i am trying to compile it is giving me some linker errors....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.