MikeG
MikeG

Reputation: 1069

PortableDLL in MonoTouch and MonoDroid

Can you share .NET DLLs (written in VB.NET using Visual Studio) between Full.NET, WindowsPhone, Silverlight, MonoTouch, MonoDroid. (And in Future also WinRT)

Is this possible?

I'm not looking to share UI code mostly just Models but maybe also some ViewModels (i.e. Using MVVM)

I was wondering whether using a Portable DLL would work? See http://visualstudiogallery.msdn.microsoft.com/b0e0b5e9-e138-410b-ad10-00cb3caf4981/

More details: This is not something I need today. I am looking at re-architecting existing projects written in VB.NET for .NET 4. This is going to be over the next year or so. Just like to have an idea whether Mono* devices will be able to play...

Thanks, Mike G

Upvotes: 0

Views: 718

Answers (3)

Eugen Rieck
Eugen Rieck

Reputation: 65274

Yes, you can! (tm)

There are some limits though: You already mentioned UI related stuff, but you have to cast a wider net: Your DLL may not make use of and it may not reference anything, that is inaccessible in one of the platforms.

With a little time warp you can even include .NET CF

Upvotes: 1

Marc Gravell
Marc Gravell

Reputation: 1062905

With regular .NET assemblies: a combination of yes and no. Broadly, yes. But in reality there are often platform-specific changes that are needed due to limitations on each platform, which will stop it running the assembly. The IDE also doesn't like certain combinations of references. The monodevelop IDE is IIRC more permissive in terms of what assemblies it will accept.

Re things that don't work; it can be silly things like whether Trace.WriteLine(...) exists, or (more recently on "unity", Interlocked), or it can be platform restrictions (you can't do as much meta-programming on iOS, for example).

WinRT sets a new "bar" for breaking things, with radical changes throughout (fundamentals such as Type have been hugely altered).

My advice: build per platform; otherwise you are limiting yourself to the least common denominator, which is not optional. Make use of what exists on each platform, with fallbacks for when it doesn't.

Upvotes: 3

Karel Frajták
Karel Frajták

Reputation: 4489

You can share the source code across projects for different platforms. You create the file once and link to other projects targeting different platforms. See this.

You can't share the DLLs. You can't for example reference .NET "desktop" assembly in Silverlight project because of the selected target platform.

Upvotes: 2

Related Questions