Using Mono libraries in Xamarin?

My project on the PC makes extensive use of System.IO.Packaging. This is supported in Mono's WindowsBase library, but this does not appear to be part of the standard Xamarin packages? Anyway, I copied that dll to my Mac and imported it into my References. Although the DLL appears and there do not appear to be any errors related to it, I still get the error "The type of namespace name 'Packaging' does not exist in the namespace 'System.IO'.

This appears to be the last remaining hurdle to getting my code to run properly, so you might imagine my desire to fix this.

Any advice?

Posts

  • adamkempadamkemp USInsider, Developer Group Leader mod

    The assembly you copied is probably referencing other assemblies that you don't have (and can't use) in your Xamarin app. Specifically the .Net base assemblies are different. Unless it is a PCL you can't just copy the binary from one platform to another. You will have to get a binary built for this platform.

  • So I guess I'm misunderstanding what exactly is going on in the PCL.

    I was eventually able to get this code working, but only by porting the original VB to C# and the re-compiling. My attempts to build the VB into a PCL on the PC side have so-far failed.

  • adamkempadamkemp USInsider, Developer Group Leader mod

    A PCL is a special kind of binary that is meant to be shared across platforms without recompiling. All other .Net DLLs cannot be shared across platforms. They require recompiling for each platform.

    I have no idea what state VB.Net is with respect to PCLs, but I didn't think Xamarin supported VB.Net anyway. I don't really know whether it should work or not, and since I think VB should be banished from the world I have no interest in finding out. ;)

  • A PCL is a special kind of binary that is meant to be shared across platforms without recompiling.

    Ahhh, I understood it be the opposite, that it contained no compiled code and invoked the compiler on the host platform. Your post triggered me to start reading more about the underlying technology, which I'm doing now.

    I didn't think Xamarin supported VB.Net anyway

    Actually this is the suggested method of supporting VB, and now that I better understand PCL I see why - this allows them to leave the VB compilation to VS, and then simply complete the last step by compiling from the CIL to Xamarin's supported platforms.

    That said, I was not able to get it to actually work. Problems were unclear, and there was little information I could find on how to address them. But now I think the reason was that I was selecting the Mono libraries, which probably aren't PCL, but by not selecting them I would lose Packaging anyway, which would make the point moot.

    Porting to C# for my test project was relatively easy, although who knows if that will remain the case as I add more of our business logic...

Sign In or Register to comment.