Compilation Directives

  • Thread starter Thread starter Carsten Unterberg
  • Start date Start date
C

Carsten Unterberg

Hey everybody,

I'm using VS2008 for developing application in ppc2003 and the .netcf 2.0.
at the moment I've got some problems while I'm creating some customcontrols,
which should be available at designtime as well. Most of the work seems to be
ok, the controls works fine at runtime. Only at designtime, in VS2008 I've
got some *** problems.

the controls, or the one controls with the problems uses some api-calls via
[DllImport("...")].
I declared a compilation directive call NETCFDESIGNTIME in the
configuration-manager and when I got the declaration of the imported
function, i I have a 'switch' with
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz....

that works fine, at runtime, not at designtime.

Could anyone help me please?

Thanks

Carsten Unterberg
 
try with,

if(Site.DesignMode)
[DllImport("coredll.dll")]
else
[DllImport("user32.dll")]

Cheers,
Arun
 
hey Arun,

thanks a lot, but I couldn't use a normal 'if' there.

its like that:

namespace myNamespace
{
public class myClass : UserControl
{

//Compilation Directive
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz...

}
}

It seems to be OK, in this way, that code will work on the device, but not
in VS. If I change the condition, it will work in VS, but on the device I get
an error like -"user32.dll" is missing-

Or is it the complete wrong way to work with that compilation directives in
VS2008, cause I saw it in VS2003?


Thanks
Carsten

--
I try to do it


Arun said:
try with,

if(Site.DesignMode)
[DllImport("coredll.dll")]
else
[DllImport("user32.dll")]

Cheers,
Arun


Hey everybody,

I'm using VS2008 for developing application in ppc2003 and the .netcf 2.0.
at the moment I've got some problems while I'm creating some customcontrols,
which should be available at designtime as well. Most of the work seems to be
ok, the controls works fine at runtime. Only at designtime, in VS2008 I've
got some *** problems.

the controls, or the one controls with the problems uses some api-calls via
[DllImport("...")].
I declared a compilation directive call NETCFDESIGNTIME in the
configuration-manager and when I got the declaration of the imported
function, i I have a 'switch' with
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz....

that works fine, at runtime, not at designtime.

Could anyone help me please?

Thanks

Carsten Unterberg
 
Read this, using Site.DesignMode is much more simpler than using the
conditional compilation directives.
http://decav.com/blogs/andre/archive/2007/04/18/1078.aspx

The conditional compilation directives always works the same,
You may have to follow this to add designer support for your control.
http://msdn2.microsoft.com/en-us/library/aa446505.aspx

Cheers,
Arun



hey Arun,

thanks a lot, but I couldn't use a normal 'if' there.

its like that:

namespace myNamespace
{
public class myClass : UserControl
{

//Compilation Directive
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz...

}
}

It seems to be OK, in this way, that code will work on the device, but not
in VS. If I change the condition, it will work in VS, but on the device I get
an error like  -"user32.dll" is missing-

Or is it the complete wrong way to work with that compilation directives in
VS2008, cause I saw it in VS2003?

Thanks
Carsten

--
I try to do it



Arun said:
try with,
if(Site.DesignMode)
[DllImport("coredll.dll")]
else
[DllImport("user32.dll")]
Cheers,
Arun
Hey everybody,
I'm using VS2008 for developing application in ppc2003 and the .netcf 2.0.
at the moment I've got some problems while I'm creating some customcontrols,
which should be available at designtime as well. Most of the work seems to be
ok, the controls works fine at runtime. Only at designtime, in VS2008 I've
got some *** problems.
the controls, or the one controls with the problems uses some api-calls via
[DllImport("...")].
I declared a compilation directive call NETCFDESIGNTIME in the
configuration-manager and when I got the declaration of the imported
function, i I have a 'switch' with
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz....
that works fine, at runtime, not at designtime.
Could anyone help me please?
Thanks
Carsten Unterberg

- Show quoted text -
 
Hi Carsten ,

Read this, using Site.DesignMode is much more simpler than using the
conditional compilation directives.
http://decav.com/blogs/andre/archive/2007/04/18/1078.aspx

The conditional compilation directives always works the same,
You may have to follow this to add designer support for your control.
http://msdn2.microsoft.com/en-us/library/aa446505.aspx

Cheers,
Arun



hey Arun,

thanks a lot, but I couldn't use a normal 'if' there.

its like that:

namespace myNamespace
{
public class myClass : UserControl
{

//Compilation Directive
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz...

}
}

It seems to be OK, in this way, that code will work on the device, but not
in VS. If I change the condition, it will work in VS, but on the device I get
an error like  -"user32.dll" is missing-

Or is it the complete wrong way to work with that compilation directives in
VS2008, cause I saw it in VS2003?

Thanks
Carsten

--
I try to do it



Arun said:
try with,
if(Site.DesignMode)
[DllImport("coredll.dll")]
else
[DllImport("user32.dll")]
Cheers,
Arun
Hey everybody,
I'm using VS2008 for developing application in ppc2003 and the .netcf 2.0.
at the moment I've got some problems while I'm creating some customcontrols,
which should be available at designtime as well. Most of the work seems to be
ok, the controls works fine at runtime. Only at designtime, in VS2008 I've
got some *** problems.
the controls, or the one controls with the problems uses some api-calls via
[DllImport("...")].
I declared a compilation directive call NETCFDESIGNTIME in the
configuration-manager and when I got the declaration of the imported
function, i I have a 'switch' with
#if NETCFDESIGNTIME
[DllImport("coredll.dll")]
#else
[DllImport("user32.dll")]
#endif
static extern int xyz....
that works fine, at runtime, not at designtime.
Could anyone help me please?
Thanks
Carsten Unterberg

- Show quoted text -
 
Hi,

Carsten Unterberg said:
thanks a lot, but I couldn't use a normal 'if' there.

If you only have a couple of Platform Invoke calls, and don't need to
conditionally compile out larger chunks of your assembly depending upon your
target (desktop or PDA) envrionment you may like to look into having
multiple Platform Invoke definitions for each of your functions.

You might find an article of mine of interest - "Sharing Platform Invoke
code between the Desktop and Compact Framework" available at
http://www.christec.co.nz/blog/archives/193, in particular the "Dealing with
APIs that exist in different locations" section.

You could probably come up with a similiar solution to the one described in
that article but also incorporating the Site.DesignMode property into the
decision of which method to call.

Hope this helps,
Christopher Fairbairn
 
Back
Top