c# - how to call a method in a windows from another method in asp.net web-api -


i have c# solution has 2 projects: windows forms project (desktop) , asp.net web-api project (rest service). trying call method enablemachine() in form1.cs post() method in valuescontroller.cs, though referenced namespace shows errors. if define enablemachine() static works, cannot because need instantiate object within method. ideas on how solve problem ? in advance !

using system; using system.collections.generic; using system.linq; using system.net; using system.net.http; using system.web.http; using restlayer.models; using validatorconnector;  namespace restlayer.controllers {     public class valuescontroller : apicontroller     {          // post api/values         public void post()             {                ...                  }        } }    using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using log4net;  namespace validatorconnector {     public partial class form1 : form     {       public form1()         {          ...         }      public void enablevalidator()     {         ...     }  } 

best thing separate common functionality separate project not depend on forms or on asp.net. give assembly asp.net , winforms projects dependency, you'll able call methods both projects.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -