问题
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