![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to initialize object in WCF services Hi, below is my sample WCF service coding [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, ConcurrencyMode=ConcurrencyMode.Single)] public class GSMService:IGSMServer private static GSMObject gsm; public GSMService() { gsm=new GSMObject(); gsm.SMSReceoved+=new GSMObject.GSMSMSEventHandler(gsm_SMSReceived); .......... } } i has host the service in window form. The GSM object only be initial when the client make a first call. Is that possible when the host start i can initial the gsm object then waiting the client to connect to receive the incoming sms event? Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: How to initialize object in WCF services R U sure. You constructor called when your call ServiceHost() in your app , and that have to be before first client's call Arkady "Elvin" <Elvin@discussions.microsoft.com> wrote in message news:3324C5D5-B5FA-4C8B-AA01-DCD7898FFA5D@microsoft.com... > Hi, below is my sample WCF service coding > > [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, > ConcurrencyMode=ConcurrencyMode.Single)] > public class GSMService:IGSMServer > > private static GSMObject gsm; > > public GSMService() > { > gsm=new GSMObject(); > gsm.SMSReceoved+=new GSMObject.GSMSMSEventHandler(gsm_SMSReceived); > .......... > } > } > > i has host the service in window form. The GSM object only be initial > when > the client make a first call. Is that possible when the host start i can > initial the gsm object then waiting the client to connect to receive the > incoming sms event? > > Thanks! |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: How to initialize object in WCF services yes, because the service need to turn on the GSM device to retrieve the sms message to do something even no client is call or attend. Once have client make a call the subscribe the operation contract then service will publish the info to the client. The other reason, is the service also need to do other job when it receive incoming sms, so the service cant depend on the client to wake up! i have think the alternative solution is make a client call from the host for the first time, but i dont think is a better design. hopefully you can give me some advice. Thanks! "Arkady Frenkel" wrote: > R U sure. You constructor called when your call ServiceHost() in your app , > and that have to be before first client's call > Arkady > > "Elvin" <Elvin@discussions.microsoft.com> wrote in message > news:3324C5D5-B5FA-4C8B-AA01-DCD7898FFA5D@microsoft.com... > > Hi, below is my sample WCF service coding > > > > [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, > > ConcurrencyMode=ConcurrencyMode.Single)] > > public class GSMService:IGSMServer > > > > private static GSMObject gsm; > > > > public GSMService() > > { > > gsm=new GSMObject(); > > gsm.SMSReceoved+=new GSMObject.GSMSMSEventHandler(gsm_SMSReceived); > > .......... > > } > > } > > > > i has host the service in window form. The GSM object only be initial > > when > > the client make a first call. Is that possible when the host start i can > > initial the gsm object then waiting the client to connect to receive the > > incoming sms event? > > > > Thanks! > > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: How to initialize object in WCF services What I meant when wrote : "R U sure ?" ( sorry forgot to put question mark ) , that GSMObject instantiated when GSMService() constructor called and that happen , not when client call the service method , but when you call ServiceHost() on the service, which have to be done before client first call, otherwise client just receive exception Arkady "Elvin" <Elvin@discussions.microsoft.com> wrote in message news:F1CA8FB6-3EB1-4E7E-AF3C-255E6092B8A8@microsoft.com... > yes, because the service need to turn on the GSM device to retrieve the > sms > message to do something even no client is call or attend. Once have client > make a call the subscribe the operation contract then service will publish > the info to the client. > The other reason, is the service also need to do other job when it receive > incoming sms, so the service cant depend on the client to wake up! > i have think the alternative solution is make a client call from the host > for the first time, but i dont think is a better design. > > hopefully you can give me some advice. Thanks! > > "Arkady Frenkel" wrote: > >> R U sure. You constructor called when your call ServiceHost() in your >> app , >> and that have to be before first client's call >> Arkady >> >> "Elvin" <Elvin@discussions.microsoft.com> wrote in message >> news:3324C5D5-B5FA-4C8B-AA01-DCD7898FFA5D@microsoft.com... >> > Hi, below is my sample WCF service coding >> > >> > [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, >> > ConcurrencyMode=ConcurrencyMode.Single)] >> > public class GSMService:IGSMServer >> > >> > private static GSMObject gsm; >> > >> > public GSMService() >> > { >> > gsm=new GSMObject(); >> > gsm.SMSReceoved+=new >> > GSMObject.GSMSMSEventHandler(gsm_SMSReceived); >> > .......... >> > } >> > } >> > >> > i has host the service in window form. The GSM object only be initial >> > when >> > the client make a first call. Is that possible when the host start i >> > can >> > initial the gsm object then waiting the client to connect to receive >> > the >> > incoming sms event? >> > >> > Thanks! >> >> >> |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: How to initialize object in WCF services Hi Arkady, thanks for the info, appreciate you can show me some sample code for this? i try debug the the application but the new ServiceHost(typeof(GSMService)) does not trigger constructor GSMService(). Thanks! "Arkady Frenkel" wrote: > What I meant when wrote : "R U sure ?" ( sorry forgot to put question mark ) > , that GSMObject instantiated when GSMService() constructor called and that > happen , not when client call the service method , but when you call > ServiceHost() on the service, which have to be done before client first > call, otherwise client just receive exception > Arkady > > "Elvin" <Elvin@discussions.microsoft.com> wrote in message > news:F1CA8FB6-3EB1-4E7E-AF3C-255E6092B8A8@microsoft.com... > > yes, because the service need to turn on the GSM device to retrieve the > > sms > > message to do something even no client is call or attend. Once have client > > make a call the subscribe the operation contract then service will publish > > the info to the client. > > The other reason, is the service also need to do other job when it receive > > incoming sms, so the service cant depend on the client to wake up! > > i have think the alternative solution is make a client call from the host > > for the first time, but i dont think is a better design. > > > > hopefully you can give me some advice. Thanks! > > > > "Arkady Frenkel" wrote: > > > >> R U sure. You constructor called when your call ServiceHost() in your > >> app , > >> and that have to be before first client's call > >> Arkady > >> > >> "Elvin" <Elvin@discussions.microsoft.com> wrote in message > >> news:3324C5D5-B5FA-4C8B-AA01-DCD7898FFA5D@microsoft.com... > >> > Hi, below is my sample WCF service coding > >> > > >> > [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, > >> > ConcurrencyMode=ConcurrencyMode.Single)] > >> > public class GSMService:IGSMServer > >> > > >> > private static GSMObject gsm; > >> > > >> > public GSMService() > >> > { > >> > gsm=new GSMObject(); > >> > gsm.SMSReceoved+=new > >> > GSMObject.GSMSMSEventHandler(gsm_SMSReceived); > >> > .......... > >> > } > >> > } > >> > > >> > i has host the service in window form. The GSM object only be initial > >> > when > >> > the client make a first call. Is that possible when the host start i > >> > can > >> > initial the gsm object then waiting the client to connect to receive > >> > the > >> > incoming sms event? > >> > > >> > Thanks! > >> > >> > >> > > > |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: How to initialize object in WCF services Oops, I was wrong. You can create such with calling some static method. Add such to the class and call it after new ServiceHost() Arkady "Elvin" <Elvin@discussions.microsoft.com> wrote in message news:19BC0F29-EB9F-4318-B753-5F6D3EE42ED0@microsoft.com... > Hi Arkady, > > thanks for the info, appreciate you can show me some sample code for this? > i try debug the the application but the new > ServiceHost(typeof(GSMService)) > does not trigger constructor GSMService(). > > Thanks! > > > "Arkady Frenkel" wrote: > >> What I meant when wrote : "R U sure ?" ( sorry forgot to put question >> mark ) >> , that GSMObject instantiated when GSMService() constructor called and >> that >> happen , not when client call the service method , but when you call >> ServiceHost() on the service, which have to be done before client first >> call, otherwise client just receive exception >> Arkady >> >> "Elvin" <Elvin@discussions.microsoft.com> wrote in message >> news:F1CA8FB6-3EB1-4E7E-AF3C-255E6092B8A8@microsoft.com... >> > yes, because the service need to turn on the GSM device to retrieve the >> > sms >> > message to do something even no client is call or attend. Once have >> > client >> > make a call the subscribe the operation contract then service will >> > publish >> > the info to the client. >> > The other reason, is the service also need to do other job when it >> > receive >> > incoming sms, so the service cant depend on the client to wake up! >> > i have think the alternative solution is make a client call from the >> > host >> > for the first time, but i dont think is a better design. >> > >> > hopefully you can give me some advice. Thanks! >> > >> > "Arkady Frenkel" wrote: >> > >> >> R U sure. You constructor called when your call ServiceHost() in your >> >> app , >> >> and that have to be before first client's call >> >> Arkady >> >> >> >> "Elvin" <Elvin@discussions.microsoft.com> wrote in message >> >> news:3324C5D5-B5FA-4C8B-AA01-DCD7898FFA5D@microsoft.com... >> >> > Hi, below is my sample WCF service coding >> >> > >> >> > [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, >> >> > ConcurrencyMode=ConcurrencyMode.Single)] >> >> > public class GSMService:IGSMServer >> >> > >> >> > private static GSMObject gsm; >> >> > >> >> > public GSMService() >> >> > { >> >> > gsm=new GSMObject(); >> >> > gsm.SMSReceoved+=new >> >> > GSMObject.GSMSMSEventHandler(gsm_SMSReceived); >> >> > .......... >> >> > } >> >> > } >> >> > >> >> > i has host the service in window form. The GSM object only be >> >> > initial >> >> > when >> >> > the client make a first call. Is that possible when the host start >> >> > i >> >> > can >> >> > initial the gsm object then waiting the client to connect to receive >> >> > the >> >> > incoming sms event? >> >> > >> >> > Thanks! >> >> >> >> >> >> >> >> >> |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: How to initialize object in WCF services Hi, you are right, change to static method will able to control from the host application, but all the related sub method also need to change to static as well. The alternative to initial the constructor when the host is start is change to InstanceContextMode.Single. Thanks! "Arkady Frenkel" wrote: > Oops, I was wrong. You can create such with calling some static method. Add > such to the class and call it after new ServiceHost() > Arkady > > > "Elvin" <Elvin@discussions.microsoft.com> wrote in message > news:19BC0F29-EB9F-4318-B753-5F6D3EE42ED0@microsoft.com... > > Hi Arkady, > > > > thanks for the info, appreciate you can show me some sample code for this? > > i try debug the the application but the new > > ServiceHost(typeof(GSMService)) > > does not trigger constructor GSMService(). > > > > Thanks! > > > > > > "Arkady Frenkel" wrote: > > > >> What I meant when wrote : "R U sure ?" ( sorry forgot to put question > >> mark ) > >> , that GSMObject instantiated when GSMService() constructor called and > >> that > >> happen , not when client call the service method , but when you call > >> ServiceHost() on the service, which have to be done before client first > >> call, otherwise client just receive exception > >> Arkady > >> > >> "Elvin" <Elvin@discussions.microsoft.com> wrote in message > >> news:F1CA8FB6-3EB1-4E7E-AF3C-255E6092B8A8@microsoft.com... > >> > yes, because the service need to turn on the GSM device to retrieve the > >> > sms > >> > message to do something even no client is call or attend. Once have > >> > client > >> > make a call the subscribe the operation contract then service will > >> > publish > >> > the info to the client. > >> > The other reason, is the service also need to do other job when it > >> > receive > >> > incoming sms, so the service cant depend on the client to wake up! > >> > i have think the alternative solution is make a client call from the > >> > host > >> > for the first time, but i dont think is a better design. > >> > > >> > hopefully you can give me some advice. Thanks! > >> > > >> > "Arkady Frenkel" wrote: > >> > > >> >> R U sure. You constructor called when your call ServiceHost() in your > >> >> app , > >> >> and that have to be before first client's call > >> >> Arkady > >> >> > >> >> "Elvin" <Elvin@discussions.microsoft.com> wrote in message > >> >> news:3324C5D5-B5FA-4C8B-AA01-DCD7898FFA5D@microsoft.com... > >> >> > Hi, below is my sample WCF service coding > >> >> > > >> >> > [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall, > >> >> > ConcurrencyMode=ConcurrencyMode.Single)] > >> >> > public class GSMService:IGSMServer > >> >> > > >> >> > private static GSMObject gsm; > >> >> > > >> >> > public GSMService() > >> >> > { > >> >> > gsm=new GSMObject(); > >> >> > gsm.SMSReceoved+=new > >> >> > GSMObject.GSMSMSEventHandler(gsm_SMSReceived); > >> >> > .......... > >> >> > } > >> >> > } > >> >> > > >> >> > i has host the service in window form. The GSM object only be > >> >> > initial > >> >> > when > >> >> > the client make a first call. Is that possible when the host start > >> >> > i > >> >> > can > >> >> > initial the gsm object then waiting the client to connect to receive > >> >> > the > >> >> > incoming sms event? > >> >> > > >> >> > Thanks! > >> >> > >> >> > >> >> > >> > >> > >> > > > |
My System Specs![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| datalist -- Object reference not set to an instance of an object. | Deere | .NET General | 0 | 08-31-2008 09:09 AM |
| Initialize Junk Mail Filtering and MSOE.DLL could not initialize | RainbowKid | Vista mail | 13 | 03-04-2008 11:36 PM |
| Cryptographic Services service failed to initialize... | Ex_Brit | Vista performance & maintenance | 0 | 08-18-2007 01:54 PM |
| Testing object arrays using Compare-Object and -contains | Alex K. Angelopoulos [MVP] | PowerShell | 2 | 08-31-2006 05:57 PM |
| Adding canonical aliases for Compare-Object, Measure-Object, New-Object | Alex K. Angelopoulos [MVP] | PowerShell | 2 | 05-26-2006 07:58 AM |