Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Integrating .NET Core Consol Application into unity

Discussion in 'Scripting' started by DeLannoy04, Jul 29, 2019.

  1. DeLannoy04

    DeLannoy04

    Joined:
    Jul 2, 2019
    Posts:
    42
    Hi, I have a .net core console app library and I want to integrate it into unity so I can call functions from my console project. How can I do it?
     
  2. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,745
    Console app is not supposed to be integrated anywhere. You need class library type project for this. Having one, you may just copy resulting .dll file in Plugins folder and use as part of the project. And if you need console app and unity app to share same functionality, you create class library or unity class library (a class library with reference to unityengine.dll) and reference that library both in console app and in unity app.
    But if you really want to integrate console app in unity, you may use Process class from .NET api to create a process and read/write data from/to it's streams.
     
  3. DeLannoy04

    DeLannoy04

    Joined:
    Jul 2, 2019
    Posts:
    42
  4. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,745
    App and library are different things. In windows, app is .exe and library is .dll. In .NET there's no thing like "console app library", there are "console app" and "class library".

    To use class library from that project build it and copy to plugins folder or copy it's source to plugins folder or made it a unity package with https://docs.unity3d.com/Manual/CustomPackages.html.
     
  5. DeLannoy04

    DeLannoy04

    Joined:
    Jul 2, 2019
    Posts:
    42
    If I copy the .dll file into the project, I get this error:
    Assembly 'Assets/BitcoinLib.dll' will not be loaded due to errors:
    Unable to resolve reference 'System.Configuration.ConfigurationManager'. Is the assembly missing or incompatible with the current platform?
    Reference validation can be disabled in the Plugin Inspector.
     
  6. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,745
  7. DeLannoy04

    DeLannoy04

    Joined:
    Jul 2, 2019
    Posts:
    42
    I saw this post, but I don't know how to add these dlls. I'm a beginner on this, sorry.
     
  8. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,745
    It says, you should just copy them to plugins folder manually.
     
  9. DeLannoy04

    DeLannoy04

    Joined:
    Jul 2, 2019
    Posts:
    42
    Yap, but there are still a lot of errors.