This article outlines how .NEt can interact with Active Directory.
Source: .NET and Active Directory
Friday, 28 March 2008
WCF vs .NET Remoting 2.0
Source: Daniel Carbajal's Weblog
WCF:
- WCF is Microsoft recommended direction
- WCF was released on January 2006 with Go-Live Licenses, but it will be officially released on November of this year
- WCF is a 100% Service Oriented Architecture application development platform
- WCF Security Architecture is interoperable, based on WS-* specifications and it’s designed for On-Machine, Cross-Machine, and Cross-Internet scenarios.
- WCF Transaction Architecture is full flexible, declarative and has method level granularity
- WCF binary messages are smaller and faster than Remoting’s. Services versioning is better dealt with WCF than with Remoting.
- Services versioning is better dealt with WCF than with Remoting
.Net Remoting for .Net Framework 2.0:
- Remoting is not recommended by Microsoft
- Remoting for .Net Framework 2.0 was released in December 2005
- Remoting is tightly coupled Object Oriented technology and not loosely coupled Service Oriented.
- It has security limitations, though now it has the new secure TcpChannel
- With System.Transactions we can get similar transaction management capabilities but not in a declarative way
Thursday, 27 March 2008
.NET Remoting
Great article explaining this concept:
Source: http://www.developer.com/net/cplus/article.php/1479761
What is .NET Remoting?
.NET Remoting is an enabler for application communication. It is a generic
system for different applications to use to communicate with one another. .NET
objects are exposed to remote processes, thus allowing interprocess
communication. The applications can be located on the same computer, different
computers on the same network, or even computers across separate networks.
Source: http://www.developer.com/net/cplus/article.php/1479761
Wednesday, 26 March 2008
Thursday, 20 March 2008
VS2005 Solution Explorer Collapse All
Cool marco to do this (Source):
Sub CollapseAll()
'http://geekswithblogs.net/scottkuhl/archive/2007/04/09/111195.aspx
'Set the depth of collapsing
Dim depth As Integer
depth = 1
' Get the the Solution Explorer tree
Dim solutionExplorer As UIHierarchy
solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (solutionExplorer.UIHierarchyItems.Count = 0) Then
Return
End If
' Get the top node (the name of the solution)
Dim rootNode As UIHierarchyItem = solutionExplorer.UIHierarchyItems.Item(1)
rootNode.DTE.SuppressUI = True
' Collapse each project node
Collapse(rootNode, solutionExplorer, 0, depth)
' Select the solution node, or else when you click
' on the solution window
' scrollbar, it will synchronize the open document
' with the tree and pop
' out the corresponding node which is probably not what you want.
rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
rootNode.DTE.SuppressUI = False
End Sub
Private Sub Collapse(ByVal item As UIHierarchyItem, ByRef solutionExplorer As UIHierarchy, ByRef Level As Integer, ByRef Depth As Integer)
'Collapse to the right Depth
If Level <> 0 Then
' Re-cursive call
Collapse(innerItem, solutionExplorer, Level + 1, Depth)
' Collapse
If innerItem.UIHierarchyItems.Expanded Then
innerItem.UIHierarchyItems.Expanded = False
If innerItem.UIHierarchyItems.Expanded = True Then
' Bug in VS 2005
innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
solutionExplorer.DoDefaultAction()
End If
End If
End If
Next
End If
End Sub
Sub CollapseAll()
'http://geekswithblogs.net/scottkuhl/archive/2007/04/09/111195.aspx
'Set the depth of collapsing
Dim depth As Integer
depth = 1
' Get the the Solution Explorer tree
Dim solutionExplorer As UIHierarchy
solutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
' Check if there is any open solution
If (solutionExplorer.UIHierarchyItems.Count = 0) Then
Return
End If
' Get the top node (the name of the solution)
Dim rootNode As UIHierarchyItem = solutionExplorer.UIHierarchyItems.Item(1)
rootNode.DTE.SuppressUI = True
' Collapse each project node
Collapse(rootNode, solutionExplorer, 0, depth)
' Select the solution node, or else when you click
' on the solution window
' scrollbar, it will synchronize the open document
' with the tree and pop
' out the corresponding node which is probably not what you want.
rootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
rootNode.DTE.SuppressUI = False
End Sub
Private Sub Collapse(ByVal item As UIHierarchyItem, ByRef solutionExplorer As UIHierarchy, ByRef Level As Integer, ByRef Depth As Integer)
'Collapse to the right Depth
If Level <> 0 Then
' Re-cursive call
Collapse(innerItem, solutionExplorer, Level + 1, Depth)
' Collapse
If innerItem.UIHierarchyItems.Expanded Then
innerItem.UIHierarchyItems.Expanded = False
If innerItem.UIHierarchyItems.Expanded = True Then
' Bug in VS 2005
innerItem.Select(vsUISelectionType.vsUISelectionTypeSelect)
solutionExplorer.DoDefaultAction()
End If
End If
End If
Next
End If
End Sub
Wednesday, 19 March 2008
Debug JavaScript in VS2005
The basic steps are listed below:
- Make sure in IE6 under Tools > Internet Options > Advanced
Disable Script Debugging (Internet Explorer) and
Disable Script Debugging (Other) are unchecked - Open VS2005 with your solution
- Open IE6 and browse to your page the JavaScript is on
- In VS2005 Debug > Attach To Process
Click on Select... and make sure Script is checked
Select IEXPLORER.EXE (Title = Your page)
Click Attach - In VS2005 Debug > Windows > Script Explorer
You will see all debuggable JavaScript files - Put a breakpoint in your JS code for debugging
Your done!
Helpful links:
http://geekswithblogs.net/lazydeveloper/archive/2006/07/10/84552.aspx
http://msdn2.microsoft.com/en-us/library/k2h50zzs(VS.80).aspx
AJAX Error Handling
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
How to handle error 500?
An error with status code 500 indicates that there is a problem when the server tries to process the request. There can be variant causes. The problem is how to find out the real cause of the error.
Here are two ways to find it out:
1. Set a breakpoint in the code that is responsible for processing the request, then debug through it to find out the exception being thrown;
2. The real error message is usually returned in the response. We can use an HTTP Sniffer (e.g., Fiddler) to peek into the traffic between the client and server to find out the error message.
How to handle error 500?
An error with status code 500 indicates that there is a problem when the server tries to process the request. There can be variant causes. The problem is how to find out the real cause of the error.
Here are two ways to find it out:
1. Set a breakpoint in the code that is responsible for processing the request, then debug through it to find out the exception being thrown;
2. The real error message is usually returned in the response. We can use an HTTP Sniffer (e.g., Fiddler) to peek into the traffic between the client and server to find out the error message.
Introduction to LINQ
Brief explanation take from: Code Digest
Language Integrated Query (LINQ) is a query syntax that defines a set of
query operators that allow traversal, filter, and projection operations to be
expressed in a declarative way in any .NET-based programming language. It
provides a unified programming model for querying and updating data from
different types of data sources and extends data capabilities directly into the
C# and Visual Basic languages. LINQ simplifies the interaction between
object-oriented programming and relational data by applying the principles of
object-oriented programming to relational data.
With the advent of LINQ, a ground-breaking, new concept of a query has
been introduced as a first-class language construct in C# and Visual
Basic. LINQ simplifies the way you work with data queries. LINQ offers you
a unified, declarative syntax model to query any data source including an XML
document, SQL database, an ADO.NET Dataset, an in-memory collection, or any
other remote or local data source that chooses to support LINQ Language
Integrated Queries are strongly typed and designer tools can be used to
create object-relational mappings. It is easier now for developers to catch many
errors during compile-time; also supports Intellisense and debugging.
What is JSON? JSON vs AJAX!
JSON = JavaScript Object Notation
ICallback & JSON Based JavaScript Serialization: http://aspalliance.com/1537
AJAX request an asyn server call. The response back from the server can be XML, HTML or JSON etc. JSON is ideal for data interchange.
Example JSON
{
"fullname": "Sean Kelly",
"org": "SK Consulting",
"emailaddrs": [
{"type": "work", "value": "kelly@seankelly.biz"},
{"type": "home", "pref": 1, "value": "kelly@seankelly.tv"}
],
"telephones": [
{"type": "work", "pref": 1, "value": "+1 214 555 1212"},
{"type": "fax", "value": "+1 214 555 1213"},
{"type": "mobile", "value": "+1 214 555 1214"}
],
"addresses": [
{"type": "work", "format": "us",
"value": "1234 Main StnSpringfield, TX 78080-1216"},
{"type": "home", "format": "us",
"value": "5678 Main StnSpringfield, TX 78080-1316"}
],
"urls": [
{"type": "work", "value": "http://seankelly.biz/"},
{"type": "home", "value": "http://seankelly.tv/"}
]
}
Learn
http://www.developer.com/lang/jscript/article.php/3596836
ICallback & JSON Based JavaScript Serialization: http://aspalliance.com/1537
AJAX request an asyn server call. The response back from the server can be XML, HTML or JSON etc. JSON is ideal for data interchange.
Example JSON
{
"fullname": "Sean Kelly",
"org": "SK Consulting",
"emailaddrs": [
{"type": "work", "value": "kelly@seankelly.biz"},
{"type": "home", "pref": 1, "value": "kelly@seankelly.tv"}
],
"telephones": [
{"type": "work", "pref": 1, "value": "+1 214 555 1212"},
{"type": "fax", "value": "+1 214 555 1213"},
{"type": "mobile", "value": "+1 214 555 1214"}
],
"addresses": [
{"type": "work", "format": "us",
"value": "1234 Main StnSpringfield, TX 78080-1216"},
{"type": "home", "format": "us",
"value": "5678 Main StnSpringfield, TX 78080-1316"}
],
"urls": [
{"type": "work", "value": "http://seankelly.biz/"},
{"type": "home", "value": "http://seankelly.tv/"}
]
}
Learn
http://www.developer.com/lang/jscript/article.php/3596836
Tuesday, 18 March 2008
Using the Visual SourceSafe Command Line
Microsoft's official documentation: http://msdn2.microsoft.com/zh-cn/library/asxkfzy4(VS.80).aspx
Friday, 14 March 2008
COM problem converting VS2005 project to VS2008
I had a problem converting my VS2005 project to VS2008. This was on a Vista (crap OS) machine. The solution was to run VS2008 "Run as Administrator" and then open the solution to convert it.
Thursday, 13 March 2008
How to sort a generic List
Brilliant article describing how to sort custom objects n a List:
http://dotnetslackers.com/community/blogs/simoneb/archive/2007/06/20/How-to-sort-a-generic-List_3C00_T_3E00_.aspx
For example:
members.Sort(delegate(IFolderExplorerHierarchyMember member1, IFolderExplorerHierarchyMember member2)
{
return member1.Name.CompareTo(member2.Name);
});
http://dotnetslackers.com/community/blogs/simoneb/archive/2007/06/20/How-to-sort-a-generic-List_3C00_T_3E00_.aspx
For example:
members.Sort(delegate(IFolderExplorerHierarchyMember member1, IFolderExplorerHierarchyMember member2)
{
return member1.Name.CompareTo(member2.Name);
});
How to view REF CURSOR results
I was having a problem viewing the REF CURSOR results because it returned "Unknown cursor return type". This forum post below describes what to do to see the results:
http://sqlnavigator.inside.quest.com/thread.jspa?threadID=2466
http://sqlnavigator.inside.quest.com/thread.jspa?threadID=2466
Custom operators in C# .NET
Below are two examples of how to create custom operators for your objects.
public static bool operator !=(BusinessEntityKey a, BusinessEntityKey b)
{
return !(a == b);
}
Another example...
public static bool operator ==(BusinessEntityKey a, BusinessEntityKey b)
{
if ((object)a == null && (object)b == null)
{
return true;
}
else if ((object)a == null (object)b == null)
{
return false;
}
else
{
return (a.businessEntitySysKey == b.businessEntitySysKey && a.timestamp == b.timestamp);
}
}
public static bool operator !=(BusinessEntityKey a, BusinessEntityKey b)
{
return !(a == b);
}
Another example...
public static bool operator ==(BusinessEntityKey a, BusinessEntityKey b)
{
if ((object)a == null && (object)b == null)
{
return true;
}
else if ((object)a == null (object)b == null)
{
return false;
}
else
{
return (a.businessEntitySysKey == b.businessEntitySysKey && a.timestamp == b.timestamp);
}
}
Wednesday, 12 March 2008
REF CURSOR in Oracle
Source: http://www.devshed.com/c/a/Oracle/Working-with-REF-CURSOR-in-PL-SQL/
A REF CURSOR is basically a data type. A variable created based on such a data type is generally called a cursor variable. A cursor variable can be associated with different queries at run-time. The primary advantage of using cursor variables is their capability to pass result sets between sub programs (like stored procedures, functions, packages etc.).
declare
type r_cursor is REF CURSOR;
c_emp r_cursor;
en emp.ename%type;
begin
open c_emp for select ename from emp;
loop
fetch c_emp into en;
exit when c_emp%notfound;
dbms_output.put_line(en);
end loop;
close c_emp;
end;
In the previous section, I retrieved only one column (ename) of information using REF CURSOR. Now I would like to retrieve more than one column (or entire row) of information using the same. Let us consider the following example:
declare
type r_cursor is REF CURSOR;
c_emp r_cursor;
er emp%rowtype;
begin
open c_emp for select * from emp;
loop
fetch c_emp into er;
exit when c_emp%notfound;
dbms_output.put_line(er.ename ' - ' er.sal);
end loop;
close c_emp;
end;
A REF CURSOR is basically a data type. A variable created based on such a data type is generally called a cursor variable. A cursor variable can be associated with different queries at run-time. The primary advantage of using cursor variables is their capability to pass result sets between sub programs (like stored procedures, functions, packages etc.).
declare
type r_cursor is REF CURSOR;
c_emp r_cursor;
en emp.ename%type;
begin
open c_emp for select ename from emp;
loop
fetch c_emp into en;
exit when c_emp%notfound;
dbms_output.put_line(en);
end loop;
close c_emp;
end;
In the previous section, I retrieved only one column (ename) of information using REF CURSOR. Now I would like to retrieve more than one column (or entire row) of information using the same. Let us consider the following example:
declare
type r_cursor is REF CURSOR;
c_emp r_cursor;
er emp%rowtype;
begin
open c_emp for select * from emp;
loop
fetch c_emp into er;
exit when c_emp%notfound;
dbms_output.put_line(er.ename ' - ' er.sal);
end loop;
close c_emp;
end;
How do I execute a function in PL-SQL?
This is the easiest way (example):
SELECT package_name.function_name(parameters)
FROM dual;
SELECT package_name.function_name(parameters)
FROM dual;
How do I detyermine the Oracle version?
Run this PL/SQL statement:
select *
from v$version
where banner like 'Oracle%';
select *
from v$version
where banner like 'Oracle%';
Monday, 10 March 2008
Oracle and JOINS
Source: http://www.techonthenet.com/sql/joins.php
Simple INNER JOIN
SELECT suppliers.supplier_id, suppliers.supplier_name, orders.order_dateFROM suppliers, ordersWHERE suppliers.supplier_id = orders.supplier_id;
OUTER JOIN
select suppliers.supplier_id, suppliers.supplier_name, orders.order_datefrom suppliers, orderswhere suppliers.supplier_id = orders.supplier_id(+);
This SQL statement would return all rows from the suppliers table and only those rows from the orders table where the joined fields are equal.
The (+) after the orders.supplier_id field indicates that, if a supplier_id value in the suppliers table does not exist in the orders table, all fields in the orders table will display as in the result set.
Simple INNER JOIN
SELECT suppliers.supplier_id, suppliers.supplier_name, orders.order_dateFROM suppliers, ordersWHERE suppliers.supplier_id = orders.supplier_id;
OUTER JOIN
select suppliers.supplier_id, suppliers.supplier_name, orders.order_datefrom suppliers, orderswhere suppliers.supplier_id = orders.supplier_id(+);
This SQL statement would return all rows from the suppliers table and only those rows from the orders table where the joined fields are equal.
The (+) after the orders.supplier_id field indicates that, if a supplier_id value in the suppliers table does not exist in the orders table, all fields in the orders table will display as
Friday, 7 March 2008
What is an Oracle Schema?
This is an extract from Chapter 8: Managing Schema Objects
A schema is a collection of database objects. A schema is owned by a database user and has the same name as that user. Schema objects are logical structures created by users to contain, or reference, their data. Schema objects include structures like tables, views, and indexes. You can create and manipulate schema objects using Oracle Enterprise Manager.
VS2005 Solution Port Numbers
This article describes how port numbers are assigned and used in Visual Studio 2005 solutions using the built in web server. It also describes how to change the port number for certain solutions.
How to set the default port for a File System web in Visual Studio 2005
How to set the default port for a File System web in Visual Studio 2005
VS2005 build fails "Access Denied" on temporary .NET files
I was trying to build my solution and it kept on failing because of the following error:
The solution was to give Write persmissions to the Users group for the Temporary .NET Folder.
Write permission - c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
Error 62 Access to the path 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\dh.shop\1cf3210c\90e45f72\resources.ordering.fr-fr.resources' is denied. C:\GroupDSG\Development\Code\dh\dh.Shop\App_GlobalResources\Ordering.fr-FR.resx 1
The solution was to give Write persmissions to the Users group for the Temporary .NET Folder.
Write permission - c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
Thursday, 6 March 2008
PL-SQL example with exception handling
DECLARE
searchKey VARCHAR2(100) := '';
valueFound NVARCHAR2(2000);
BEGIN
SELECT value INTO valueFound
FROM cmn_cf_configuration
WHERE key = searchKey;
dbms_output.put_line('Search key : ' || searchKey || ' returned ' || valueFound);
EXCEPTION
WHEN NO_DATA_FOUND
THEN dbms_output.put_line('Search key : ' || searchKey || ' returned no data');
WHEN OTHERS
THEN RAISE_APPLICATION_ERROR(-20011, 'Unknown error');
END;
searchKey VARCHAR2(100) := '';
valueFound NVARCHAR2(2000);
BEGIN
SELECT value INTO valueFound
FROM cmn_cf_configuration
WHERE key = searchKey;
dbms_output.put_line('Search key : ' || searchKey || ' returned ' || valueFound);
EXCEPTION
WHEN NO_DATA_FOUND
THEN dbms_output.put_line('Search key : ' || searchKey || ' returned no data');
WHEN OTHERS
THEN RAISE_APPLICATION_ERROR(-20011, 'Unknown error');
END;
Typical PL/SQL Query
DECLARE
x NUMBER;
z NUMBER;
a NUMBER;
y VARCHAR2(100) := 'Shane';
BEGIN
x := 73600;
z := 26378.234;
a := x + z;
dbms_output.put_line(y || ' says ' || x || '+' || z || '=' || a);
END;
|| - Is a string concatenator.
x NUMBER;
z NUMBER;
a NUMBER;
y VARCHAR2(100) := 'Shane';
BEGIN
x := 73600;
z := 26378.234;
a := x + z;
dbms_output.put_line(y || ' says ' || x || '+' || z || '=' || a);
END;
|| - Is a string concatenator.
Anti-flicker background in IE6 only
Great script (http://www.hedgerwow.com/360/bugs/dom-fix-ie6-background-image-flicker.html):
script
function(){
/*Use Object Detection to detect IE6*/
var m = document.uniqueID /*IE*/
&& document.compatMode /*>=IE6*/
&& !window.XMLHttpRequest /*<=IE6*/
&& document.execCommand ;
try{
if(!!m){
m("BackgroundImageCache", false, true) /* = IE6 only */ }
}catch(oh){}; })();
/script
script
function(){
/*Use Object Detection to detect IE6*/
var m = document.uniqueID /*IE*/
&& document.compatMode /*>=IE6*/
&& !window.XMLHttpRequest /*<=IE6*/
&& document.execCommand ;
try{
if(!!m){
m("BackgroundImageCache", false, true) /* = IE6 only */ }
}catch(oh){}; })();
/script
Sunday, 2 March 2008
Culture and UI Culture
In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.
Subscribe to:
Posts (Atom)