Start a new topic

Compile duo library for use in .net

I would like to create a C# library that I compile into a .NET assembly (dll) and a JavaScript/Typescript file. I'm using VS 2015 and DuoCode 1.0. Without DuoCode I can compile the shared library code into a .NET dll and run a test WinForms app. As soon as I enable DuoCode for the library (by installing DuoCode via the NuGet manager), my app fails when it tries to instantiate a type from the Duocode dll. I generates a System.InvalidProgramException.

Is my intended Use Case supported? If yes, what am I doing wrong? If no, should I create a post-build step in VS that compiles the C# code into JavaScript via the dcc.exe command line tool? 

Thanks. If I can get this working I believe DuoCode will be a significant tool for us as we try to implement C# and JavaScript code.



DuoCode compiler creates "meta-data" .NET assembly DLLs which contains on class/types/methods declaration no actual code behind.
Such an assemlies are good for referencing only between DuoCode projects, they are not valid Win32 assemblies for executing.

In order to compile you project/assembly to multiple platforms, we recommend to create Configuration = "JavaScript" for example and compile using DuoCode only on this configuration.
The way to achive this is to edit your .csproj file, instead of the following line:

<Import Project="packages\DuoCode.1.0.1353.0\build\DuoCode.targets" Condition="Exists('packages\DuoCode.1.0.1353.0\build\DuoCode.targets')" />

Write this one:

<Import Project="packages\DuoCode.1.0.1353.0\build\DuoCode.targets" Condition="Exists('packages\DuoCode.1.0.1353.0\build\DuoCode.targets') And '$(Configuration)' == 'JavaScript'" />

Such approach allows to have different project properties per configuration (Debug/Release/JavaScript).

Sorry for late replay,
The DuoCode team



One more tip is to define also in Project Properties "Build\General" tab a Conditional Compilation Symbol called JAVASCRIPT.
In your multi-platform C# code you can easily check:


The DuoCode team


Thank you very much. I think this solution will work for me
Login or Signup to post a comment