niedziela, 23 sierpnia 2009

Drop User: The database principal owns a schema in the database, and cannot be dropped

Dropping a user which owns a schema will result in the error message “The database principal owns a schema in the database, and cannot be dropped”.

To solve this you can assign the schema back to its base principal with the ALTER AUTHORIZATION message, or it can be moved to another user/principal.
If for example user Test1 owns the db_owner schema and you want to drop Test1 but don’t have another user to move the schema to you can type:

ALTER AUTHORIZATION ON SCHEMA::db_owner TO db_owner
(or for example db_datawriter if that was the case and so on)

If you wanted to move the schema to another user the syntax would be:

ALTER AUTHORIZATION ON SCHEMA:: TO userName

czwartek, 11 czerwca 2009

Create and Install Temporary Certificates in WCF

You can find full article here

Most important parts:
1) Create a Certificate to Act as Your Root Certificate Authority

makecert -n "CN=RootCATest" -r -sv RootCATest.pvk RootCATest.cer

2) Create and Install Your Temporary Service Certificate

makecert -sk MyKeyName -iv RootCATest.pvk -n "CN=tempCert" -ic RootCATest.cer -sr localmachine -ss my -sky exchange -pe tempCert.cer

3) In Client config set RevocationMode to "NoCheck"

<behaviors>
<endpointBehaviors>
<behavior name="NewBehavior">
<clientCredentials>
<serviceCertificate>
<authentication *revocationMode="NoCheck" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<client>
<endpoint behaviorConfiguration="NewBehavior" ….>
</endpoint>
</client>

wtorek, 9 czerwca 2009

"Add Service Reference" 16384 quota

If you got a problem with adding large WCF service into your Visual Studio sollution via "Add Service Reference" you can use following sollution.

You need to edit devenv.exe.config (default located in c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\) and add larger quota info to IMetadataExchange binding. This configuration will be used by VS and it is used for netTcpBinding.

<configuration>
.
.
.
<system.serviceModel>
<client>
<endpoint name="net.tcp" binding="netTcpBinding" bindingConfiguration="bc" contract="IMetadataExchange" />
</client>
<bindings>
<netTcpBinding>
<binding name="bc" maxReceivedMessageSize="512000">
<readerQuotas maxNameTableCharCount="163840" />
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
.
.
.
</configuration>

poniedziałek, 4 maja 2009

Finding objects in Generics with List.Find()

Simple class:

public class Person
{
   public int ID { get; set; }
   public int Name { get; set; }

   public Person(int id, string name)
   {
      ID = id;
      Name = name;
   }
}

Usage code:

//Add some objects
List myList = new List();
myList.Add(new Person(1, "Person 1"));
myList.Add(new Person(2, "Person 2"));
myList.Add(new Person(3, "Person 3"));

//Find a specific object
Person myLocatedObject = myList.Find(delegate(Person p) {return p.ID == 1; });


Thanks Andrey for good example (original article)