1

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

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

+1 on that ... you do need to be careful about what you reference. As long as you don't reference script-specific stuff or .net specific stuff you're fine ... in practice, some ifdefs go a long way. It would be interesting to improve this experience where possible. If there are suggestions, please open them as issues on the github repo for Script# for consideration.
Thanks NikhilK, Another thing I do is to create some kind of mock attributes (ScriptNameAttribute for example) with the same parameters, so that I use exactly the same .cs file without worring about the ugly #IF #ENDIF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.