Monday, August 12, 2013

TFS: Access to the path is denied

I want to download latest version from TFS 2012 to test the project is uploaded to source control successfully or not. When I run the project, an error is occurred.


After a while, I discover the file property of the project is read-only. Hence, access is denied.

Then, I just wonder why the project become read-only. It is because I haven't check out the project through TFS before the download. So, please remember to check out the project via TFS or just uncheck the read-only properties of the project.




Thursday, June 20, 2013

href vs onclick

I would like to generate a link dynamically. Then, a javascript function is used to redirect to another page. original: It can really redirect the page, but IE doesn't indicate that the page is loading. update: It works fine under IE which can show the page is loading.

Friday, April 26, 2013

RegisterArrayDeclaration

I would like to use ClientScript.RegisterArrayDeclaration to declare an array in client side.So that, it looks like following code.
Client side:
var CheckBoxIDs = new Array(
'ctl00_MainContent_GridViewList_ctl02_CheckBoxItem', 
'ctl00_MainContent_GridViewList_ctl03_CheckBoxItem', 
'ctl00_MainContent_GridViewList_ctl04_CheckBoxItem', 
'ctl00_MainContent_GridViewList_ctl05_CheckBoxItem', 
'ctl00_MainContent_GridViewList_ctl06_CheckBoxItem');

Server side:
ClientScript.RegisterArrayDeclaration("CheckBoxIDs ", checkboxID);

It works fine. However, I need to add elements into the array dynamically. Instead of using ClientScript, ScriptManageer should be used this time.

ScriptManager RegisterArrayDeclaration

Wednesday, April 24, 2013

SerializationException: VewState

In order to save temporary data within a .aspx page, ViewState is my choice.  The data is a List of custom object.
ViewState["TempData"] = new List<ABC>();
Unfortunately, it throws an SerizationException. This error message shows that the class is not serializable. After I add "[Serializable] "  to the class, the problem is solved. But, I don't know why the class needs to be serialized. 

This issue is related to how ViewState packs data into a hidden field. ViewState serialized data into based 64 string and then stored into hidden form field. Later, page can get back state data by deserialized the hidden field.


Understanding ASP.NET View State
[ASP.NET] 利用ViewState保存自訂物件

Wednesday, April 17, 2013

Allow Remote WMI connection in Windows Servers 2008 R2

I wanna a C# program to get disk space of a remote server whose OS is Windows Server 2008 R2. The program and the server are under different domains. I use server's domain account to authenticate the connection. 

Unluckily, the most different part of this task is the configuration of enabling remote WMI connection, not the program to get a disk space. Two error codes:  

=> The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)  
=> Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))  

I have spent much time on the first one and it seems there are some thing wrong with my config. Here are some steps I still remember:

1. Allow WMI to communicate through firewall



2. Enable "remote launch" and "remote activation" in Access Permission of Component Services



3. Enable "remote access" in Access Permission of Component Services



4. Enable "remote enable" in WMI Control Properties



You can simply test WMI connection by using wmic command
wmic /node:localhost /user:administrator /password:1234 bios get serialnumber 

Monday, February 25, 2013

Enable DataSet View in Reporting Services

I would like to enable a view to display DataSet in a report. But, I go to Tab [View] and then search it through [Other Windows]. No relevant window can be found. After googling, the solution is View -> Reporting Data (Ctrl + Alt + D)

Thursday, December 6, 2012

SQL SERVER: Execute SSIS Package Using Store Procedure

Originally, I used 'Microsoft.SqlServer.Dts.Runtime'to execute local SSIS package under asp.net Web application. Under client's environment, SQL Server and web application are hosted on different Windows servers. Now, I use store procedure to execute SSIS package placed in DB server.
 
set @params = '/conn \"a\";"\"' + @a+ '\"" /set \package.variables[b].Value;"\"' + @b+ '\""'
set @cmd = 'C:\dtexec.exe /f ' + @PackagePath + ' ' + @params
EXEC xp_cmdshell @cmd

Dont forget to enable 'xp_cmdshell' option first!

I had to used 32 bit version of dtexec.exe as my package need OLEDB provider Jet 4.0. The provider is not available under 32 bit environment. As a result, I use the x86 version to handle this issue.

Errors when executing SQL Server SSIS Package From Stored Procedure
How to Call SSIS Package from the Stored Procedure