Are there any known issues when using CSLA in a Windows Service? I created a new Windows Service and made a project reference to my existing CSLA business objects. I continue to get a DataPortal.Fetch error. I hard coded the connection string in the object just to verify it was not an issue with the app.config. Am I missing something obvious? Any help would be greatly appreciated.
As you know debugging a windows service is not easy. I wrapped the script in a try catch and had it email me the exception. The exception is the basic DataPortal.Fetch Failed error. I have tested the object in other projects and it works as expected.
The service is using the same connection string as the web project, so I am not sure how the permissions would be denied from the service.
I have tried LOCAL SERVICE and LOCAL SYSTEM as the Account and both have the same result. I also tried USER and supplied the Administrator login information, but it failed to install. At this point I don't know what else to try. Any ideas?
Check out the details of the DataPortalException. The DataPortalException.BusinessException will give you more details.
Mike
Thanks that was very helpful. It appears that my service is attempting to reference my business object from the development server. When I made the references in the Windows Service project to my BO class library I set Copy :Local = True. Do I need to make each DLL an Embedded Resource for this to work?
It would seem to me that if Copy Local = True that this would be incorporated into the service. Am I missing something here?
Ok. Thanks for your help. After a half day of trial and error and a little research I found the problem. I will explain in case any other novice windows service developers have the same problem.
1. By default the Windows Service does not include System.Configuration. Make a reference and you should be good. CSLA uses the following as a function to return the database name from your app.config file:
ConfigurationManager.AppSettings("DB:" & DatabaseName)
And this function requires System.Configuration. Make sure you have all the other necessary references as well.
2. You need to copy your app.config file and place it in the bin directory. You should rename it XXXXX.exe.config where XXXXX is the name of your service.
rbellow:As you know debugging a windows service is not easy.
It's actually not that hard. You just start the service and use Debug -> Attach to process from the menu. The only challenge really is having enough delay in the service so you can attach to it fast enough to catch the bug. :)
Copyright (c) Marimer LLC