Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when referencing out-of-solution DLL's (.NET Core only) #2041

Closed
Hosch250 opened this issue Mar 13, 2018 · 1 comment · Fixed by #2090
Closed

Bug when referencing out-of-solution DLL's (.NET Core only) #2041

Hosch250 opened this issue Mar 13, 2018 · 1 comment · Fixed by #2090
Milestone

Comments

@Hosch250
Copy link

I've found an interesting issue with using DLL's in .NET Core (.NET Framework works fine). MVCE as follows:

Create an F# (language is irrelevant) .NET Core class library with the following single file (specific code irrelevant as well):

namespace FSharpClassLibrary

module Say =
    let hello name =
        printfn "Hello %s" name

Create a C# .NET Core class library in a separate solution (very important--it completely works if they are all in the same solution) with the following code:

namespace CSharpClassLibrary
{
    public class HelloClass
    {
        public void Hello(string name)
        {
            FSharpClassLibrary.Say.hello(name);
        }
    }
}

Also, add a folder dlls, copy/paste FSharpClassLibrary.dll into it, and add it as a reference to the project (otherwise, the file above won't compile). It's actually not important to move the .dll into the project, but since I'm distributing this second project independently of the first, I need to guarantee the DLL is available.

Finally, add a console app to the same solution as CSharpClassLibrary with the following file:

using System;
using CSharpClassLibrary;

namespace ConsoleApp1
{
    public class Main1
    {
        public static void Main()
        {
            new HelloClass().Hello("test");

#if DEBUG
            Console.Write("Press any key");
            Console.ReadKey();
#endif
        }
    }
}

Finally, go into NuGet and add FSharp.Core version 4.3.4 to both C# projects (just to make sure everything has access to the F# language stuff; not necessary if you create the first class library with C#). Also, I am using VS 15.6; this may or may not be relevant as well.

Set the console app as the startup project and run it. You will get the following error:

System.IO.FileNotFoundException: Could not load file or assembly 'FSharpClassLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'FSharpClassLibrary, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
at ClassLibrary1.Facade.Hello1.Hello(String name)
at ConsoleApp1.Main1.Main() in C:\Users\***\source\ConsoleApp1\ConsoleApp1\Main.cs:line 11

The most curious part about this is that if I bypass the CSharpClassLibrary library and host FSharpClassLibrary.dll and HelloClass.cs in the ConsoleApp1 project, everything works as expected. The same issue happens if I use two C# DLL's, I used F# because that's what I was working with already.


Initially posted as a question on Stack Overflow.

@tannergooding tannergooding self-assigned this Mar 13, 2018
@tannergooding tannergooding added this to the 2.1.3xx milestone Mar 13, 2018
@tannergooding
Copy link
Member

This is basically #1609. Manual assembly references are transitive for the purposes of copying outputs, but are not transitive for the purposes of deps.json creation.

There is a separate issue where the deps.json is not being rewritten when it should be (so if you build, then add a manual reference, and rebuild, F5 will fail).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants