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
Post a Comment