Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 737117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:41:01+00:00 2026-05-14T07:41:01+00:00

I have a C# Windows Forms project open with some C# code in it.

  • 0

I have a C# Windows Forms project open with some C# code in it.

Question: How can I have an F# file that I can write F# code in but still referencing all the C# code I have on Form1.cs (including the GUI).

I can successfully do this:

– Create a C# Windows Forms project

– Create a F# Library project

– Reference the F# Library DLL from my C# project

– That way I can call F# functions from C#

But I still can’t see my buttons and textboxes from F#

I understand that that is because it’s a library and it can’t reference System.Windows.Forms

So how do I fix this? I don’t want it to be a library or this or that, I just want it to be a file that will allow me to write F# code while being able to reference my C# Form and code.


I guess you can say I want an F# file that is also a “partial class Form1” so that I can continue writing code for the same Project, but using F# instead.
How do I do that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T07:41:01+00:00Added an answer on May 14, 2026 at 7:41 am

    If I understand the question correctly, you’re actually asking how to structure your application so that you can use WinForms designer (which is only available in C#/VB) to create a form and at the same time, write the application logic in F#.

    First of all, there is no way to mix the two languages in a single project, which means that you cannot write something like a partial class with one part in F# and other part in C# (this is technically almost impossible). So, the only option is to write an F# project and a C# project and reference one from the other. There are two ways to do this:

    (Based on your answer and comments, I think you may prefer the first one)

    Referencing C# library from F# application: One option is to create a simple WinForms library project in C# to contain the form (and possibly other controls etc.) created using the WinForms designer and nothing else. Then you’d reference this library from an application created in F# and implement all the user interaction in the F# application.

    If you make sure to mark the YourForm class created by WinForms designer as well as all relevant controls added to the form as public, then you can reference the form and control it from your F# application.

    • I used this approach in the one sample in my book, so if you’re looking for an example, you can look at the source code for Chapter 14 (look for “FSharpEffects”)

    Referencing F# library from C# application: When you structure your application in this way, you’ll need to create an F# library that exposes all the basic functionality that your application needs and then reference it from a C# application. The C# application would add all the user-interface interaction code and it would call the F# library to preform the actual work.

    In this scenario, the F# library doesn’t know anything about the C# form. If you reference System.Windows.Forms from your F# library then it may take some WinForms controls as arguments (e.g. to configure them & load data), but it won’t know anything about the controls declared in C#.

    One possible extension to this approach is to declare an interface in the F# library, implement it in the C# application and then pass an implementation back to the F# library. The interface may expose some important properties of the application (e.g. give access to all the important WinForms controls). Once you give an implementation of the interface to your F# library, the F# library can use it to manipulate with the application.

    (The approach with interface requires writing more code and may be less flexible, but if you want to write the main application in C# and declare the form there, it is probably the best option)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 362k
  • Answers 362k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is a very tricky question here. First: What are… May 14, 2026 at 3:11 pm
  • Editorial Team
    Editorial Team added an answer In sqlplus, execute this: SET LINESIZE 1500 May 14, 2026 at 3:11 pm
  • Editorial Team
    Editorial Team added an answer It's fine. @synchronized is aware of the return statement. (Ref:… May 14, 2026 at 3:11 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.