Writing an instance in F # is null in C #

I am working on a task for a school in which we make a small game using monogame, with the added task of working in F #. The logic of the game is completely unchanged F #, and the entry point is in C # using the Game class in a monogame. However, I had a strange problem with record types in F #. In the logic (F #), I have something like:

... module Vectors = type Vector = { x : double y : double } let Zero : Vector = {x=0.0; y=0.0} ... 

And in C #, I have a Zero access code:

 ... player.vector = Vectors.Zero; ... 

Oddly enough, when I try to use player.vector, it appears as null. When debugging, Vector.Zero is also null. I was looking for several solutions, and this might be some kind of trivial error, but I cannot find it.

+7
c # visual-studio f # monogame
source share
2 answers

When you build an F # project as an exe, but use it as a library, sometimes the initialization code is not called.

This can be fixed by changing the project to an assembly as a library.

+11
source share

Solved - the F # project was built as a console application. A change to this library has been fixed.

Thanks @JohnPalmer

+3
source share

All Articles