SOAP | REST |
---|---|
<system.serviceModel>
<services> <service behaviorConfiguration="ServiceBehavior"> <endpoint address="" binding="wsHttpBinding"
contract=...>... </endpoint> ... </service> </services> ... </system.serviceModel> |
<system.serviceModel>
<services> <service behaviorConfiguration="ServiceBehavior"> <endpoint address=""
binding="webHttpBinding"
contract=...>behaviorConfiguration="RESTBehavior" ... </endpoint> ... </service> </services> ... <behaviors> ...
<endpointBehaviors>
</behaviors><behavior name="RESTBehavior"> <webHttp/> ... </behavior> </endpointBehaviors> ... </system.serviceModel> |
Tuesday, May 19, 2009
SOAP and REST-based WCF basic settings in Web.config
Friday, May 15, 2009
Blogger cannot display the image

Using the images stored with blogger could be tricky. There is no doubt that the image can be displayed correctly if you use exactly the code provided by blogger.
href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0dTd1RVdaar9KTLCks9J022j3MxwYgjx7fIjXCTaj1COwHcxCAEge4DKoFhoFNuFs9mGxkc4yXFby9JiZbzIuwBFSe9Qb9vKkgqZxrUR-gZdcFhksqi4IlVW8UZylPZAcge3Dw2UlaTM/s1600-h/rat_cheese.gif">
<img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 230px; height: 320px;"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0dTd1RVdaar9KTLCks9J022j3MxwYgjx7fIjXCTaj1COwHcxCAEge4DKoFhoFNuFs9mGxkc4yXFby9JiZbzIuwBFSe9Qb9vKkgqZxrUR-gZdcFhksqi4IlVW8UZylPZAcge3Dw2UlaTM/s320/rat_cheese.gif"
border="0" alt=""
id="BLOGGER_PHOTO_ID_5336176003028964418" />
- href uses the image in s1600-h: the image looks original or bigger.
- src uses the image in s320: the image is shrunk or smaller.
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0dTd1RVdaar9KTLCks9J022j3MxwYgjx7fIjXCTaj1COwHcxCAEge4DKoFhoFNuFs9mGxkc4yXFby9JiZbzIuwBFSe9Qb9vKkgqZxrUR-gZdcFhksqi4IlVW8UZylPZAcge3Dw2UlaTM/s320/rat_cheese.gif"
border="0" alt="Using s320"
id="BLOGGER_PHOTO_ID_5336176003028964418" />
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0dTd1RVdaar9KTLCks9J022j3MxwYgjx7fIjXCTaj1COwHcxCAEge4DKoFhoFNuFs9mGxkc4yXFby9JiZbzIuwBFSe9Qb9vKkgqZxrUR-gZdcFhksqi4IlVW8UZylPZAcge3Dw2UlaTM/s1600-h/rat_cheese.gif"
border="0" alt="Using s1600-h"
id="BLOGGER_PHOTO_ID_5336176003028964418" />
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0dTd1RVdaar9KTLCks9J022j3MxwYgjx7fIjXCTaj1COwHcxCAEge4DKoFhoFNuFs9mGxkc4yXFby9JiZbzIuwBFSe9Qb9vKkgqZxrUR-gZdcFhksqi4IlVW8UZylPZAcge3Dw2UlaTM/s1600/rat_cheese.gif"
border="0" alt="Using s1600"
id="BLOGGER_PHOTO_ID_5336176003028964418" />
Sunday, May 3, 2009
LINQ and ConnectionString
Why do I have this error "No parameterless constructor defined for this object"?
Why can't I add a database table to DBML / LINQ designer?
- Why is the dropdown box of "Choose your context object" always empty or why can't I find my context object while I am configuring LinqDataSource?
Please be sure the DLL containing the context object existed and you have a reference to it. If the LINQ class is newly created, please compile the project first before you try to configure LinqDataSource.
- Why do I have this error "No parameterless constructor defined for this object"?
If you remove the ConnectionString manually from the Connection element of the DBML source file first (use external text editor to remove it) and then set the Application Settings to False (also see How to Turn off Application Settings for LINQ), your parameterless constructor of the DataContext class (e.g., Book.designer.cs) will immediately be removed by the IDE. Then the above error will occur when you recompile and run the application.
Normally enabling Application Settings on LINQ will have the parameterless constructor generated for you automatically, as long as its ConnectionString property is not empty. Indeed, you won't be able to remove the ConnectionString property inside the IDE. But you remove it anyway outside it. When this happens, the original parameterless contructor will lose forever regardless of Application Settings. Thereafer, adding back the ConnectionString property to the file will not resolve it. And the other problem dicussed in the next question may occur.
To resolve this, you need to manually add the original parameterless constructor back.
- Why does the actual connection string (like below) suddenly appear inside the parameterless contructor of my DataContext class? For example,
public BookDataContext() :
base("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Books.mdf;Integrated Security=True;User Instance=True", mappingSource)
{
OnCreated();
}Situation 1: If you set the Application Settings to False while the ConnectionString property exists in the DBML source file, your original parameterless constructor of that DataContext class will be altered by hard-coding with the actual connection string that can be found in your .config file (e.g., web.config).
Situation 2: The application had Application Settings set to False and the correct default parameterless constructor some time ago. Later, you make a change by adding a new table to the LINQ. As soon as you drag the new table to the DBML or LINQ designer, your original, correct parameterless contructor will be altered by hard-coding with the actual connection string.
Currently, I don't know any other easy way to deal with it. If you know, please jot me a note. What I do is
- First, ensure Application Settings for LINQ is set to False.
- Then, manually alter or copy the parameterless contructor back to the original .
- Why can't I add a database table to DBML / LINQ designer?
This happens when
- your Application Settings for LINQ is set to False,
- ConnectionString element doesn't exist in the DBML source file, and
- the parameterless constructor in LINQ class is missing.
The IDE needs to know where to read the connection string in order to access the database. Please ensure you have the parameterless contructor defined correctly while remaining Application Settings for LINQ to False and the absence of ConnectionString in the DBML source file.
Sample of Parameterless Constructor in a ContextClass
- public BookDataContext() : base(global::System.Configuration.ConfigurationManager.ConnectionStrings["BookConnectionString"].ConnectionString, mappingSource) { OnCreated(); } where BookDataContext is my DataContext class, BookConnectionString is the name of the connection string found in .config file. You should change them to fit yours accordingly.
The default setting of LINQ to SQL class is always True. You can do the following to disable it.
On VS IDE
- Go and double-click to open the DBML file from Solution Explorer.
- Then open the file Properties window if it is not open. Be sure that the focus is on the DBML designer tab; otherwise, you won't see or cannot continue with the next step.
- Expand Connection and then set Application Settings to False.
Saturday, April 25, 2009
MagicJack: pros and cons
MagicJack (MJ) is a USB Internet phone device using the processor chip from Tiger Jet acting as an adapter that allows you to plug in a regular phone and then use, or directly use the provided softphone via your computer with a speaker and a microphone ready. The device is Windows compliance so there is no driver needed. Any new driver update will be automatically detected and distributed via Windows update.
I purchased it because I was suddenly required 100% travel due to the department transfer and I began disliking my new task. I was thinking to leave the company by starting my job search journey. Since I had the company cell phone, I could simply forward all my personal calls to my cell because my home phone was a basic land line without any feature. Thus, I would like to have an economic solution. MagicJack is the solution I chose. If you have stable high-speed Internet connection, the phone quality will be as good as a regular land line. MJ works like other VoIPs like Vonage but with much lower cost. You can use it wherever you are including internationally, and unlimited calls are free to made within/to the US and Canada.
I am a MagicJack user and use it every day now. I would like to share some thought and experience here. You may find them useful to decide if MagicJack is right for you.
Pros | Cons |
---|---|
Driver Needed No, MagicJack is compatible on Windows and Windows compliance. Thus, there is no driver needed. Any new driver update will be automatically detected and distributed via Windows update. Easy Installation Unlike its advertisement on TV (i.e., no installation), MagicJack requires software download and installation. You must sign-up an account as soon as you have softphone installed and then activated it before you can make a call. This is based on my experience. I have 3 laptops and 1 desktop at home; they all required manually software download and installation. Cost and Features Low cost. The first year subscription including the device itself is $39.95 + shipping and handling ($9.95 for USA user). Up to this moment I am writing (April 25, 2009), each subsequent subscription per year is only $19.95 and $59.95 for 5 years. Unlike a landline or other VoIPs, the price here is final without additional tax or subcharge. The cost includes all the needy features: unlimited local and long distance call, 411 directory assistance, voice mail, call waiting, 3-way calling, call forwarding, 911 service, and Do-Not-Disturb. Total Call Minutes No limit on total call minutes. Unlimited calls can be made within the United State and Canada. But the duration of each call is limited to 2 hours. Quality of the Call and Connectivity The service provided by MagicJack is VoIP relying on Internet connection. Thus, your Internet connection stability is the key to your call quality and connectivity. I have a stable, high-speed Internet; I found the call quality is as good as a landland. I usually talk to my family about 2 hours during weekends (but there is time limit per call; 2 hours max). Within these 2 hours, my call is never interrupted nor dropped. I am happy with the call quality and I have no problem on the call connectivity. Phone Number Like other VoIP phone service providers (e.g., Vonage), MagicJack provides you a phone number. You can choose the number that you want including the area code. | Windows Only MagicJack cannot run on any other platforms but windows only. Computer-Dependent MagicJack goes offline when your computer is off. In addition, you have to log in onto the system and let the software (i.e., softphone) load before use. MagicJack provides you a call log (via softphone) but the missing call will not be captured when the computer is off unless the person leaves you a message. Any left message will be directly delivered to your email box via a WAV file. Software-Dependent You cannot make a call if your softphone is not ready. You have to wait until your softphone is completely loaded. Seeing "Ready to Call" on the softphone doesn't mean you can make a call. You may still have to wait a few seconds. Although you are able to use a regular phone to make calls, the softphone is the actual interface sitting between your phone and the device (i.e., MagicJack). Thus, if the softphone is not running, your phone will not work, and you will never know if there is a missing call unless the person leaves you a message. Only when the softphone is up and running, all calls timestamp will be kept in your call log. Any Hardware Conflict Yes, at least I found that MagicJack is conflict with my USB TV tuner. As soon as I plug the TV tuner in, the MagicJack softphone won't work without unplugging and re-plugging. The same problem occurs when you start or reboot the system with the TV tuner and MagicJack attached. If you make a call without hearing the phone dialing after you have keyed in all the numbers, it indicates either your softphone is not ready or you have hardware conflict issue. Consume More Drive Labels MagicJack is a USB device but it consumes 2 disk/drive labels. If you have a lot of external USB drives (e.g., USB thumb drives), some of them may not be recognized because MagicJack takes their original drive labels. To resolve this, you need to specifically change the drive labels either on MagicJack itself or the USB drives via Computer Management. Configurability No, there is not much you can configure MagicJack except for the call forwarding via their Web-based interface. You cannot configure the greeting message if you don't like it (sorry, I cannot find a way to do it). And you cannot change the time zone either. Thus, the time shown on the call log doesn't reflect your actual time. I have no idea which time zone is. Customer Service Unlikely you will speak to a live person over the phone but live-chat with their technical support 24/7 or via email query. Frankly, I don't find them much helpful on the issue I had. MagicJack will provide you a contact number when you have a billing issue but you need to chat with the technical support first. The attitude of the customer representative in the billing department is horrible. The one I talked to was impatient and unpleasant. The more I spoke to her, the more I got frustratetd. See my another comment on MagicJack. Time Limit Per Call Each call is limited to 2 hours. Otherwise, the call is automatically terminated and then what you can hear is the dial tone. You can continue with your conversation by placing the call again. Other Issues
|
Updated on October 17, 2009
An additional note: since MagicJack is via VoIP protocol to send voice, your traditional fax machine may not work with VoIP line. I have recently run into this problem. For the detail of why faxing and modems don't work well over VoIP, see here.
Thursday, April 23, 2009
Limitation highlight of SQL server editions
Feature | Express | Developer or Enterprise | Workgroup or Standard |
---|---|---|---|
Is free? | Yes | No | No |
Redistributable? | Yes | No | No |
Work with Team Foundation Server? |
No | No - Developer Yes - Enterprise |
Yes |
Concurrent Connection | 5 | No Limit - subject to @@MAX_Connections |
No Limit - subject to @@MAX_Connections |
Database size | 4 GB | No Limit | No Limit |
CPU supported | 1 | Maximum OS supported |
2 - Workgroup 4 - Standard |
RAM Supported | 1 GB | Maximum OS supported | 3GB - Workgroup Maximum OS supported for Standard |
Tuesday, April 21, 2009
Batch or VBScript cannot run as scheduled task on Windows 2008/Vista, why?
The script file runs fine as a scheduled task under Windows 2003/XP but it fails on Windows 2008/Vista. If you run the script manually on the command prompt on Windows 2008/Vista, it will work perfectly without a problem. It always fails when it runs as a scheduled task regardless of logon. Task Start Failed always occurs with the default error code 2147750687.
The problem spent me almost 2 months to figure out while I was busy with something else. It happened almost 8 months ago from now when everything was being moved from Windows 2003 to Windows 2008.
The followings were the scheduled task settings on Windows 2008/Vista:
- Run under the local Administrator account
- Run whether user is logged on or not
- Run with highest privileges - actually this one shouldn't be needed since it is run under the local Administrator.
Task Scheduler 2.0 took place on Windows 2008 as well as Windows Vista. There are a lot of differences from its predecessor on Windows 2003 or Windows XP. Here is one of them. When you run your script as a scheduled task, the scheduler (2.0) will create an account impersonating as the user you configure/specify for the task. The account is always resided in or runs from %systemroot%\system32\. Therefore, if your script internally uses relative path, it is going to fail 100% because of path/file not found or permission denied. For that reason, there are two options I would suggest:
- Modify all the relative paths to be fully qualified paths or absolute paths; e.g., c:\tasks\scheduled\output.txt
- Modify the script to take the directory as an argument when you run it; e.g., c:\tasks\scheduled\taskA.vbs c:\tasks\myappPath\.
In my case, as soon as I've fixed the relative path problems, all scripts with Task Scheduler 2.0 run like a charm.
In sum, checking if the problem is related to a relative path on your mystery task may save you from a million troubles.
Monday, April 13, 2009
How to attach MDF without LDF into SQL 2005 - Part 2
In the following illustration, I will use AdventureWorks.mdf as an example.
Execute the following statement to attach your MDF on SQL Management Studio:
GO
CREATE DATABASE AdventureWorks
ON PRIMARY (FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks.mdf')
FOR ATTACH_REBUILD_LOG
GO
If everything works fine, you may get the similar message below and have your database attached after execution:
-
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.ldf" may be incorrect.
New log file 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks_log.LDF' was created.
-
File activation failure. The physical file name "C:\Users\<SomeUserName>\Documents\MyCode\Test\App_Data\AdventureWorks_log.ldf" may be incorrect.
The log cannot be rebuilt when the primary file is read-only.
Msg 1813, Level 16, State 2, Line 3
Could not open new database 'AdventureWorks'. CREATE DATABASE is aborted.
Depending on how or where you get your MDF file (because your MDF may not be detached properly), your LDF rebuilt may fail and so may your database attach command. In this case, you need to download and use the free tool SQL Server Express Utility (SSEUtil) to interact with the server and create the LDF file for you. This tool also works well with the full version of SQL Server 2005. There are two (2) big steps you need to perform in order to make your MDF finally available on SQL Management Studio.
Step 1: Use SSEUtil to attach MDF into the database server
Then at the command prompt, run sseutil's attach database command. Before doing it, please be sure to add your path to sseutil.exe. Otherwise, you need to use its absolute path name,., e.g., c:\util\sseutil.exe.
- sseutil -s .\SQLExpress -a "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks.mdf" AdverureWorks
- -s to specify the instance of SQL server.
- -a to attach the database by specifying its MDF file path name.
- The last parameter is optional. It is the name of database you want to call (e.g., AdvantureWorks).
or
You can use sseutil console to interact with the server.
- To start a sseutil console, at the command prompt, type
sseutil -c
- You will see
Console mode. Type 'help' for more information.
1> - To attach a MDF, type
!attach "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks.mdf" AdventureWorks - Type quit when you're done. This step is necessary to enable you to add the database into the sysdabases in the next step by removing the lock on file.
Step 2: Add MDF into sysdatabases
-
USE master
GO
EXEC SP_ATTACH_DB
@filename1=N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks.mdf',
@dbname=N'AdventureWorks
or
-
USE master
GO
CREATE DATABASE AdventureWorks
ON PRIMARY (FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\AdventureWorks.mdf')
FOR ATTACH
GO
Sunday, April 12, 2009
How to attach MDF without LDF into SQL 2005
If you are only interested in attaching MDF to the SQL 2005 server without data extraction and replication, please see my part 2, which works without Visual Studio installed.
I use VS.2008 to do the trick. VS.2005 doesn't have this ability. This method probably may work in Visual Web Developer 2008 Express Edition.
Open VS.2008 and do the followings:- New a Web site or use the existing one.
- Add the file to the project's App_Data folder.
- Right click this folder in the Solution Explorer and select Add Existing Item...
- Locate the MDF file you want to use.
- Then click Add.
- Double-click on the MDF file that you just added; it will open Server Explorer for you.
- Locate and right-click the MDF file data connection on Server Explorer.
- Select Publish to provider...
- Go through the wizard; when the wizard asks you where to publish, I select Script to file. It will generate a SQL file that contains all the database schema and its data.
- Create a database with the same name as your MDF.
- Run the SQL file you just created by Server Explorer in VS.2008.
How to print PDF background as you see on file
Have you ever experienced the following problem when you print a PDF file? The background images appear like regular text. It is not what you see on file when you view it.
You may have a PDF look like this when you view it:Whenever you try to print, you will get this:
There is nothing wrong with the PDF. To fix this, use Print as image at your printer option. You may find this option at your Advanced button or tab. Then you should print something as below:
Note that the printer used here is a black and white laser printer, not color print.
Friday, April 10, 2009
Favorite torrent sites
Good torrent sites | Bad torrent sites |
---|---|
|
If you go there, be careful of running out of CPU usage and you have to kill your browser in order to stop it |
How to enable script debugging on Internet Explorer
On Internet Explorer, at the menu bar,
- Choose Tools -> Internet Options
- Click Advanced
- Ensure to uncheck Disable script debugging (Internet Explorer) in the Browsing category.
Windows Firewall Settings and IIS for ASP.NET
On Windows XP,
- Go Control Panel -> Windows Firewall
- Select Advanced tab
- On the Network Connection Services selection list, select one of the connection item, e.g., Local Area Connection, Wireless Network Connection, ... and etc.
- Then click Settings...
- Ensure that Web Server (HTTP) is checked.
On Windows Vista,
- Go Windows Control Panel
- Select the Exception tab
- Ensure that World Wide Web Services (HTTP) is checked.
Sunday, April 5, 2009
Can you be that creative?
These egg shells were cut with a high intensity precision Laser Beam. This gives a very good idea of what can be achieved with a Laser Beam. This gives you an idea what laser surgery performed on one's eye is all about. Is it any wonder how one's vision can be improved in just a few moments? Science is sometimes wonderful, and it's still on the frontier of gaining new knowledge. Inc redible what can be done with an eggshell and a laser beam.
Saturday, April 4, 2009
Can Your Brain Switch?
Please look at it for at least 30 seconds.
Someone has sent this picture to me recently and asked me what I saw.
Well, my colleague who is left-handed saw both ways after a few seconds. I have another colleague who primarily uses her right hand also saw her turning both ways. Mine is even more interesting. At first, I only saw her turning clock-wise. But after a while, I saw her turning the other way around and then in the half way, she was bouncing back. I saw her turning back and forth a few times. Then I saw her turning completely anti-clockwise. I cannot believe my eyes. It is neat. Now I even make her turn whichever way I want or make her bounce back left and right repeatedly. How about you? Can you make her turn? Which direction do you see?
If you see it the other way, you are using left brain.
Some people do see both ways, but most people see it only one way.
If you try to see it the other way and if you do see, your IQ is above 160 which is almost a genius.
Then see if you can make her go one way and then the other by shifting the brain's current?
BOTH DIRECTIONS CAN BE SEEN
This was proved at Yale University, over a 5 year study on the human brain and it's functions. Only 14% of the US population can see her move both ways.
LEFT BRAIN FUNCTIONS uses logic detail oriented facts rule words and language present and past math and science can comprehend knowing acknowledges order/pattern perception knows object name reality based forms strategies practical safe |
RIGHT BRAIN FUNCTIONS uses feeling "big picture" oriented imagination rules symbols and images present and future philosophy & religion can "get it" (i.e. meaning) believes appreciates spatial perception knows object function fantasy based presents possibilities impetuous risk taking |
Friday, April 3, 2009
Cheated by MagicJack
I ordered MagicJack (MJ) on Feb 22, 2009 Sunday when I saw their ad on TV. I am sure that I remember what the ad said because the ad was repeated several times. I wasn't making my decision right away to order it. I made it almost last minute.
What the TV ad said is: $39.95 for the device and one year free subscription. The ad sounds more attractive to say that making an order via the phone number advertised on the TV now would waive shipping and handling. The product provided money back guarantee for 30 days free trial. It also emphasized that within the trial period, the customer could send it back at their expense without paying the shipping cost. Thus, it was absolutely no risk.
Well, I was cheated. Besides $39.95, there is always $6.95 shipping and handling fee. Their representative claimed, the ad maybe said that I could get my money back including shipping cost. The S&H is not free. Okay, I listened incorrectly. The following is the page when I first activated MJ and logged in. It clearly said that S&H is free. Even now, the page is still there. But they said they don't know what I am talking about and claimed the page could be wrong. Gosh, unbelievable!
Their automatic ordering system is horrible and not easy to use. They cannot get my name right and they have my incorrect email address. There is no confirmation number when I placed an order so I wouldn't know if the order is done successfully. When I first received MJ, I called the customer service for installation. It is not as smooth as it is claimed on TV. At the same time, I inquired my account information and asked when I would receive my billing statement; the customer service replied that there is nothing to worry. When I activated MJ, I would sign up an account at the same time. The billing statement will be sent to my account later. Up to this moment, I haven't received my statement yet but my credit card was charged already on the 30th day from the date I placed an order.
I called their billing department for questions. Their real person attitude is horrible. She helped nothing but referred me back to the customer service (via live chat). My account was billed under different name and different email address. It was why I have never got my bill. Lucky them, they have my credit card right!
Chatting to their customer service twice about account data correction, they said they had informed the accounting department to have my file updated and may try re-send me the statement. An email for correction will reach me within 24-48 hours. 4 days already and I hear nothing from them. Their issue service is very bad!
Luckily their phone service is not bad - it is the only comfort.