Re: Best practices in .NET libraries compatible to Compact Framewo

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hello Frans,

I thought, that I can compile my own library, that can be used in both
project ('normal' .NET Framework and Compact .NET Framework). This compiled
library contains objects that I want to use in both projects (like an Order,
or Customer is). But there are helper functions, that can be used only on the
'normal' Framework - like... SendBroadcast or something similar that is
useable only in PC environment.

For example:

Im writing base clases for our business solution like Order, Customer etc.
These object have same structure, same methods, same properties for
Windows-Form apps, .NET.ASP apps, and mobile, PocketPC apps. I would like to
write library, that is useable for both platforms (one library) .. and I
thought, that I can write one library project, and then I have to sign the
methods by an attribute like [CFSupported] or something similar only. Only
the methods, that are supported by CF (because not all methods can be used on
CF)


It seems Im wrong and I have to write two version of my own business
framework. Thats weird.

Thanks for any idea

Mirek.

"Frans Bouma [C# MVP]" wrote:

Mirek Endys wrote:

Im writing .NET libraries for .NET Framework and .NET Compact
Framework too. What is the best practices to write 'multi-platform
(.NET Framwork / .NET Compact Framework)' libraries

:)

(Which attribute says; in my class; that this member of a class is
.NET Compact Framework compatible)

I'm not familiar with such an attribute. The thing is that for .NET it
doesn't matter if you're compiling for the compact framework or normal
..NET, as you're using the same compiler, you just link with another
mscorlib and framework assemblies ;)

In general, everything remoting related should be avoided. Also,
things like:
myStringBuilder.AppendFormat("..."... )
should become:
myStringBuilder.AppendFormat(null, "...

but that's mostly it. To get my o/r mapper core running on the CF.NET
framework I wrote a couple of dummy classes which do nothing on the
CF.NET and I simply add that set of classes to the code when I'm
compiling against the CF.NET. This then helps me avoid to add a lot of
conditional compilation statements in the code and I can keep
[Serializable()] etc. in my code. :)

So I'd invest some time in that set of classes, which isn't that hard,
and then just develop for the normal .net framework. Porting the code
over would then be a piece of cake :)

Frans

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

.



Relevant Pages