Monday, December 27, 2010

XCode, A valid provisioning profile for this executable was not found. When you try to Build and Run Ipad/Iphone App to devices

I just create one HelloIpad application in Xcode. and connect my IPAD to the PC and run the auto provisioning step to add one Device to the team provision profile managed by Xcode. all works good. When I try to build and run on the IPAD, Get the following strange error.

A valid provisioning profile for this executable was not found.


Then I checked the Device Console Log [ Device->console tab]

Mon Dec 27 09:38:47 DVDs-iPad installd[361] <Error>: 2ff66000 verify_signer_identity: Could not copy validate signature: -402620395
Mon Dec 27 09:38:47 DVDs-iPad installd[361] <Error>: 2ff66000 preflight_application_install: Could not verify executable at /var/tmp/install_staging.LpTPGN/
Mon Dec 27 09:38:47 DVDs-iPad installd[361] <Error>: 2ff66000 install_application: Could not preflight application install
Mon Dec 27 09:38:47 DVDs-iPad mobile_installation_proxy[364] <Error>: handle_install: Installation failed
Mon Dec 27 09:38:47 DVDs-iPad installd[361] <Error>: 2ff66000 handle_install: API failed
Mon Dec 27 09:38:47 DVDs-iPad installd[361] <Error>: 2ff66000 send_message: failed to send mach message of 71 bytes: 10000003
Mon Dec 27 09:38:47 DVDs-iPad installd[361] <Error>: 2ff66000 send_error: Could not send error response to client

the profile is for sure correct [ Means the profile contains the device UUID, Also you can tell from the device itself, Setting->general->profiles]

When you check the .app contents, the embeddedprofile is there too. that’s the same one you downloaded from dev protal.

So there are must be something wrong with the profile, what’s those potential dependency?

the answer is Certificate/Keys. I use a wrong keys/certificate to sign the application. ( that means the Cert to sigh the profile is different with the key in your keychain.)

So make sure 

the cert to create Profile is the same with your keychain. you can tell from their expiration date. otherwise, you get this annoying error.

Or just jailbreak you device, then you can install any app without have to follow the signature enforcement policy.

Tuesday, December 21, 2010

XCode, error: There is no SDK with the name or path 'iphoneos4.2'

When I try to compile one project , get the No SDK error. 
Here, I don't have to use the latest SDK 4.2, Just click Project->Edit Project settings, Build tab,Chose the version I want to use.

Thursday, December 16, 2010

eclipse OUTOfMemoryError

Eclipse is one Great and Free JAVA IDE, the only problem is that it keep crashing compared with other commercial IDE. 
Since eclipse is one standard java applicaton, so out of memory problem could be caused by wrong settings. Here is one error I get recently


Click details, to get more information.


PermGen Space, PermGen is one special Heap area to keep classes , metadata, etc.
Run JvisualVM, Click and open the eclipse JVM.


Here the max space for Perm is 64M, we used 63.998M now. that’s the perm space problem.

How to fix that, just like other XX jvm parameters, put a more big size limitation for perm to the eclipse.ini which is located in the eclipse folder.


profile the jvm again, the space get more quota now.


Wednesday, December 8, 2010

How to purge Squid /varnish stale/outdated pages programmatically

>>>For SQUID, you need to enable the Purge Request for IP and Send a Request to the Squid server using the PURGE http method.

squid.conf, enable Purge request from a given devices.

acl localnetwork
http_access allow PURGE localnetwork

you can use squidclient utility
squidclient -m Purge http://squidserver:2128/foo.html

Here is one C# code snippet.

string url = http://squidserver:3128/fooo.html;
//Squid IP: Port 
WebRequest req = HttpWebRequest.Create(url);
req.Method = "PURGE";
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
if (resp.StatusCode == HttpStatusCode.OK)
Console.WriteLine("PURGE Sucessful");
Console.WriteLine("PURGE Failed");
catch (WebException ex)
Console.WriteLine("PURGE Failed" + ex.Message);

>>> Varnish , two ways.
option 1, send the purge directive from the admin console. (when you start the varnishd, add one –T for the admin port, i,e 7777)  varnishd –a –T –f  youvcl.vcl

then telnet to the 7777 admin port, enter “purge req.url ~ foo.html” , this will put a switch mark for all url matching the expression foo.htm

also, this process can be implemented in the C# code.

