dotnet web sql business etc

26 серпня, 2011

Scripts to enable SQL Service Broker

Just recently a newcomer in our team could not get his windows service to work properly, and get messages from sql service broker queue. In the end it turned out that in the main database that was created from scratch, service broker appeared to be disabled. Here are some scripts to enable it:

alter database [mydatabase] set single_user with rollback immediate
alter database [mydatabase] set enable_broker
alter database [mydatabase] set multi_user with no_wait

Мітки: ,

12 серпня, 2011

The provider did not return a ProviderManifestToken string

I just have been going through ASP.NET MVC tutorial, step 5 (http://www.asp.net/mvc/tutorials/getting-started-with-mvc3-part5-cs), when I have ran into the "The provider did not return a ProviderManifestToken string" error when interacting with Entity Framework. When I tried to create a Controller specifying Model class  (Movie (MvcMovie.Model)) and Data Context Class (MovieDBContext (MvcMovie.Model)), Visual Studio gave an error "The provider did not return a ProviderManifestToken string". My connection string seemed fine:
 add name="MovieDBContext" connectionString="Server=.;database=movies;Integrated Security=SSPI;User Instance=true" providerName="System.Data.SqlClient"/>
<

Changing User Instance from true to false, solved the issue :). Why? I don't know, have not had time to investigate.

Мітки: ,

10 серпня, 2011

Install, uninsttall and kill a Windows Service

After having set up new build environment I decided to note some tips on working with Windows services, for myself to remember, and for others to easily find needed steps. So, off we go.

To install a Windows service (in a Windows 7 environment):
1) Copy service files (including the .exe) to the folder C:\MyService
2) Open command prompt as Administrator
3) cd to C:\MyService
4) Install Windows service from commant prompt using installutil.exe:
C:\MyService>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\installutil.exe /serviceName="My Service" MyService.exe

To uninstall a Windows service:
1)  Open command prompt as Administrator
2)  cd to C:\MyService
3)  c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /u  /serviceName="My Service" MyService.exe

Sometimes, it can happen that Windows Service can not be stopped. It remains in status Stopping, and never stops actually. Then you would have to kill it:
1)  Open command prompt as Administrator
2)  sc queryex MyService. You will receive the following information:

SERVICE_NAME: MyService
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0
        PID                : 4084
        FLAGS              :


3)  taskkill /F /PID 4084

Мітки: ,