Code Monkey home page Code Monkey logo

Comments (2)

shawnhar avatar shawnhar commented on August 16, 2024

Interesting question! I don't know F# well, but if I am correctly interpreting what I see in Visual Studio, I think this issue is due to the lack of a non-PCL F# library template supporting Windows Store.

PCL (Portable Class Library) is a very restricted subset that can only reference APIs that are universally available on all the enabled target platforms. Because Win2D is a WinRT component implemented using native code, it is not accessible from a PCL.

In C#, there are two options for library projects:

  • Store Apps / Universal Apps / Class Library (Portable for Universal Apps) is a PCL, so cannot reference Win2D
  • Store Apps / Windows Apps / Class Library (Windows) is a regular (non-PCL) class library that supports Windows Store and can reference Win2D

But when I look at the F# project templates, I see only:

  • Library (which is not for Windows Store)
  • Portable Library (which is a PCL)

I'm not sure why F# is missing the option of a non-PCL library project that targets Windows Store, but without this I don't think it will be possible to directly access Win2D. At least not currently - we will do some more digging to see if there isn't some way we might be able to support PCL better, but I'm not sure how or even if that may be possible.

You could use the C# "Class Library (Windows)" project type as a proxy except I suspect this will run into the same issue that you won't be able to reference that C# project from an F# PCL.

Unless I'm missing something, it looks like F# support for calling WinRT APIs is currently not very complete, or at least that Visual Studio does not include a full set of templates for this type of project.

from win2d.

shawnhar avatar shawnhar commented on August 16, 2024

Hello again - I spent some more time looking into this and here's what I found out:

  1. There is not currently any good way to consume a WinRT component such as Win2D from a .NET portable class library (PCL) like the default F# project type. There's nothing we can change in the Win2D packaging to make that work.

  2. This means that to access Win2D from F#, you would need to create a non-PCL F# project targeting the Windows Store platform. Unfortunately there does not seem to be any support for this in F#, although I am extremely newbie in the world of F# so might just not be aware how to do it.

  3. One structure that will work is to implement your app logic as an F# PCL, then consume the resulting F# assembly from a C# app project which can use Win2D to draw the data that was calculated by F# code. The project dependencies only work this way around, though: C# Windows Store project using Win2D can call into F# PCL, but it is not possible for an F# PCL to call into a C# Windows Store library project (F# PCL can only call C# library if that C# library is also PCL, in which case the C# PCL library could not use Win2D).

Hope that helps,

from win2d.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.