string url = "fooo.html"; //URL regular expression
TcpClient t = new TcpClient();
t.Connect("varnishserver", 7777); //varnish admin port
NetworkStream ns = t.GetStream();
StreamReader sr = new StreamReader(ns);
System.Threading.ManualResetEvent mre = new ManualResetEvent(false);
new Thread(
                (object obj) =>
while (true)
if (ns.DataAvailable)
if (mre.WaitOne(TimeSpan.FromSeconds(3)) == true)
StreamWriter sw = new StreamWriter(ns);
sw.Write("purge req.url ~ " + url + sw.NewLine);

Option 2, put a logic in the recv VCL, intercept the PURGE method and call the purge method.

sub vcl_recv {
        if (req.request == "PURGE") {
                if (!client.ip ~ purge) {
                        error 405 "Not allowed.";
                purge("req.url == " req.url );
                error 200 "Purged.";

the code is the same like the squid options.

troubleshooting the driver disconnecting while associating, dot11 status code 0

One Day, My laptop can’t connect to any WIFI at company, but it works at home. the symptom is that the wifi keep connecting  but never be successful. Check the event log, get some error like

the driver disconnecting while associating, dot11 status code 0 

then I update the driver to the latest version, that’s a Intel nic, so installed the manual diagnostics toolkit as well. and run a basic test.  it failed on the association phase.


When I run “netsh wlan show all”, I could see all the AP and their SSid. so basic communication is fine.
then I realized that the AP just blocked my MAC.  reset the AP or change the MAC address of the NIC is the workout.

Can Macbook support 8G RAM, yes! at least for snow leopard

During the holiday shopping season, I couldn't resist the RAM deal  of getting one 2*4G DDR3 set for 90 bucks. then replace the original 2*2G set and power on, the Mac just works without any problem for a week now.

so the spec on is incorrect, it says it could support Max 4G ram. here is the spec in

“2GB (two 1GB SO-DIMMs) of 1066MHz DDR3 SDRAM; two SO-DIMM slots support up to 4GB”

My hardware spec, the late-2008 version. And I wrote a simple java to reserve more RAM over 4G, it works


the spec,

Model Name:    MacBook
  Model Identifier:    MacBook5,1
  Processor Name:    Intel Core 2 Duo
  Processor Speed:    2.4 GHz
  Number Of Processors:    1
  Total Number Of Cores:    2
  L2 Cache:    3 MB
  Memory:    8 GB
  Bus Speed:    1.07 GHz
  Boot ROM Version:    MB51.007D.B03

Tuesday, November 30, 2010

Online Retailers, 7 of 10 Didn’t protect their Customer information in a secure way/ Password reset page

From the error page design rules 101 , we should only tell the audience general error information instead of the detailed information which will tell something to hacks about your system. 
Now it’s holiday season, I get a chance to visit several E-commerce sites which I didn’t visit very often. then for some site, I forgot the password, luckily, every site has the password reset options. unfortunately, 7 of 10 sites didn’t secure the user information correctly. I will give some examples. good and bad ones. 

my of my favorite  sites,  when you input an email address , It will tell you immediately whether that email is a HPshooping customer or not. this process is not protected by any sort of CAPTCHA authentication , AND could be scripted as part of the spam campaign or targeted fishing. idea is very simple, go through the email db which has a lot junk addresses, and filter out those valid HPshooping customers, then send targeted fishing email.

bad example, HP shooping.

same thing for
image, no luck,

Some good example. when you input an email address whether it’s valid customer or not, just tell you a general information. it it’s true, you will the password reset notification.



that’s sweet design.  from the perspective of security, it’s secure. for user convenience. secure too. no extra steps required.

Also some good examples, that might cause some  inconvenience which need extract step to identity and key in the CAPTCHA code., for regular good user, they know whether the account is good or not immediately, but have to pass the CAPTCHA test. However, it’s SECURE.


Newegg has the similar approach. it combined Amazon and Apple design, which is the most secure one. It requires CAPTCHA and tells only general information.


Tuesday, November 23, 2010

How To: MySql replication between two clusters. capture data changes

Here , I just setup two VMs and following tutorial Installing and testing Mysql NDB Cluster on Centos Tutorial. On each Server, there is one NDB cluster with one API Node and two Data Nodes and one mgmt node.
  before we kick off the replication, first make sure the /etc/hosts file has the right entry for both Hosts. Otherwise you may get the error in mysql like no access.

101123  5:55:16 [Warning] IP address '' could not be resolved: getnameinfo() returned error (code: -3).
101123  5:55:56 [Warning] IP address '' could not be resolved: getnameinfo() returned error (code: -3).

Configuration changes on HOST Master.

On HostA mysql instance, create one user that will be used by slave server hostb to pull the replication information.

GRANT REPLICATION SLAVE ON *.* TO 'repluser'@'hostb' IDENTIFIED BY 'pass';

Chagne the /etc/my.cnf , add options to enable binlog logging on row level, and assign one server-id.


backup the db using the mysql dump and copy to Slave server for the initial restore. (ALL DB objects will be covered in the mysqldump , like view , storeprocedue)

mysqldump –u root yourdatabase –master-data=1> ini.sql

Restart the Master mysqld daemon. that’s all the  changes.

Configuration changes on HOST Slave Server.

Assign one explicit server-id in the my.cnf


restore the db from the master backup

mysql –u root ourdatabase<init.sql

Change the master to the appropriate host.


start the slave service>.
slave start


Now any change will be synced to slave server.

if you have any problem to sync the data. always check the /usr/local/mysql/data/yourhostname.err

there are some system tables to maintain the binlog and replication status.

for example, in the master server mysqld which we enable the binarylog.
you can always query mysql.ndb_binlog_index.


here we have two log entries which represent two update in my case. If we want to replay the first one  in slave server. just stop the slave replication and change the master log file position.
here the log will be replayed and duplicate record will inserted into the table.

If we just want to capture Master change and push the change to other db store besides mysql.

we can change the slave server table engine to blackhole, which will never store any data.  then turn on the query logging.
now all changes on master data will be pushed to slave server , we can tell the change from the query log.

Monday, November 22, 2010

VMware player can’t open OVF file

When you get an OVF format VM image, you can’t open it with Vmware player directly. lucky there is a way to conver ovf VM image to VMX format.

Download the OVFTool from Vmware.

then run the ovftool to convert the image. here is the syntax

Ovftool c:\vm\myvm.ovf  c:\vm\vmxvm

Tuesday, November 16, 2010

How to : Installing and testing Mysql NDB Cluster on Centos Tutorial

AS I mentioned in How to Create a Mysql NDB cluster on a PC, windows 7 tutorial, It requires the same prerequisites to run a simple NDB cluster. I will go over a tutorial to create a one Mgmt node, Two storage Node One Api Node clusters in one single Centos instance.

Download the Linux version of Mysql cluster community edition which is free to use . 
Unzip it and copy the folder to /usr/local/mysql, here you may copy to a folder like /usr/local/mysql_xxx where xxx is the edition, then put a link named mysql to that folder.


tar -zxvf mysql-cluster-gpl-7.1.8-linux-x86_64-glibc23.tar.gz

#unzip it

cp -r mysql-cluster-gpl-7.1.8-linux-x86_64-glibc23 /usr/local/

ln -s /usr/local/mysql-cluster-gpl-7.1.8-linux-x86_64-glibc23/  /usr/local/mysql

Create a user named mysql.

useradd mysql

setup the Mysql service.

cd /usr/local/mysql

# you must be in this folder to run the install script
once done, copy the demon script
cp support-files/mysql.server  /etc/init.d/mysql
chown -R mysql:mysql /usr/local/mysql/data

Now you can run service  mysql start to startup a regular mysql service.


Time to create a NDB config ini, there are some templates file like config-xxx.ini in the support-files directory, just copy and paste. and change the nodes per you requirement.
I will put a config file in /ndb/config.ini
and put all NDB data into /ndb/folder

mkdir /ndb
cp /usr/local/mysql/support-files/config.medium.ini /ndb/config.ini

then change the config.ini just created as the following content.

NoOfReplicas: 2
DataDir: /ndb

PortNumber: 1186
DataDir: /ndb

Id: 1

Id: 2
Id: 3
Id: 4

after saving the chagnes to /ndb/config.init, run a commant ndb_mgmtd –f /ndb/config.ini –-ini to initialize the ndb folder

cd /usr/local/mysql/bin
./ndb_mgmd -f /ndb/config.ini  --init

Only mgmt node is active in this cluster now.

run ./ndb twice to start Two  NDB Data Nodes.

run the show in ndb_mgm to refersh the status. Two data ndoes are back.

one more step left, change the mysqld API Node to point to ndb cluster ( ask it to pickup the ndb engine and ndb node configuration.  all it need is the connectiong to ndb mgm node, node will push all information to API nodes.)

Create one file in /etc/my.cnf as content below.


restart the mysql service. API node is On now


let’s run a helloworld test.

Now you can run several utility to make sure the data is distributed to two NDB data nodes evenly.

ndb_desc –d hello foo -p

here two partitions, one has two records, one has one record.


run ndb_mgm, all report memory

Wednesday, November 10, 2010

How To : installing and testing greenplum single node edition on Centos 5.5

Download the single node edition, Here I use the version 4.0 for redhat /centos , greenplum-db-

check OS version,

[root@localhost Desktop]# cat /etc/redhat-release
CentOS release 5.5 (Final)

if you run the installer on unmatched version of centos, will get an error, “Installer will only install on RedHat/CentOS x86_64”
here run Uname –m, It will tell the hardware spec, 386 or x86_64.

[root@localhost ~]# uname -m

run the installer directly.

[root@localhost Desktop]# ./greenplum-db-
make sure you have the execute permission. If not, run
chmod 722 greenplum-db-

read and accept the agreement,
by default the bits will be put into folder /usr/local/greenplum-version.  Enter yes to accept the default settings. like folder path, once done. you will get the message like


source /usr/local/greenplum-db-

Create a dedicated user to run the process , and folders to hold segments and maser data. given user the folder access permission.

Here we will create a user named gp
Create a maser folder /data/master
Create 4 segment folders /data/seg1, /data/seg2,/data/seg3/,/data/seg4
Change ownership folder of /data/* to gp

Copy one instance from the sample config and change the setting like folder path , listen port.

cd /usr/local/greenplum-db-
[root@localhost cli_help]# cp gp_init_singlenode_example /home/gp/
[root@localhost cli_help]# cp single_hostlist_example /home/gp/
[root@localhost cli_help]#

Switch to user gp, go to home foder, then change two files we just copied here.

gp_init_singlenode_example content change.


declare -a DATA_DIRECTORY=(/data/seg1 /data/seg2 /data/seg3 /data/seg4)
#four segment folders

#master diferctory

Initialize the system. (create folders and start up several postgres processes.)

[gp@localhost ~]$ gpssh-exkeys -f single_hostlist_example

gpinitsystem -c gp_init_singlenode_example

once done, when you run ps -aux|grep /data/, you will see 5 postgresq processes here, one master , four segment instances.


Now the single Node cluster is ready, we can use the psql to connect to the instance and have some fun.

Create one test database
CreateDB androidtest

psql (8.2.14)
Type "help" for help.

androidtestdb=# Create table public.test( id int primary key, state varchar(30) not null);
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" for table "test"
androidtestdb=# \d+ public.test;
                   Table "public.test"
Column |         Type          | Modifiers | Description
id     | integer               | not null  |
state  | character varying(30) | not null  |
    "test_pkey" PRIMARY KEY, btree (id)
Has OIDs: no
Distributed by: (id)

Now we just created one table test which is disturbed by id. which means if we put more data, the data will be distributed and dispatched to different segments by column iD.  let’s run a simple sql.

insert into public.test values (1,'AL') ,(2,'AK') ,(3,'AS') ,(4,'AZ') ,(5,'AR') ,(6,'CA') ,(7,'CO') ,(8,'CT') ,(9,'DE') ,(10,'DC') ,(11,'FM') ,(12,'FL') ,(13,'GA') ,(14,'GU') ,(15,'HI') ,(16,'ID') ,(17,'IL') ,(18,'IN') ,(19,'IA') ,(20,'KS') ,(21,'KY') ,(22,'LA') ,(23,'ME') ,(24,'MH') ,(25,'MD') ,(26,'MA') ,(27,'MI') ,(28,'MN') ,(29,'MS') ,(30,'MO') ,(31,'MT') ,(32,'NE') ,(33,'NV') ,(34,'nh') ,(35,'NJ') ,(36,'NM') ,(37,'NY') ,(38,'NC') ,(39,'ND') ,(40,'MP') ,(41,'OH') ,(42,'OK') ,(43,'OR') ,(44,'PW') ,(45,'PA') ,(46,'PR') ,(47,'RI') ,(48,'SC') ,(49,'SD') ,(50,'TN') ,(51,'TX') ,(52,'UT') ,(53,'VT') ,(54,'VI') ,(55,'VA') ,(56,'WA') ,(57,'WV') ,(58,'WI') ,(59,'WY') ;

How can we tell whether the data are distributed across segments evenly.
in each table, there is one system column called gp_segment_id

select gp_segment_id, id, state from public.test;

gp_segment_id | id | state
             3 |  2 | AK
             3 |  6 | CA
             3 | 10 | DC
             3 | 14 | GU
             3 | 18 | IN
             3 | 22 | LA
             3 | 26 | MA

you can run a basic group query

androidtestdb=# select gp_segment_id, count(*) from public.test group by gp_segment_id;
gp_segment_id | count
             3 |    15
             0 |    15
             1 |    14
             2 |    15

   data is evenly distributed across four segments.

also you can run a analyze to tell the execution plan. which will also tell you the segments scan are handled in a parallel way.

androidtestdb=# EXPLAIN  select * from public.test;
                                 QUERY PLAN
 Gather Motion 4:1  (slice1; segments: 4)  (cost=0.00..4.59 rows=15 width=7)
   ->  Seq Scan on test  (cost=0.00..4.59 rows=15 width=7)
(2 rows)

EXPLAIN analyze  select * from public.test;
                                                   QUERY PLAN                             
Gather Motion 4:1  (slice1; segments: 4)  (cost=0.00..4.59 rows=15 width=7)
   Rows out:  59 rows at destination with 0.515 ms to first row, 1.215 ms to end.
   ->  Seq Scan on test  (cost=0.00..4.59 rows=15 width=7)
         Rows out:  Avg 14.8 rows x 4 workers.  Max 15 rows (seg0) with 0.026 ms to first row, 0.029 ms to end.
Slice statistics:
   (slice0)    Executor memory: 139K bytes.
   (slice1)    Executor memory: 155K bytes avg x 4 workers, 155K bytes max (seg0).
Total runtime: 2.038 ms
(8 rows)

Tuesday, November 9, 2010

Windows: Start or Stop a Service on remote server using wmic

WMIC has been a built-in command since XP as a interface to WMI operations. Here is a basic task , stop or start the windows service on remote server.

Run WMIC on command prompt, or Run box.

By default, the WMIC connect to local WMI service. If you want to connect to a remote Node.

/Node:yourremote Server
enter you password.

When you run /? , you will be able to see all the built-in Objects that you can interact with.


Service List, it will show you all services installed on the server

If you want to list only those service a running, and list the name caption only (like the sql projection syntax. )

service where state=”running” get name, caption, status

get a specified service status, like iisadmin


If you want to control the service, like stop the service or restart the service. 

to list all the operation on the service ,
Service where name=”iisadmin” call

the same approach applies to the process management.

process where name=”notepad.exe” call terminate
close the notepad.exe process
to shutdown the server
terminate the winlogon.exe

Also you can use PSexec to run process on the remote server directly.

Monday, November 8, 2010

yum updates through Microsoft ISA proxy which needs NTLM authentication /NTLM Authorization Proxy Server HTTP Error 407: Proxy Authentication Required

If you have a Centos VM or any other VM that need access internet to update or download some bits. And the Host machine is behind the ISA proxy which is NTLM authentication enabled.  Here is the basic Idea to make the guest OS can access the internet without having the Authentication problem.

for some security reason, IT admin might disabled the Basic authentication for ISA access. If you use YUM and have to pass the proxy. Yum only support Basic authentication. so there is the problem. if you put one ISA proxy into /etc/yum.conf like proxy=http://youproxyserver:port and run yum update, you will get 407 error which means authentication failed. even you put the username password into the config. (why? proxy server only accept ntlm authentication)

login as: root
root@'s password:
Last login: Fri Nov  5 02:25:34 2010
[root@linuxserver ~]# vi /etc/yum.conf
[root@linuxserver ~]# cls
[root@linuxserver ~]# yum update kernel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base:
* updates:
* addons:
* extras: [Errno 14] HTTP Error 407: Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied.  )

answer, install one NTLM Authorization Proxy Server on Host or guest OS. (the  APS is python based, run anywhere that has python.) 'NTLM Authorization Proxy Server' (APS) is a proxy software that allows you to authenticate via an MS Proxy Server using the proprietary NTLM protocol. then change the yum.config to use the new proxy server which is anonymous.

more steps,
Download and Install Python
Download and install NTLM Authorization Proxy Server

Change the server.cfg,  here is the key change

Accept:text/html, application/xhtml+xml, */*

User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; MS-RTC LM 8)


NTLM_FLAGS: 07820000

Then startup the proxy utility ntlmaps-\runserver.bat

Now change the yum.conf to the new proxy ISA01, Yum works now.

for Other http client like Wget, you need Export http_proxy=http://yourproxy:port



Friday, November 5, 2010

CustomBinding binaryMessageEncoding error, Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

this is an Issue about the WCF Bindings. By default, if you use wshttpbinding or httpbinding, The http channel will use the Text based encoding which is not very efficient in terms of the network transfer.  however, you can combine one custombing, just pick up the binaryencoding which is been used by tcpbinding, and httptransfer as the transport channel.

you can create one customBinding like this,

       <binding name="csbinding">




if the service is hosted in IIS, and the anonymous access for this folder has been turned off.  you may get the follow error when you try to access the svc. even just the wsdl access.

erver Error in '/DemoWCF' Application.

Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NotSupportedException: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.]
System.ServiceModel.Channels.HttpChannelListener.ApplyHostedContext(VirtualPathExtension virtualPathExtension, Boolean isMetadataListener) +11449553
System.ServiceModel.Activation.VirtualPathExtension.ApplyHostedContext(TransportChannelListener listener, BindingContext context) +75
System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener(BindingContext context) +119
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener() +66
System.ServiceModel.Channels.MessageEncodingBindingElement.InternalBuildChannelListener(BindingContext context) +67
System.ServiceModel.Channels.BinaryMessageEncodingBindingElement.BuildChannelListener(BindingContext context) +46
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener() +66
System.ServiceModel.Channels.Binding.BuildChannelListener(Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters) +124
System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession) +337
System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result) +647
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +1364
System.ServiceModel.ServiceHostBase.InitializeRuntime() +37
System.ServiceModel.ServiceHostBase.OnBeginOpen() +27
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +49
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +261
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +121
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +479

