Click here to Skip to main content
15,887,861 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have 2 problem.
In short:
1. problem 1, use the .NET core from a full framework app
2. write a .NET Core app which target platform specific code

Problem 1
see "what I have tried"

Problem 2
I don't have any code to show here.
But at work we target Android, iOS and .NET SDK using PCL. I was wondering if can write a .NET Core library that somehow get to use platform specific implementation of whatever feature... I am not sure how to go about it....

What I have tried:

Problem 1:
I have 2 very simple projects.

A .NET Core library as follow (whole source code)
C#
namespace ClassCoreLib1
{
    public static class Class1
    {
        public static string Answer() { return "42"; }
    }
}


and a .NET 4.5.2 console app as follow (whole source code)
C#
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = ClassCoreLib1.Class1.Answer();
            Console.WriteLine(s);
        }
    }
}


Now I try, as you can see to use the .NET Core library with the full .NET framework console app

I did modified the .NET Core library's project.json as follow, I added:
JavaScript
"net451": {
  "dependencies": {
    "Microsoft.NETCore.Platforms": "1.0.1"
  }

And it did create a .NET output folder and when I study the .DLL inside it it seems to depends on mscorlib from the GAC, .NET 4.5.1, so it should be right, I think...

Now... if I copy the .DLL in the net452 output folder outside the ClassCoreLib folder.. then I am able to link against it and run! Yahoo! :)

However I can't compile by linking against the project or even directly referencing the .dll by its path "..\..\src\ClassCoreLib1\bin\Debug\net451\ClassCoreLib1.dll" fails to compile...

Summary
Having to copy the .dll after each successfull build is quite unproductive and error prone.... I wonder if there is a better solution?
Posted
Updated 28-Jun-16 23:25pm

1 solution

Fixed it!!

changed my framework dependency (in the project.json file) to
"net451": {}

I was able to link against the .dll in "..\..\src\ClassCoreLib1\bin\Debug\net451\ClassCoreLib1.dll" successfully! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900