Is it possible to write code in C# and use Script# to share it between .NET assemblies and JavaScript?

旧巷老猫 提交于 2019-12-11 11:58:44

问题


I'm investigating using Script# to share some of our C# business logic with the client-side by compiling it to JavaScript.

Question is, is it possible to reference a Script# class library from another .NET assembly? I've tried doing it in a quick test and failed miserably.

Looking through the Script# source code leads me to believe this won't be possible because no implementation code has been provided for Script#'s mscorlib classes. See the String class as an example.

If someone can provide a definitive answer on this, I would be very grateful.


回答1:


What I do is to create two projects. The #script proyect and the .net class library proyect. Then I link each of the .cs files (Adding existing items as linked).

You can use #IF SCRIPTSHARP .... #ENDIF preprocesors to avoid compiling specific #script attributes.

Finally you can compile both libraries and reuse the code.

I use it every day and it work perfectly well.



来源:https://stackoverflow.com/questions/11460012/is-it-possible-to-write-code-in-c-sharp-and-use-script-to-share-it-between-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!