[ServiceActivationException: The service '/DemoWCF/Service.svc' cannot be activated due to an exception during compilation. The exception message is: Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service..]
System.ServiceModel.AsyncResult.End(IAsyncResult result) +11527290
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +194
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +176
System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +278
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +68
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

for the fix. just right click the .svc file in IIS and enable the anonymous access.

Tutorial , Firebug , Free Commercial IE httpwatch alternative

HttpWatch is a great Commercial Tool to capture the Http traffic, enable admin to do the user end http analysis. like check the Cache is correct, client did get the Gzip version response. If you are looking for a free alternative.  FireBug for fixfox is my top choice.  Here is a basic tutorial one Firebug.

Install Firebug on Firefox.
Click tools->add-ons, search firebug. click to install the add-on and restart firefox.


After loaded the firebug, Open Firefox, press F12 or click add-ons to turn it on.

View the Http Request /Response Header. Click the dropdown arrow to enable the traffic capturing.

When you access Wikipedia mainpage,, you will see the resource get requested to web servers. and the timeline.


click one url , i.e the first one. you can tell the server is apache, the wiki used Cache heavily. here the cache could be squid or varnish.  the we do get the gzip version response.

scroll down, you can see the request header the firefox is sending out.

If you press Shift and click the refersh in firefox. you will see that the firefox tell the edge server to reload th request and never pickup the cached version.

