0

I need to maintain a F# project. Right now I need to import a C# dll and make use a function in there.

What I have done is that in the F# solution, I have added the C# project, then in the F# project, I have added this new C# project as a reference. The exact step is as follows.

in solution explorer, I have located the F# project. right clicked references, and add reference. Under solution category, I checked the C# project.

After all these steps. my C# project is listed as one of the references in the solution explorer. but it has a yellow triangle with an exclamation mark on it.

In the F# solution file. I have tried the following

open CSV_Reader    //this is the project name, and also the namespace


module Stage =

    CSV_Reader.Parser.InsertIntoDB(connStr, tableName, csvFilePath)

the compiler is telling me for the 2 occurrences of CSV_Reader

The namespace or module 'CSV_Reader' is not defined
The namespace or module 'CSV_Reader' is not defined

EDIT:

Thanks to the link (likely duplicate) provided by Guy Coder, tt turns out that the problem I am running into is a .net framework mismatch issue. The F# project runs on .net 4 but the C# dll is written in .net 4.5. Therefore when I make a reference to the C# project, there is a yellow triangle with exclamation mark. All i need to do is to modify the C# dll project to use the same version of .net framework as the F# project and the issue is resolved.

Community
  • 1
  • 1
Ji_in_coding
  • 1,691
  • 1
  • 14
  • 17
  • @Ian how do you add a dll to a F# project? I don't see a place to do that in Reference manager – Ji_in_coding Mar 24 '16 at 16:54
  • I take it that you are trying to compile the project and not run it from F# Interactive? I ask because the link above is about using F# Interactive. – Guy Coder Mar 24 '16 at 17:03
  • @GuyCoder you are correct. and I have tried the link above before openning this thread – Ji_in_coding Mar 24 '16 at 17:05
  • 1
    This might help: [Why do I get a warning icon when I add a reference to an MEF plugin project?](http://stackoverflow.com/questions/20186216/why-do-i-get-a-warning-icon-when-i-add-a-reference-to-an-mef-plugin-project) It might be different versions of .NET for the C# and F# projects. – Guy Coder Mar 24 '16 at 17:05
  • @GuyCoder hi, yes that link you provided does solve part of my problem. It is indeed a .net framework mismatch problem. – Ji_in_coding Mar 24 '16 at 17:49

0 Answers0