Sample code:
1. Generate the Proxy with the /async switch
e.g.: svcutil.exe /serializer:DataContractSerializer /async /out:ServiceProxy.cs, "https://www.abcd.com/ServiceHost/UserManagement.svc"
2. Instantiate the proxy client:
e.g.:
UserManagementClient userClient = null;
endPtKey = "UserManagement_WindowsEndpoint";
userClient = new PartnerContactManagementClient(endPtKey);
User[] users = null;
3. Declare and Instantiate the manualresetEvents
e.g.:
ManualResetEvent[] handles = new ManualResetEvent[2];
handles[0] = new ManualResetEvent(false);
handles[1] = new ManualResetEvent(false);
4. Use the BeginXXX / EndXXX way of invoking aync calls:
(The following example is made using anonymous methods, so that we can use the local variables.)
e.g.:
AsyncCallback contactAsyncCallback = delegate(IAsyncResult userResult)
{
try
{
users = userClient.EndLookupUser userResult);
}
catch (Exception ex)
{
exceptions.Add(ex);
}
finally
{
////Set the waithandle signal to true
handles[0].Set();
}
};
////The Begin Invoke Call
int userId = "12345";
contactClient.BeginLookupUser(userId, contactAsyncCallback, null);
5. Make the second such Async call:
e.g.:
UserRoles[] userRoles = null;
AsyncCallback roleAsyncCallback = delegate(IAsyncResult roleResult)
{
try
{
userRoles = userClient.EndLookupUserRoles(roleResult);
}
catch (Exception ex)
{
exceptions.Add(ex);
}
finally
{
////Set the waithandle signal to true
handles[1].Set();
}
};
userClient.BeginLookupUserRole(userid, accountAsyncCallback, null);
6. Wait for the Calls to return:
e.g.:
WaitHandle.WaitAll(handles);
////At this point both the reset event would join back
////Close both the handles manually
handles[0].Close();
handles[1].Close();
////Write the follow up code
Software Development : A dizzy job...keeping abreast and being competitive is a 24X7 involvement
Sep 13, 2010
Sep 3, 2010
Patterns and Practices: Microsoft Application Blocks
List of all the Microsoft Application Blocks:
1. Data Access Application Block v 2.0:
http://www.microsoft.com/downloads/details.aspx?FamilyId=F63D1F0A-9877-4A7B-88EC-0426B48DF275&displaylang=en
The Data Access Application Block encapsulates performance and resource management best practices and can easily be used as a building block in your own .NET application. If you use it, you will reduce the amount of custom code you need to create, test and maintain.
==========================================================
2. Exception Management Application Block:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=8CA8EB6E-6F4A-43DF-ADEB-8F22CA173E02
The Exception Management Application Block provides a simple yet extensible framework for handling exceptions. With a single line of application code you can easily log exception information to the Event Log or extend it by creating your own components that log exception details to other data sources or notify operators, without affecting your application code. The Exception Management Application Block can easily be used as a building block in your own .NET application.
=======================================================
3. Authorization and Profile Application Block :
http://www.microsoft.com/downloads/details.aspx?familyid=ba983ad5-e74f-4be9-b146-9d2d2c6f8e81&displaylang=en
The Authorization and Profile Application Block provides you with an infrastructure for role-based authorization and access to profile information.
===================================================
4. Aggregation Application Block:
http://microsoft.com/downloads/details.aspx?FamilyId=9058F345-E5FE-42FC-B40B-14EBDD182F48&displaylang=en
The Aggregation Application Block is a .NET Framework extension that allows you to easily manage and coalesce information from various service providers and other systems and present that information to users.
======================================================
5. Asyncronous invocation application block:
http://msdn.microsoft.com/library/en-us/dnpag/html/PAIBlock.asp?frame=true
======================================================
6. Configuration Management Application Block :
http://www.microsoft.com/downloads/details.aspx?familyid=85cb1c53-8ca7-4a92-85e3-e4795bd27feb
The Configuration Management Application Block is an easy to use mechanism through which you can read and write application configuration data.
======================================================
7. Updater Application Block:
http://www.microsoft.com/downloads/details.aspx?familyid=c6c17f3a-d957-4b17-9b97-296fb4927c30
In medium to large organizations, it is common to want to keep all instances of a desktop application up to date with the latest version of executables, libraries, and other files. The Updater Application Block provides an extensible framework that companies can use to create updateable applications
======================================================
8. User Interface Processes Application Block v 2.0:
http://www.microsoft.com/downloads/details.aspx?FamilyId=98C6CC9D-88E1-4490-8BD6-78092A0F084E&displaylang=en
The User Interface Process Application Block provides a simple yet extensible framework for developing user interface processes. It is designed to abstract the control flow and state management out of the user interface layer into a user interface process layer.
=====================================================
9. Web Services Facade for legacy applications:
http://msdn.microsoft.com/library/en-us/dnpag/html/WSFacadeLegacyApp.asp?frame=true
=====================================================
10. Caching Application Block:
http://microsoft.com/downloads/details.aspx?FamilyId=B55164C9-94C8-4077-AA29-AFE4074746DE&displaylang=en
The Caching Application Block has been designed to encapsulate Microsoft's recommended best practices for caching in .NET applications
=====================================================
11. Smart Client Offline Application Block:
http://www.microsoft.com/downloads/details.aspx?FamilyId=BD864EB5-56B3-43A5-A964-6F23566DF0AB&displaylang=en
The Offline Application Block, is intended to serve as an architectural model for developers who want to add offline capabilities to their smart client applications.
=====================================================
12. Logging Application Block:
http://www.microsoft.com/downloads/details.aspx?FamilyId=24F61845-E56C-42D6-BBD5-29F0D5CD7F65&displaylang=en
This block is a reusable code component that uses the Microsoft Enterprise Instrumentation Framework (EIF) and the Microsoft .NET Framework to help you design instrumented applications.
=======================================================
13. Persistent Asynchronous Invocation Application Block :
http://microsoft.com/downloads/details.aspx?FamilyId=794EC811-B5EA-46AE-BAA4-69A3DEADD38E&displaylang=en
The Microsoft Asynchronous Invocation Application Block manages asynchronous communication between a Web client and one or more foreign service providers (FSP).
===========================================================
Other important links:
1. Microsoft Patterns and Practices Application Blocks and Enterprise Library, in ASP.Net Forums :
http://forums.asp.net/122.aspx
2. An Introduction and Overview of the Microsoft Application Blocks, in 4GuysFromRolla.com :
http://www.4guysfromrolla.com/articles/062503-1.aspx
3. Patterns and Practices in Msdn :
http://www.4guysfromrolla.com/articles/062503-1.aspx
4. Microsoft Enterprise Library 5.0 – April 2010 in Msdn:
http://msdn.microsoft.com/en-us/library/ff632023.aspx
5. Microsoft Enterprise Library 5.0 – April 2010 in Codeplex:
http://entlib.codeplex.com/
http://entlib.codeplex.com/wikipage?title=EntLib5%20Beta1
1. Data Access Application Block v 2.0:
http://www.microsoft.com/downloads/details.aspx?FamilyId=F63D1F0A-9877-4A7B-88EC-0426B48DF275&displaylang=en
The Data Access Application Block encapsulates performance and resource management best practices and can easily be used as a building block in your own .NET application. If you use it, you will reduce the amount of custom code you need to create, test and maintain.
==========================================================
2. Exception Management Application Block:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=8CA8EB6E-6F4A-43DF-ADEB-8F22CA173E02
The Exception Management Application Block provides a simple yet extensible framework for handling exceptions. With a single line of application code you can easily log exception information to the Event Log or extend it by creating your own components that log exception details to other data sources or notify operators, without affecting your application code. The Exception Management Application Block can easily be used as a building block in your own .NET application.
=======================================================
3. Authorization and Profile Application Block :
http://www.microsoft.com/downloads/details.aspx?familyid=ba983ad5-e74f-4be9-b146-9d2d2c6f8e81&displaylang=en
The Authorization and Profile Application Block provides you with an infrastructure for role-based authorization and access to profile information.
===================================================
4. Aggregation Application Block:
http://microsoft.com/downloads/details.aspx?FamilyId=9058F345-E5FE-42FC-B40B-14EBDD182F48&displaylang=en
The Aggregation Application Block is a .NET Framework extension that allows you to easily manage and coalesce information from various service providers and other systems and present that information to users.
======================================================
5. Asyncronous invocation application block:
http://msdn.microsoft.com/library/en-us/dnpag/html/PAIBlock.asp?frame=true
======================================================
6. Configuration Management Application Block :
http://www.microsoft.com/downloads/details.aspx?familyid=85cb1c53-8ca7-4a92-85e3-e4795bd27feb
The Configuration Management Application Block is an easy to use mechanism through which you can read and write application configuration data.
======================================================
7. Updater Application Block:
http://www.microsoft.com/downloads/details.aspx?familyid=c6c17f3a-d957-4b17-9b97-296fb4927c30
In medium to large organizations, it is common to want to keep all instances of a desktop application up to date with the latest version of executables, libraries, and other files. The Updater Application Block provides an extensible framework that companies can use to create updateable applications
======================================================
8. User Interface Processes Application Block v 2.0:
http://www.microsoft.com/downloads/details.aspx?FamilyId=98C6CC9D-88E1-4490-8BD6-78092A0F084E&displaylang=en
The User Interface Process Application Block provides a simple yet extensible framework for developing user interface processes. It is designed to abstract the control flow and state management out of the user interface layer into a user interface process layer.
=====================================================
9. Web Services Facade for legacy applications:
http://msdn.microsoft.com/library/en-us/dnpag/html/WSFacadeLegacyApp.asp?frame=true
=====================================================
10. Caching Application Block:
http://microsoft.com/downloads/details.aspx?FamilyId=B55164C9-94C8-4077-AA29-AFE4074746DE&displaylang=en
The Caching Application Block has been designed to encapsulate Microsoft's recommended best practices for caching in .NET applications
=====================================================
11. Smart Client Offline Application Block:
http://www.microsoft.com/downloads/details.aspx?FamilyId=BD864EB5-56B3-43A5-A964-6F23566DF0AB&displaylang=en
The Offline Application Block, is intended to serve as an architectural model for developers who want to add offline capabilities to their smart client applications.
=====================================================
12. Logging Application Block:
http://www.microsoft.com/downloads/details.aspx?FamilyId=24F61845-E56C-42D6-BBD5-29F0D5CD7F65&displaylang=en
This block is a reusable code component that uses the Microsoft Enterprise Instrumentation Framework (EIF) and the Microsoft .NET Framework to help you design instrumented applications.
=======================================================
13. Persistent Asynchronous Invocation Application Block :
http://microsoft.com/downloads/details.aspx?FamilyId=794EC811-B5EA-46AE-BAA4-69A3DEADD38E&displaylang=en
The Microsoft Asynchronous Invocation Application Block manages asynchronous communication between a Web client and one or more foreign service providers (FSP).
===========================================================
Other important links:
1. Microsoft Patterns and Practices Application Blocks and Enterprise Library, in ASP.Net Forums :
http://forums.asp.net/122.aspx
2. An Introduction and Overview of the Microsoft Application Blocks, in 4GuysFromRolla.com :
http://www.4guysfromrolla.com/articles/062503-1.aspx
3. Patterns and Practices in Msdn :
http://www.4guysfromrolla.com/articles/062503-1.aspx
4. Microsoft Enterprise Library 5.0 – April 2010 in Msdn:
http://msdn.microsoft.com/en-us/library/ff632023.aspx
5. Microsoft Enterprise Library 5.0 – April 2010 in Codeplex:
http://entlib.codeplex.com/
http://entlib.codeplex.com/wikipage?title=EntLib5%20Beta1
Sep 2, 2010
Aug 6, 2010
Configuring Your ASP.NET 2.0 Site
1. For configuration of Asp.net applications and Web sites and for Role Management: (Use the default WSAT tool)
http://www.developer.com/net/asp/article.php/3569166/Configuring-Your-ASPNET-20-Site.htm
2. For configuring the Asp.Net MVC Applicationsand for Role Management: (Use the MVC WSAT tool)
http://wsat.codeplex.com/
3. For Configuring WCF Roles:
http://weblogs.asp.net/spano/archive/2007/03/12/how-to-implement-a-wcf-authorization-manager-using-azman.aspx
http://www.developer.com/net/asp/article.php/3569166/Configuring-Your-ASPNET-20-Site.htm
2. For configuring the Asp.Net MVC Applicationsand for Role Management: (Use the MVC WSAT tool)
http://wsat.codeplex.com/
3. For Configuring WCF Roles:
http://weblogs.asp.net/spano/archive/2007/03/12/how-to-implement-a-wcf-authorization-manager-using-azman.aspx
Problem: Intellisense missing in Visual Studio
Setup Web Admin Tool for Production Servers
I have been able installed WebAdminTool for Production Servers using the following steps:
Create a virtual directory ASP.NETWebAdminFiles in IIS that point to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles
Open properties windows of the new virtual directory, make sure that it is configured to run with ASP.NET 2.0, and in Security tab, uncheck Anonymous Access, check Integrated Windows Authentication.
After that, you will be able to connect to WebAdminTools using the following syntax
http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=XXX&applicationUrl=/YYY
in my case, it is:
http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=D:\Tasks\Libranyon\Photonyon\&applicationUrl=/Photonyon
Although I don't recommend to do it, if you want to access WebAdminTool from other computer, open WebAdminPage.cs from (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles\App_Code) and comment the following code block
if (!application.Context.Request.IsLocal) {
SecurityException securityException = new SecurityException((string)HttpContext.GetGlobalResourceObject("GlobalResources", "WebAdmin_ConfigurationIsLocalOnly"));
WebAdminPage.SetCurrentException(application.Context, securityException);
application.Server.Transfer("~/error.aspx");
}
WebAdminTool still be protected by Intergrated Windows Authentication, so you still some have some defense here.
Create a virtual directory ASP.NETWebAdminFiles in IIS that point to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles
Open properties windows of the new virtual directory, make sure that it is configured to run with ASP.NET 2.0, and in Security tab, uncheck Anonymous Access, check Integrated Windows Authentication.
After that, you will be able to connect to WebAdminTools using the following syntax
http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=XXX&applicationUrl=/YYY
in my case, it is:
http://localhost/ASP.NETWebAdminFiles/default.aspx?applicationPhysicalPath=D:\Tasks\Libranyon\Photonyon\&applicationUrl=/Photonyon
Although I don't recommend to do it, if you want to access WebAdminTool from other computer, open WebAdminPage.cs from (C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ASP.NETWebAdminFiles\App_Code) and comment the following code block
if (!application.Context.Request.IsLocal) {
SecurityException securityException = new SecurityException((string)HttpContext.GetGlobalResourceObject("GlobalResources", "WebAdmin_ConfigurationIsLocalOnly"));
WebAdminPage.SetCurrentException(application.Context, securityException);
application.Server.Transfer("~/error.aspx");
}
WebAdminTool still be protected by Intergrated Windows Authentication, so you still some have some defense here.
Subscribe to:
Posts (Atom)