Wednesday, December 25, 2013
The database could not be exclusively locked to perform the operation. (Microsoft SQL Server, Error: 5030)
First we will see how to set the database to single user mode,
ALTER DATABASE dbName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Now we will try to rename the database
ALTER DATABASE dbName MODIFY NAME = dbNewName
Finally we will set the database to Multiuser mode
ALTER DATABASE dbNewName
SET MULTI_USER WITH ROLLBACK IMMEDIATE
source :
http://weblogs.asp.net/varadam/archive/2012/08/10/the-database-could-not-be-exclusively-locked-to-perform-the-operation-microsoft-sql-server-error-5030.aspx
Wednesday, November 20, 2013
read only property and XmlSerializer
I had an issue serializing a class using the XmlSerializer, where the class had a collection property.
example:
public List<Employee> Subordinates { get; private set; }
if the property setter was public then everything works fine and the property serialized .
but if the property has a private setter then the following exception is thrown
Unable to generate a temporary class (result=1). error CS0200: Property or indexer '[namespace].Subordinates' cannot be assigned to -- it is read only
The problem was that the class exposed the collection property as a readonly property, but the XmlSerializer needs the property to be read/write access
so the solution is to make the property with public setter as follows
public List<Employee> Subordinates { get; set; }
example:
public List<Employee> Subordinates { get; private set; }
if the property setter was public then everything works fine and the property serialized .
but if the property has a private setter then the following exception is thrown
Unable to generate a temporary class (result=1). error CS0200: Property or indexer '[namespace].Subordinates' cannot be assigned to -- it is read only
The problem was that the class exposed the collection property as a readonly property, but the XmlSerializer needs the property to be read/write access
so the solution is to make the property with public setter as follows
public List<Employee> Subordinates { get; set; }
Monday, January 7, 2013
Give user acess to a certification
When your application use certification and you have a
windows service, and you set the user of
the windows service to be for example Network Service to be able to access
resources on network by the windows service , you may get the following
exception
It is likely that certificate 'CN=XX' may not have a private
key that is capable of key exchange or the process may not have access rights
for the private key. Please see inner exception for detail. Keyset does not
exist
That mean the Network
Service account have no access for the certification
Then You have to give authority for the Network Service
account to access your certification
Then you can use WinHttpCertCfg
WinHttpCertCfg.exe -g -c LOCAL_MACHINE\MY -s "IssuedToName"
-a "AccountName"
Note AccountName is the name of a local computer account or a domain account. IssuedToName
is the name of the company or domain to which the client certificate was
issued.
Reference
Tuesday, November 27, 2012
Read Telerik drop downlist javascript
sometimes we need to read the value/text of a Telerik MVC dropDownList items.
using JQUERY:
function getData()
{
}
Note :
you have to read " $(
using JQUERY:
function getData()
{
var items= $('#dropdownlistName).data('tDropDownList').data;
// items is the items list
// items can be dealt as an array
// then we can get the text and the value of each item as following:
var text = items[0].Text;
var value = items[0].Value;
Note :
you have to read " $(
'#dropdownlistName) " after document.read() function as we have to wait for the Telerik JQuery library to be loaded.it is preferred to be read pageLoad function of the Microsoft.Ajax libraryfunction pageLoad(){ getData()}or at any event handler javascript function
Wednesday, November 14, 2012
certification under Network Service account
When your application use certification and you have a windows
service, and you set the user of the
windows service to be for example Network Service to be able to access
resources on network by the windows service , you may get the following
exception
It is likely that certificate 'CN=XX' may not have a private
key that is capable of key exchange or the process may not have access rights
for the private key. Please see inner exception for detail. Keyset does not
exist
That mean the Network
Service account have no access for the certification
Then You have to give authority for the Network Service
account to access your certification
Then you can use WinHttpCertCfg
WinHttpCertCfg.exe -g -c LOCAL_MACHINE\MY -s "MyCompany"
-a "NetworkService"
Reference
Wednesday, August 8, 2012
WIX..enforce overwrite files & more
If user had installed a product before and want to uninstall to reinstall same version but new build
sometimes the user need to delete the files manually from the installaton directory
so it is better for the product to force reinstallation for all the files , registry keys and others to avoid user undeletion
WIX support this by adding the follwing property to the Main fragment of the WIX project
<Property Id="REINSTALLMODE" Value="amus"/>
which mean:
a - Force all files to be reinstalled, regardless of version.
m - Rewrite all registry keys that go to HKEY_LOCAL_MACHINE or HKEY_CLASSES_ROOT.
u - Rewrite all registry keys that go to HKEY_CURRENT_USER or HKEY_USERS.
s - Reinstall shortcuts and icons.
Sunday, May 6, 2012
Ajax Autocomplete extender doesnt retrieve data on IIS
when building asp.net website with start option set to "IIS" and test an autocomplete extender that retrieve data using a webservice , it doesnt retrieve data
using "Fiddler" to catch the error , it gets
System.InvalidOperationException: Request format is invalid: application/json; charset=utf-8.
at System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()
solution :
at the web.config file =>system.webserver => handlers => add these lines
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Subscribe to:
Posts (Atom)