.net - Share code between website/web application project and Script#/ScriptSharp -


I added a script # project to my website project and created a small sample library with two classes.

Now I want to use these sections with website code. In this case, I created a simple object tree and it serialized JSON (which will then be received by the client-side code).

I tried to add a reference to the script # project

  • Runtime version variant
  • Is it also OK, but then I have a Returns the error:

    • Is it possible to share code between script # and normal C #?

      I am using script # 0.6 with VS 2010 and .NET 3.5 (both projects).

    The code is completely refreshed. I trust that the data sections sent to the web service Reuse

    What you can do:

    1. Set up a single c-sharp file named SharePoint in the "Shared" folder.
    2. Then right-click on each of your projects, project node, select "Add" -> "Existing Items". Browse for SharedTypes.cs, then click the down arrow next to "Add" and select "Add Link"
    3. Create your shared classes there.
    4. For example, add a preprocessor symbol to the "server" project, for example "WEBSERVER" allows you to have slightly different functionality between projects if you need it

    Example:

      Public class MyDataPacket {public int UserId; Public string SomeData1; Public int SomeData2; #if SCRIPTSHARP Public MyDataPacket {MySpace}  Script now has a default symbol  SCRIPTSHARP , ! WEBSERVER . 


    Comments