in the HTML tab, click the pointer to a object like the logo here., you can see the img url and css styles.

Tuesday, October 26, 2010 mvc, CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

after I located the Entity framework connection string, Unable to load the specified metadata resource. continued reading the professional mvc 2 to page 48. When I try to run the details page. /controller/details/validid
get the following error,

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0012: The type 'System.Data.Objects.DataClasses.EntityObject' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Source Error:

Line 170:
Line 171: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 172: public class views_dinners_details_aspx : System.Web.Mvc.ViewPage<LADinner.Models.Dinner>, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Line 173:
Line 174: private static bool @__initialized;

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.0.cs    Line: 172
the stack trace shows when runtime try to compile the .aspx page using the csc.exe, missed one assembly reference System.Data.Entity.

then I click the detailed compiler output  , I get the following outputs. and Highlighted the System.Data.X assemblies. the error is right, there is no reference to System.Data.Entity.

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_global.asax.4lhx-qfz.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_3rrpychx.dll"
/R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\assembly\dl3\452a723b\f0bfe800_2e75cb01\NerdDinner.DLL"
/R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Routing\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Routing.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701 /warnaserror-  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\f41f3cb9\3196a0b\App_Web_details.aspx.32d6c807.yjqx_sl8.1.cs"
Then I did some research. Though we added the assembly System.Data.Entity into our project. which means that those assembly are only for Runtime reference. For Compile time reference, We have to add the reference to System.web/Compilation/Assemblies in web.config, then the csc will pick up this settings


