Split code between website / web application project and Script # / ScriptSharp

I added the Script # project to my site project and created a small sample library with two classes.

Now I want to use these classes from the website code. In this case, I created a simple tree of objects and serialized it in JSON (which will then receive the client-side code).

I tried to add a link to the Script # project. It compiles fine, but then gives me an error on startup:

  • Assembly not found
  • execution version different

Is it even possible to use code between Script # and regular C #?

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

+3
source share
3 answers

. , -.

:

  • c-sharp SharedTypes.cs "".
  • node, "" → " ". SharedTypes.cs, "" " ".
  • .
  • , "WEBSERVER", . , .

:

public class MyDataPacket
{
    public int UserId;
    public string SomeData1;
    public int SomeData2;

#if SCRIPTSHARP
    public MyDataPacket(MyOtherClientSideClass arg)
    {
        // init
    }
#endif

#if WEBSERVER
    public MyDataPacket(MyOtherServerSideClass arg)
    {
        // init
    }
#endif
}

EDIT: Script # SCRIPTSHARP , !WEBSERVER.

+6

script # # . VS ( , ). # . , , , . , # #, script # script #.

, , , # script #. , , , .

+3

Script # #?

. # 2.0 Script # . automapper.

Script #, , .

, Script # Javascript.

0
source

Source: https://habr.com/ru/post/1755299/


All Articles