DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Tue, 17 Jul 2007 10:00:48 +1000,    posted on: microsoft.public.dotnet.framework.compactframework        back       

Thread Index
  1    John Dinning
          2    dbgrick
                 3    John Dinning


DllImport and visual component problem   
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.
Date:Tue, 17 Jul 2007 10:00:48 +1000   Author:  

RE: DllImport and visual component problem   
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" wrote:


> 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.
> 
> 
> 
Date:Tue, 17 Jul 2007 07:14:01 -0700   Author:  

Re: DllImport and visual component problem   
Rick, thank you, thank you, thank you.
A simple fix and everything is now working perfectly. That was driving me 
insane.

John.

"dbgrick"  wrote in message 
news:315C8B52-975B-4FF2-950E-DD7F30612D92@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" wrote:
>
>> 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.
>>
>>
>> 
Date:Thu, 19 Jul 2007 09:40:57 +1000   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us