<compilation debug="true" targetFramework="4.0">
<add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Abstractions, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>

Monday, October 25, 2010

Troubleshooting Entity framework connection string, Unable to load the specified metadata resource.

I was reading the Book called Professional MVC 2 , following the tutorial to Page 44.

When I run the application, /Details/id, which will invoke the Entity framework to do a DB query. No luck, get an strange error.

Line 37:         /// Initializes a new nerdDinnerEntities object using the connection string found in the 'nerdDinnerEntities' section of the application configuration file.
Line 38:         /// </summary>
Line 39:         public nerdDinnerEntities() : base("name=nerdDinnerEntities", "nerdDinnerEntities")
Line 40:         {
Line 41:             this.ContextOptions.LazyLoadingEnabled = true;

[MetadataException: Unable to load the specified metadata resource.]
   System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources(String assemblyName, String resourceName, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) +2490148
   System.Data.Metadata.Edm.MetadataArtifactLoaderCompositeResource.CreateResourceLoader(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) +170
   System.Data.Metadata.Edm.MetadataArtifactLoader.Create(String path, ExtensionCheck extensionCheck, String validExtension, ICollection`1 uriRegistry, MetadataArtifactAssemblyResolver resolver) +8517824
   System.Data.Metadata.Edm.MetadataCache.SplitPaths(String paths) +271
   System.Data.Common.Utils.<>c__DisplayClass2.<Evaluate>b__0() +19
   System.Data.Common.Utils.Result.GetValue() +100
   System.Data.Common.Utils.Memoizer`2.Evaluate(TArg arg) +181
   System.Data.EntityClient.EntityConnection.GetMetadataWorkspace(Boolean initializeAllCollections) +292
   System.Data.Objects.ObjectContext.RetrieveMetadataWorkspaceFromConnection() +29
   System.Data.Objects.ObjectContext..ctor(EntityConnection connection, Boolean isConnectionConstructor) +205
   System.Data.Objects.ObjectContext..ctor(String connectionString, String defaultContainerName) +27
   LADinner.Models.LaDinnerEntities..ctor() in C:\NerdDinner\Models\LaDinners.Designer.cs:39
   LADinner.Models.DinnerRepository..ctor() in C:\NerdDinner\Models\DinnerRepository.cs:10
   LADinner.Controllers.DinnersController..ctor() in C:\NerdDinner\Controllers\DinnersController.cs:14

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.Activator.CreateInstance(Type type) +6
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +491

[InvalidOperationException: An error occurred when trying to create a controller of type 'LADinner.Controllers.DinnersController'. Make sure that the controller has a parameterless public constructor.]
   System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +628
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +204
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +193
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +160
   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +80
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +45
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841400
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Then I check the web.config.  the connection string is there.

    <add name="ApplicationServices" connectionString="data source=.;Integrated Security=SSPI;database=aspnetdb;trusted_connection=true" providerName="System.Data.SqlClient"/>
    <add name="NerdDinnerEntities" connectionString="metadata=res://*/NerdDinner.Models.NerdDinners.csdl|res://*/NerdDinner.Models.NerdDinners.ssdl|res://*/NerdDinner.Models.NerdDinners.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=NerdDinner;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/></connectionStrings>

So the runtime will read some resource file embedded in the Assembly. So are the name correct?

I just run a ILDASM NerdDinner.DLL /

c:\NerdDinner\bin>ildasm NerdDinner.dll /

Volume in drive C is BOOTCAMP
Volume Serial Number is 7CA9-BE94

Directory of c:\NerdDinner\bin

10/25/2010  05:23 PM    <DIR>          .
10/25/2010  05:23 PM    <DIR>          ..
10/25/2010  05:23 PM           173,811
10/25/2010  05:23 PM               824 a.res
10/25/2010  05:19 PM            31,232 NerdDinner.dll
10/25/2010  05:19 PM            46,592 NerdDinner.pdb
10/25/2010  05:23 PM             2,298 Models.NerdDinners.csdl
10/25/2010  05:23 PM             1,205 Models.NerdDinners.msl
10/25/2010  05:23 PM             2,066 Models.NerdDinners.ssdl
               7 File(s)        258,028 bytes
               2 Dir(s)   5,624,713,216 bytes free

Here, for those resource file, Pay attantion to the filename. this is no Assmebly name as the prefix.
Models.NerdDinners.csdl Instead of NerdDinner.Models.NerdDinners.CSDL which is defined in the web.config

so remove the nerddinner in web.config , that’s the trick to fix the problem

    <add name="ApplicationServices" connectionString="data source=.;Integrated Security=SSPI;database=aspnetdb;trusted_connection=true" providerName="System.Data.SqlClient"/>
    <add name="NerdDinnerEntities" connectionString="metadata=res://*/NerdDinner.Models.NerdDinners.csdl|res://*/NerdDinner.Models.NerdDinners.ssdl|res://*/NerdDinner.Models.NerdDinners.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.;Initial Catalog=NerdDinner;Integrated Security=True;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient"/></connectionStrings>

Friday, October 22, 2010

Microsoft wse kerberos an invalid security token was provided

there is one WSE secured service  which is authenticated using the Kerberos token.   someday, I get this error. “an invalid security token was provided”

the error is very general , that means the TGT ticket is somehow invalid. Could be caused by time inconsistency, host mismatch, tons of reasons.

So how to get more inside error. like the com return come?
run Cordbg, and attach to the w3wp process. turn on unhandled exception.

ca e
a xxxxx
print $exception


Print the Inner Exception Exception

p $exception._innerException


Here we get the detailed error.

The incoming Kerberos service ticket could not be validated. The LsaLogonUser call failed with the following message: The trust relationship between this workstation and the primary domain failed.
form the wse manual, you can check the reason is that  when the Kerberos target host name does not match the host name of the Web service that receives the SOAP message. Change the target host name to match the host name of the Web service.

you may try rejoin the server to domain. for me, that’s because the client send two tgt token.

wse 2 sp1 think that’s fine that one soap with two tgt token. for sp3, it will denied the request and throw the above error.

Wednesday, October 20, 2010

Microsoft SQL Server 2008 Setup SQL Server 2008 Setup requires .NET Framework 3.5 to be installed.

I get an error today, when I try to install sql server 2008 on one windows server 2008. The .net Framework 3.5  is there already. you can tell from the folder. C:\windows\\Framework



the SQL 2008 requires windows installer 4.5. (you can tell from run “msiexec /?”


Go to this link to install the latest windows installer.

Then I go to %temp%, there is the setup log for sql server, also for all microsoft product. always check this folder for installation log.
there is one file called sqlsetup, here is the content.

10/20/2010 09:45:23.809 ======================================================================
10/20/2010 09:45:23.809 Setup launched
10/20/2010 09:45:23.809 Attempting to determine media source
10/20/2010 09:45:23.824 Media source value not specified on command line argument.
10/20/2010 09:45:23.824 Setup is launched from media directly so default the value to the current folder.
10/20/2010 09:45:23.824 Media source: E:\
10/20/2010 09:45:23.840 Attempt to determine media layout based on file 'E:\mediainfo.xml'.
10/20/2010 09:45:23.918 Media layout is detected as: Full
10/20/2010 09:45:23.934 Media LCID is detected as: 1033
10/20/2010 09:45:23.934 Local setup.exe not found, so continuing to run setup.exe from media.
10/20/2010 09:45:23.934 /? or /HELP or /ACTION=HELP specified: false
10/20/2010 09:45:23.949 Help display: false
10/20/2010 09:45:23.949 Checking to see if we need to install .Net version 3.5
10/20/2010 09:45:23.949 Determining the cluster status of the local machine.
10/20/2010 09:45:23.980 The local machine is not configured as a cluster node.
10/20/2010 09:45:23.996 Attempting to find media for .Net version 3.5
10/20/2010 09:45:23.996 Error: Cannot determine file version of .Net redist: 0x80004005
10/20/2010 09:51:44.615 .Net version 3.5 installation failed, so setup will close. Error code: 0x80004005
10/20/2010 09:51:44.631 Setup closed with exit code: 0x80004005
10/20/2010 09:51:44.631 ======================================================================


also I open the process monitor. to capture all fiel activity of setup.exe. , it try to read one setup file which is located in E:\x86\redist\DotNetFrameworks\dotNetFx35setup.exe


it’s not a valid PE file.

80004005 means  the file is broken.
so the final answer,  make sure you ISO checksum is correct. for me, just download a new ISO which works well.

Also Microsoft should prompt user a friendly error.

Locations of visitors to this page