none
Add Reference to a .Net Class Library RRS feed

  • Question

  • Hi all,

    I have an issue and I need some help.

    I want to add reference to a .Net Class Library named TestDLL in my Lightswicth project. The TestDLL contains a method. This methods doesn't return any value. Just I want to call it every time I click on a button. I am allowed to add this dll only on server side but it doesn't help me. I want to call this method when I click on a button and I am not allowed to add this reference to the Client. Unfortunately the TestDLL can not be written again as Silverlight Class Library. So I am in trouble.

    As I read the better way is to use Ria Sevrice but I couldn't find something that suits to my case..

    Any Ideas?

    Thanks in advance

    Maria

    Tuesday, December 13, 2011 8:49 AM

Answers

  • If you search the forum, you'll find that other users achieve this by using what's called the command pattern.

    In LightSwitch, the way to communicate information between a client and the server is to use table entities. What you can do is create a table that represents executing the method that you want to call from the TestDLL assembly.

    Essentially, the client will create a new instance of this entity type and save it. The server will intercept the inserting operation for the entity type (open the entity in the designer, select the <EntityName>_Inserting method from the Write Code drop down) and call the method.

    If the action you wanted to perform on the server has some kind of result, you can then store the result in one of the properties of the entity instance. Once the insertion is completed, the updated entity is propagated back to the client, thus, the client can react to the result.


    Justin Anderson, LightSwitch Development Team
    Tuesday, December 13, 2011 9:00 AM
    Moderator

All replies

  • If you search the forum, you'll find that other users achieve this by using what's called the command pattern.

    In LightSwitch, the way to communicate information between a client and the server is to use table entities. What you can do is create a table that represents executing the method that you want to call from the TestDLL assembly.

    Essentially, the client will create a new instance of this entity type and save it. The server will intercept the inserting operation for the entity type (open the entity in the designer, select the <EntityName>_Inserting method from the Write Code drop down) and call the method.

    If the action you wanted to perform on the server has some kind of result, you can then store the result in one of the properties of the entity instance. Once the insertion is completed, the updated entity is propagated back to the client, thus, the client can react to the result.


    Justin Anderson, LightSwitch Development Team
    Tuesday, December 13, 2011 9:00 AM
    Moderator
  • Justin,

    Indeed, people in the forum call it "the command pattern" and they mean, as you describe as well, that they use an entity not with the primary intention  of saving this entity, but for  triggering a "transaction script" server side, where the params of the transaction script are stored in the entity.

    Obviously, the command pattern is a well-known design pattern, basically an Interface defining an Execute() method (In MVVM terms, a command gets an additional _CanExecute() method) and is of course something completely different than what is meant in Lightswitch context.

    Maybe the naming "command table pattern" is more appropriate?

     


    paul van bladel
    Tuesday, December 13, 2011 8:40 PM