Good article to read on Microsoft MSDN site-
http://msdn.microsoft.com/en-us/library/ms731059.aspx
.NET architecture, programming tips and tricks around Microsoft technology stack - Azure, WCF Services, SQL and strategy work.
Wednesday, May 21, 2008
How to implement SQL notifications in .net?
How do i notify the .net client when data changes in SQL server backend?
How to implement SQL notifications in .net easy way?
Query Notification, a collaboration between Microsoft’s ADO.NET and SQL Server teams. In a nutshell, Query Notification allows you to cache data and be notified when the data has been changed in SQL Server. Upon notification, you can then refresh your cache or take whatever action you need to.
Query Notification is possible because of a new feature in SQL Server 2005 called Service Broker. Service Broker puts queuing functionality into the database with a coordination of queues that communicate with services that, in turn, know how to communicate back to the calling entity. The queues and services are first class objects just as tables, views, and stored procedures are. Although Service Broker can be leveraged completely within SQL Server, ADO.NET knows how to communicate with Service Broker to trigger this mechanism and retrieve the notifications back from the Service Broker.
On the .NET side, there are a number of ways of hooking into this functionality. ADO.NET 2.0 provides the System.Data.SqlClient.SqlDependency and System.Data.Sql.SqlNotificationRequest classes. SqlDependency is a higher-level implementation of SqlNotificationRequest and is most likely the one you will use when working with ADO.NET 2.0. ASP.NET 2.0 also communicates with Service Broker through the System.Web.Caching.SqlCache-Dependency class (that provides a wrapper around SqlDependency), as well as directly through functionality provided declaratively in an ASP.NET page using the <%OutputCache> directive. This allows ASP.NET developers to easily invalidate caches that are dependent on data from SQL Server.
Read this article for implementation details - http://www.code-magazine.com/Article.aspx?quickid=0605061
Credits: I got the pleasure of working with Jeff Clark for a short stint though at Avanade recently and i learnt quite a few things from him...
How to implement SQL notifications in .net easy way?
Query Notification, a collaboration between Microsoft’s ADO.NET and SQL Server teams. In a nutshell, Query Notification allows you to cache data and be notified when the data has been changed in SQL Server. Upon notification, you can then refresh your cache or take whatever action you need to.
Query Notification is possible because of a new feature in SQL Server 2005 called Service Broker. Service Broker puts queuing functionality into the database with a coordination of queues that communicate with services that, in turn, know how to communicate back to the calling entity. The queues and services are first class objects just as tables, views, and stored procedures are. Although Service Broker can be leveraged completely within SQL Server, ADO.NET knows how to communicate with Service Broker to trigger this mechanism and retrieve the notifications back from the Service Broker.
On the .NET side, there are a number of ways of hooking into this functionality. ADO.NET 2.0 provides the System.Data.SqlClient.SqlDependency and System.Data.Sql.SqlNotificationRequest classes. SqlDependency is a higher-level implementation of SqlNotificationRequest and is most likely the one you will use when working with ADO.NET 2.0. ASP.NET 2.0 also communicates with Service Broker through the System.Web.Caching.SqlCache-Dependency class (that provides a wrapper around SqlDependency), as well as directly through functionality provided declaratively in an ASP.NET page using the <%OutputCache> directive. This allows ASP.NET developers to easily invalidate caches that are dependent on data from SQL Server.
Read this article for implementation details - http://www.code-magazine.com/Article.aspx?quickid=0605061
Credits: I got the pleasure of working with Jeff Clark for a short stint though at Avanade recently and i learnt quite a few things from him...
how to raise and handle events/callbacks in .net?
How to implement and respond to Events in .net ?
In the following example, you'll create a class library containing a class that raises a pair of events. Then you'll create a user interface application that can respond to those events. You'll use both compile time event association with Handles and run-time event association with AddHandler.
Create the Class Library
Follow these steps to create the class library that will raise the events:
Open Microsoft® Visual Studio® .Net, and on the Start Page, click New Project.
On the tree view on the left-hand side of the screen, click Visual Basic Projects.
Click Class Library to select it as the project template.
Set the name of the application to Water and click OK to create the project.
Click the class called Class1.vb in the Solution Explorer window and rename it to Bucket.vb.
Select the code for Class1 in Bucket.vb (this will be an empty class definition) and replace it with the following code:
Class Bucket
Private ContentsValue As Integer
Private CapacityValue As Integer
Private NameValue As String
Public Event Full()
Public Event Overflowing(_
ByVal sender As System.Object)
Public Sub New(ByVal Capacity As Integer)
mintCapacity = Capacity
mintContents = 0
End Sub
Public Sub Empty()
mintContents = 0
End Sub
Public ReadOnly Property Contents()
Get
Contents = mintContents
End Get
End Property
Public Property Name() As String
Get
Name = mstrName
End Get
Set(ByVal Value As String)
mstrName = Value
End Set
End Property
Public Sub Add(ByVal Amount As Integer)
mintContents = mintContents + Amount
If mintContents > mintCapacity Then
RaiseEvent Overflowing(Me)
mintContents = mintCapacity
ElseIf mintContents = mintCapacity Then
RaiseEvent Full()
End If
End Sub
End Class
This code creates a class named Bucket to represent a bucket that can be filled with water. The New method initializes the bucket with a specified capacity. The Name property assigns a name to the bucket. The Add method adds water to the bucket, and the Empty method empties the bucket.
The Bucket class includes two event declarations:
Public Event Full()
Public Event Overflowing(_
ByVal sender As System.Object)
These two events are both raised within the Add method. If the amount of water in the bucket exceeds the capacity of the bucket, the code raises the Overflowing event. Otherwise, if the amount of water in the bucket exactly equals the capacity of the bucket, the code raises the Full event.
Note that the argument lists of the two events are different. You have complete flexibility to pass whatever information you need in any particular event.
On the Build menu, click Build or press Ctrl+Shift+B to build the class library.
Create the User Interface Project
Follow these steps to create a Windows Application to test the events of the Bucket class:
Open Visual Studio .Net and on the Start Page, click New Project.
On the tree view on the left-hand side of the screen, click Visual Basic Projects.
Click Windows Application to set it as the project template.
Set the name of the application to BucketTest and click OK to create the project.
Select the form called Form1.vb in the Solution Explorer window and rename it to frmBuckets.vb.
Create the form by adding the appropriate controls and setting the properties of those controls.
Add Code to Handle Events
Now you're ready to write code to handle the events from the Bucket class. This code will create three objects of the Bucket class. The Full events will be individually connected to event handlers at compile time using Handles. The Overflow events will all be handled by a single procedure, dynamically associated with the events at run time by using AddHandler.
On the View menu, click Code, and enter this code before the Windows Form Designer generated code:
Dim WithEvents Bucket1 As New Water.Bucket(10)
Dim WithEvents Bucket2 As New Water.Bucket(10)
Dim WithEvents Bucket3 As New Water.Bucket(10)
Now enter this code after the Windows Form Designer generated code:
Private Sub Form1_Load(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Bucket1.Name = "Bucket 1"
Bucket2.Name = "Bucket 2"
Bucket3.Name = "Bucket 3"
AddHandler Bucket1.Overflowing, _
AddressOf HandleOverflow
AddHandler Bucket2.Overflowing, _
AddressOf HandleOverflow
AddHandler Bucket3.Overflowing, _
AddressOf HandleOverflow
End Sub
Private Sub btnAdd1_Click(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd1.Click
Bucket1.Add(1)
pb1.Value = Bucket1.Contents
End Sub
Private Sub btnAdd2_Click(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd2.Click
Bucket2.Add(1)
pb2.Value = Bucket2.Contents
End Sub
Private Sub btnAdd3_Click(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd3.Click
Bucket3.Add(1)
pb3.Value = Bucket3.Contents
End Sub
Private Sub Bucket1_Full() Handles Bucket1.Full
lblFull1.Visible = True
End Sub
Private Sub Bucket2_Full() Handles Bucket2.Full
lblFull2.Visible = True
End Sub
Private Sub Bucket3_Full() Handles Bucket3.Full
lblFull3.Visible = True
End Sub
Private Sub HandleOverflow(_
ByVal sender As System.Object)
lboOverflow.Items.Add(sender.Name & " Overflow!")
End Sub
Read more on this msdn site where you will find this example and details - :
http://msdn.microsoft.com/en-us/library/ms973905.aspx
In the following example, you'll create a class library containing a class that raises a pair of events. Then you'll create a user interface application that can respond to those events. You'll use both compile time event association with Handles and run-time event association with AddHandler.
Create the Class Library
Follow these steps to create the class library that will raise the events:
Open Microsoft® Visual Studio® .Net, and on the Start Page, click New Project.
On the tree view on the left-hand side of the screen, click Visual Basic Projects.
Click Class Library to select it as the project template.
Set the name of the application to Water and click OK to create the project.
Click the class called Class1.vb in the Solution Explorer window and rename it to Bucket.vb.
Select the code for Class1 in Bucket.vb (this will be an empty class definition) and replace it with the following code:
Class Bucket
Private ContentsValue As Integer
Private CapacityValue As Integer
Private NameValue As String
Public Event Full()
Public Event Overflowing(_
ByVal sender As System.Object)
Public Sub New(ByVal Capacity As Integer)
mintCapacity = Capacity
mintContents = 0
End Sub
Public Sub Empty()
mintContents = 0
End Sub
Public ReadOnly Property Contents()
Get
Contents = mintContents
End Get
End Property
Public Property Name() As String
Get
Name = mstrName
End Get
Set(ByVal Value As String)
mstrName = Value
End Set
End Property
Public Sub Add(ByVal Amount As Integer)
mintContents = mintContents + Amount
If mintContents > mintCapacity Then
RaiseEvent Overflowing(Me)
mintContents = mintCapacity
ElseIf mintContents = mintCapacity Then
RaiseEvent Full()
End If
End Sub
End Class
This code creates a class named Bucket to represent a bucket that can be filled with water. The New method initializes the bucket with a specified capacity. The Name property assigns a name to the bucket. The Add method adds water to the bucket, and the Empty method empties the bucket.
The Bucket class includes two event declarations:
Public Event Full()
Public Event Overflowing(_
ByVal sender As System.Object)
These two events are both raised within the Add method. If the amount of water in the bucket exceeds the capacity of the bucket, the code raises the Overflowing event. Otherwise, if the amount of water in the bucket exactly equals the capacity of the bucket, the code raises the Full event.
Note that the argument lists of the two events are different. You have complete flexibility to pass whatever information you need in any particular event.
On the Build menu, click Build or press Ctrl+Shift+B to build the class library.
Create the User Interface Project
Follow these steps to create a Windows Application to test the events of the Bucket class:
Open Visual Studio .Net and on the Start Page, click New Project.
On the tree view on the left-hand side of the screen, click Visual Basic Projects.
Click Windows Application to set it as the project template.
Set the name of the application to BucketTest and click OK to create the project.
Select the form called Form1.vb in the Solution Explorer window and rename it to frmBuckets.vb.
Create the form by adding the appropriate controls and setting the properties of those controls.
Add Code to Handle Events
Now you're ready to write code to handle the events from the Bucket class. This code will create three objects of the Bucket class. The Full events will be individually connected to event handlers at compile time using Handles. The Overflow events will all be handled by a single procedure, dynamically associated with the events at run time by using AddHandler.
On the View menu, click Code, and enter this code before the Windows Form Designer generated code:
Dim WithEvents Bucket1 As New Water.Bucket(10)
Dim WithEvents Bucket2 As New Water.Bucket(10)
Dim WithEvents Bucket3 As New Water.Bucket(10)
Now enter this code after the Windows Form Designer generated code:
Private Sub Form1_Load(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Bucket1.Name = "Bucket 1"
Bucket2.Name = "Bucket 2"
Bucket3.Name = "Bucket 3"
AddHandler Bucket1.Overflowing, _
AddressOf HandleOverflow
AddHandler Bucket2.Overflowing, _
AddressOf HandleOverflow
AddHandler Bucket3.Overflowing, _
AddressOf HandleOverflow
End Sub
Private Sub btnAdd1_Click(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd1.Click
Bucket1.Add(1)
pb1.Value = Bucket1.Contents
End Sub
Private Sub btnAdd2_Click(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd2.Click
Bucket2.Add(1)
pb2.Value = Bucket2.Contents
End Sub
Private Sub btnAdd3_Click(_
ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles btnAdd3.Click
Bucket3.Add(1)
pb3.Value = Bucket3.Contents
End Sub
Private Sub Bucket1_Full() Handles Bucket1.Full
lblFull1.Visible = True
End Sub
Private Sub Bucket2_Full() Handles Bucket2.Full
lblFull2.Visible = True
End Sub
Private Sub Bucket3_Full() Handles Bucket3.Full
lblFull3.Visible = True
End Sub
Private Sub HandleOverflow(_
ByVal sender As System.Object)
lboOverflow.Items.Add(sender.Name & " Overflow!")
End Sub
Read more on this msdn site where you will find this example and details - :
http://msdn.microsoft.com/en-us/library/ms973905.aspx
Tuesday, May 20, 2008
Designing and working with Spatial data type in SQL 2008
One of the interesting feature of SQL 2008 that had my eye balls rolling was the introduction of Spatial data type/Column.
SQL Server 2008 and later versions support spatial data. This includes support for a planar spatial data type, geometry, which supports geometric data—points, lines, and polygons—within a Euclidean coordinate system. The geography data type represents geographic objects on an area on the Earth's surface, such as a spread of land. A spatial index on a geography column maps the geographic data to a two-dimensional, non-Euclidean space.
A spatial index is defined on a table column that contains spatial data (a spatial column). Each spatial index refers to a finite space. For example, an index for a geometry column refers to a user-specified rectangular area on a plane.
Here's more to it on msdn - http://msdn.microsoft.com/en-us/library/bb964712(SQL.100).aspx
Here's all that you wanted to know on designing and working with Spatial data type in SQL 2008 - http://msdn.microsoft.com/en-us/library/bb933790(SQL.100).aspx
SQL Server 2008 and later versions support spatial data. This includes support for a planar spatial data type, geometry, which supports geometric data—points, lines, and polygons—within a Euclidean coordinate system. The geography data type represents geographic objects on an area on the Earth's surface, such as a spread of land. A spatial index on a geography column maps the geographic data to a two-dimensional, non-Euclidean space.
A spatial index is defined on a table column that contains spatial data (a spatial column). Each spatial index refers to a finite space. For example, an index for a geometry column refers to a user-specified rectangular area on a plane.
Here's more to it on msdn - http://msdn.microsoft.com/en-us/library/bb964712(SQL.100).aspx
Here's all that you wanted to know on designing and working with Spatial data type in SQL 2008 - http://msdn.microsoft.com/en-us/library/bb933790(SQL.100).aspx
How to connect to other SQL Server from SQL Server 2005 (using linked list)?
Whenever you want to connect the other SQL Server from SQL Server 2005(using linked list), use the NATIVE CLIENT.
Read more about native client - http://msdn2.microsoft.com/en-us/library/ms131456.aspx
Read more about native client - http://msdn2.microsoft.com/en-us/library/ms131456.aspx
Wednesday, May 14, 2008
Accenture and Avanade announced the availability of its first retail showcase application for Microsoft Surface....
Accenture (NYSE: ACN) and Avanade Inc. announced the availability of its first retail showcase application for Microsoft SurfaceTM. This new application has the potential to transform the shopping experience by using Microsoft Surface to improve customer loyalty, allow customers to better understand complex purchases, build customer relationships and increase add-on sales. Read more here ... http://newsroom.accenture.com/article_display.cfm?article_id=4651
Regards - Dipesh
Regards - Dipesh
Third major release of Windows Presentation Foundation (WPF)
Microsoft introducing the third major release of Windows Presentation Foundation (WPF)
http://blogs.msdn.com/tims/archive/2008/05/12/introducing-the-third-major-release-of-windows-presentation-foundation.aspx
Regards - Dipesh
http://blogs.msdn.com/tims/archive/2008/05/12/introducing-the-third-major-release-of-windows-presentation-foundation.aspx
Regards - Dipesh
Thursday, May 01, 2008
WSE and WCF
Applications built using WSE 1.0 and WSE 2.0 won't interoperate with applications built on WCF and some effort is required to move existing WSE code to new Windows Communication Foundation framework.
Applications built on WSE 3.0, will interoperate with WCF applications, however!
Applications built on WSE 3.0, will interoperate with WCF applications, however!
Tuesday, April 08, 2008
Microsoft Dynamics CRM 4.0 Performance Toolkit
The Microsoft Dynamics CRM 4.0 Performance Toolkit was created by the Microsoft CRM product team to formalize testing of Microsoft CRM 4.0. The performance toolkit is intended to be used by partners and customers to collect data to support their CRM deployment decisions.
Some of the enhancements made to the toolkit are:
1. Multi Organization Performance Testing Support
2. Multi Server Deployment Performance Testing Support
3. Outlook Synchronization and Offline Performance Testing Support
4. Data Management Performance Testing Support
5. Workflow Performance Analysis Support
6. Email Matching Performance Testing Support
7. Ease of deployment of the Toolkit through an MSI package with enhanced configuration of the toolkit.
The Performance toolkit contains various tools listed below that can be used in customizing the CRM installation, populating the necessary semantic data for the required scale and conducting the benchmarking tests against the CRM installation. The tools provided in the Performance toolkit are:
1. ImportCustomization Tool
2. DbPopulator Tool
3. CRM_Perf_Benchmark Tool
Here's the link on codeplex for complete details - http://www.codeplex.com/crmperftoolkit
Regards - Dj
Some of the enhancements made to the toolkit are:
1. Multi Organization Performance Testing Support
2. Multi Server Deployment Performance Testing Support
3. Outlook Synchronization and Offline Performance Testing Support
4. Data Management Performance Testing Support
5. Workflow Performance Analysis Support
6. Email Matching Performance Testing Support
7. Ease of deployment of the Toolkit through an MSI package with enhanced configuration of the toolkit.
The Performance toolkit contains various tools listed below that can be used in customizing the CRM installation, populating the necessary semantic data for the required scale and conducting the benchmarking tests against the CRM installation. The tools provided in the Performance toolkit are:
1. ImportCustomization Tool
2. DbPopulator Tool
3. CRM_Perf_Benchmark Tool
Here's the link on codeplex for complete details - http://www.codeplex.com/crmperftoolkit
Regards - Dj
Monday, March 31, 2008
Leader's window...
I was in SFO last few days back for "Leader's Window" training organized by my company and i was very pleased that i attended this. It was refreshing and gave my a thought on where i am suppose to head! This in turn was a good reflection on me and has motivated me to kick start a new blog in this direction... Keep watching this space for more! Cheers - Dipesh
how to setup IIS over secure communications - HTTPS/SSL?
To change websites hosted over IIS onto HTTPS/SSL we want to do this from IIS
- Obtain a server certificate.
- Specify the server certificate to a default web site in IIS.
The sever certificate could be obtained by any third party CA (credential authority) like Verisign that authenticates your web server. However, for reasons of test or with limited resources/pages access you may not want to reach out to them. In that case, the easiest way is to get an SSL from SelfSSL.exe that comes bundled with IIS resources toolkit 6.0 available from Microsoft for free!
The toolkit includes bring along many other tools but you can select only SelfSSL.exe by itself.
This is a commmand line utility which you can just execute it and say "Yes" when prompted to override any server certificate existing.
Test it by accessing https://localhost... and it should load fine.
Also, ideally this certificate be installed in your local Directory store to have IIS recognize it valid. This is applicable to IIS 5.0, 5.1 and 6.0
HTH, Thanks - Dipesh
- Obtain a server certificate.
- Specify the server certificate to a default web site in IIS.
The sever certificate could be obtained by any third party CA (credential authority) like Verisign that authenticates your web server. However, for reasons of test or with limited resources/pages access you may not want to reach out to them. In that case, the easiest way is to get an SSL from SelfSSL.exe that comes bundled with IIS resources toolkit 6.0 available from Microsoft for free!
The toolkit includes bring along many other tools but you can select only SelfSSL.exe by itself.
This is a commmand line utility which you can just execute it and say "Yes" when prompted to override any server certificate existing.
Test it by accessing https://localhost... and it should load fine.
Also, ideally this certificate be installed in your local Directory store to have IIS recognize it valid. This is applicable to IIS 5.0, 5.1 and 6.0
HTH, Thanks - Dipesh
IE 8 released
IE 8 developer preview found here - http://www.microsoft.com/windows/products/winfamily/ie/ie8/default.mspx
Visual Studio Rosario CTP
This month can definitely be termed as "March madness"... lot of things happened to me in my personal life and career life..but you bet this was all fun! I am writing this after a long halt... sorry about that, i will try to keep it more updated on regular basis!
News here is that i was still trying to get around with VS Orcas/2008 release...and have learned that Microsoft is already preparing for the next release Visual Studio Rosario...crazy ? :) Regardless, here's the link to VPC - Aug 2007 CTP if you are interested to dive in new features of Visual Studio Rosario.
http://www.microsoft.com/downloads/details.aspx?FamilyID=8450eff5-24ad-44c3-ab91-1ed88ef2f4f0&DisplayLang=en
Cheers - Dipesh
News here is that i was still trying to get around with VS Orcas/2008 release...and have learned that Microsoft is already preparing for the next release Visual Studio Rosario...crazy ? :) Regardless, here's the link to VPC - Aug 2007 CTP if you are interested to dive in new features of Visual Studio Rosario.
http://www.microsoft.com/downloads/details.aspx?FamilyID=8450eff5-24ad-44c3-ab91-1ed88ef2f4f0&DisplayLang=en
Cheers - Dipesh
Monday, March 10, 2008
What do i need to create my first WCF service?
What do you need to create a WCF service from scratch?
You can either create a WCF service in Visual Studio 2008 or you can also create a WCF Service with Visual Studio 2005 as well. What do you need ...
1> Visual Studio 2005 extensions.
2> .net 3.0 runtime (redistributable package, not Service pack release or 3.5)
This will get you the templates needed as well for you to quick start with you creating your WCF service. You can find the SDK for the same on msdn site too.
Happy servicing :) Thanks - Dipesh
You can either create a WCF service in Visual Studio 2008 or you can also create a WCF Service with Visual Studio 2005 as well. What do you need ...
1> Visual Studio 2005 extensions.
2> .net 3.0 runtime (redistributable package, not Service pack release or 3.5)
This will get you the templates needed as well for you to quick start with you creating your WCF service. You can find the SDK for the same on msdn site too.
Happy servicing :) Thanks - Dipesh
Powercommands for Visual studio 2008
Powercommands for Visual studio 2008 released...
http://blogs.msdn.com/vsxteam/archive/2008/02/29/PowerCommands-for-Visual-Studio-2008-released.aspx
Cheers - DJ
http://blogs.msdn.com/vsxteam/archive/2008/02/29/PowerCommands-for-Visual-Studio-2008-released.aspx
Cheers - DJ
Wednesday, February 20, 2008
"Service Unavailable"
How do you know if WCF is installed on your machine or if WCF is registered with IIS ?
Run ServiceModelReg.exe from your command prompt with /i option to register/reregister WCF (.net 3.5) with your IIS.
Restart your IIS and then try rerun the service...hopefully this should work or atleast conifrm that you have your machine ready to execute WCF requests.
HTH - Dipesh
Run ServiceModelReg.exe from your command prompt with /i option to register/reregister WCF (.net 3.5) with your IIS.
Restart your IIS and then try rerun the service...hopefully this should work or atleast conifrm that you have your machine ready to execute WCF requests.
HTH - Dipesh
how do i deploy/host a WCF service on remote machine?
With the task completion of hosting WCF service on machine that has installed VS 2008 and now when you are ready to deploy this on remote machine in IIS this is what you do...
1> Publish web site (option with VS 2008) that generates compiled code,
2> Copy the files on your remote machine where you want this WCF service installed,
3> Create a virtual directory and point to the physical folder where .svc files are found.
That's it! :) It's pretty much similar to the traditional web services deployment.
before you install WCF serive on any machine ensure that you have WCF and IIS installed. (IIS 6 and above). WCF is part of .net 3.0 framework. it comes along with .net 3.5 redistributable package as well.
However, here are solutions to few issues you might encounter whilst deploying...
1> After deployment you get error "Service Unavailable" in IE.
Solution - Ensure that you have sufficent rights on the physical folder from where you are executing your service (.svc) ... specially asp_net and IIS workgroup users.
2> sometimes you may just get web configuration error as you launch WCF service in IE .svc ...
Solution - You may want to try specifying custom errors tag in web.config to have exceptions as "remoteonly" so that you can understand the unhandled exceptions thrown by IIS. Sometimes, this just solves the problem...atleast solved for me :)
Previous posts on WCF - http://archdipesh.blogspot.com/search/label/WCF
Cheers - Dipesh
1> Publish web site (option with VS 2008) that generates compiled code,
2> Copy the files on your remote machine where you want this WCF service installed,
3> Create a virtual directory and point to the physical folder where .svc files are found.
That's it! :) It's pretty much similar to the traditional web services deployment.
before you install WCF serive on any machine ensure that you have WCF and IIS installed. (IIS 6 and above). WCF is part of .net 3.0 framework. it comes along with .net 3.5 redistributable package as well.
However, here are solutions to few issues you might encounter whilst deploying...
1> After deployment you get error "Service Unavailable" in IE.
Solution - Ensure that you have sufficent rights on the physical folder from where you are executing your service (.svc) ... specially asp_net and IIS workgroup users.
2> sometimes you may just get web configuration error as you launch WCF service in IE .svc ...
Solution - You may want to try specifying custom errors tag in web.config to have exceptions as "remoteonly" so that you can understand the unhandled exceptions thrown by IIS. Sometimes, this just solves the problem...atleast solved for me :)
Previous posts on WCF - http://archdipesh.blogspot.com/search/label/WCF
Cheers - Dipesh
Overcome slow performance with the initial WCF service load/call
So now when you are all set with "WCF service" deployment milestone :) do you experience slow performance on the initial call/load of the WCF service?
Yes, Scott mentioned in the .net roadmap one of the points of cold warmup perfomance fix this summer....till then Joel has this post which has attached warmup script files that overcomes this problem.
Refer his post to get attachments -
http://blogs.msdn.com/joelo/archive/2006/08/13/697044.aspx
HTH- Dipesh
Yes, Scott mentioned in the .net roadmap one of the points of cold warmup perfomance fix this summer....till then Joel has this post which has attached warmup script files that overcomes this problem.
Refer his post to get attachments -
http://blogs.msdn.com/joelo/archive/2006/08/13/697044.aspx
HTH- Dipesh
Tuesday, February 19, 2008
Scott Gu's roadmap for .net 3.5
Congratulations to Scott Guthrie first on his new role and responsibilities... he is the man! :) btw, he is on a roll with his product roadmap of .net 3.5 this summer.
You can see details on his blog here but for sure some of these changes are huge, such as speeding up cold load of .NET applications by 25%-40%, improving WPF support...and so on.
Check this - http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx
Cheers - Dipesh
You can see details on his blog here but for sure some of these changes are huge, such as speeding up cold load of .NET applications by 25%-40%, improving WPF support...and so on.
Check this - http://weblogs.asp.net/scottgu/archive/2008/02/19/net-3-5-client-product-roadmap.aspx
Cheers - Dipesh
Convert existing asmx .net web service to WCF service in .net 3.0/3.5
If you are thinking what if i already have an existing web service .asmx which are exposed to existing clients already but still want to use the new technology infrastructure then you can do it really sweet. (why you would do that...must check new features of WCF on msdn:))
So if you have existing web service like this - http://mycompany/myWebservice.asmx
Steps to have clients use .asmx extension but behind scenes use powerful WCF here they are -
1> Decorate web service class name and web method with ServiceContract and OperationContract atrributes. For this you should add reference System.ServiceModel.dll assembly that is part of .net 3.5 framework. You can download .net 3.5 framework from to have WCF services run on your machines just fine.
Once you install you should found this installed in GAC.
here's how it looks-
using System.ServiceModel;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ServiceContract(Namespace="http://tempuri.org")]
public class myWebService : System.Web.Services.WebService
{
[WebMethod]
[OperationContract]
public string HelloWorld(string name)
{
return string.Format("Hello, {0}",name);
}
}
2> add this system.serviceModel section into your existing web.config of the asmx web service -

3> you can run the web service now and it should compile and run without issues with asmx extension but one more thing you would have to do to tell .net runtime to use WCF service runtime is add buildprovider under Compilation section.

4> Last but not the least modify your markup code .asmx to have something like this -% @ServiceHost language = "c#" Service="yourNamespace.ClassnameOftheService" %
This shuold help you up and running WCF service still keeping the existing asmx extension!
If you are done ...great! After i completed all the above steps i encountered pretty wierd errors saying -
Service 'myWebservice' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
Reason - that was because my web.config had wrong endpoint service name reference.
service name="myWebService" behaviorConfiguration="returnFaults"
endpoint binding="basicHttpBinding" contract="myWebService"
Rectifying that helped...
If you still continue to get error you may also want to verify that you have your config file as web.config instead of app.config.
Hope that helps!
Here are few links for further information and references used here -
http://blogs.msdn.com/wenlong/archive/2007/09/18/how-to-use-asmx-extension-to-handle-wcf-requests.aspx
http://www.topxml.com/rbnews/WSCF/WCF/re-44738_Phased-Migration-From-ASMX-to-WCF.aspx
For more on WCF visit previous posts here - http://archdipesh.blogspot.com/search/label/WCF
Cheers - Dipesh
So if you have existing web service like this - http://mycompany/myWebservice.asmx
Steps to have clients use .asmx extension but behind scenes use powerful WCF here they are -
1> Decorate web service class name and web method with ServiceContract and OperationContract atrributes. For this you should add reference System.ServiceModel.dll assembly that is part of .net 3.5 framework. You can download .net 3.5 framework from to have WCF services run on your machines just fine.
Once you install you should found this installed in GAC.
here's how it looks-
using System.ServiceModel;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ServiceContract(Namespace="http://tempuri.org")]
public class myWebService : System.Web.Services.WebService
{
[WebMethod]
[OperationContract]
public string HelloWorld(string name)
{
return string.Format("Hello, {0}",name);
}
}
2> add this system.serviceModel section into your existing web.config of the asmx web service -
3> you can run the web service now and it should compile and run without issues with asmx extension but one more thing you would have to do to tell .net runtime to use WCF service runtime is add buildprovider under Compilation section.
4> Last but not the least modify your markup code .asmx to have something like this -% @ServiceHost language = "c#" Service="yourNamespace.ClassnameOftheService" %
This shuold help you up and running WCF service still keeping the existing asmx extension!
If you are done ...great! After i completed all the above steps i encountered pretty wierd errors saying -
Service 'myWebservice' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
Reason - that was because my web.config had wrong endpoint service name reference.
service name="myWebService" behaviorConfiguration="returnFaults"
endpoint binding="basicHttpBinding" contract="myWebService"
Rectifying that helped...
If you still continue to get error you may also want to verify that you have your config file as web.config instead of app.config.
Hope that helps!
Here are few links for further information and references used here -
http://blogs.msdn.com/wenlong/archive/2007/09/18/how-to-use-asmx-extension-to-handle-wcf-requests.aspx
http://www.topxml.com/rbnews/WSCF/WCF/re-44738_Phased-Migration-From-ASMX-to-WCF.aspx
For more on WCF visit previous posts here - http://archdipesh.blogspot.com/search/label/WCF
Cheers - Dipesh
No Web methods visible in WCF service hosted...workaround
Well, one real good thing that i liked about WCF is the ease by which you get a new WCF service running real quick. The best part is that Microsoft has provided a code template with sample methods and contracts in VS 2008. You just hit Run button and you are good to go. However, with such ease i had few problems that i ran into. First of all i started creating a WCF web service project under Web which is pretty similar to ASMX style of coding. I am still to figure out why Microsoft has provided an option to create an WCF service library (a dll for web service...huh!) Regardless, if you just run the WCF service first time ...don't be afraid if you see NONE of your web methods listed in IE for the WCF service you just created. That's by nature...ofcourse there are workarounds by which you can intercept client messages inbound and outbound. Keith has showed us a way by which you can see your web methods and actually inspect soap body and envelope going through your client.
http://keithelder.net/blog/archive/2008/01/15/How-to-Get-Around-WCFs-Lack-of-a-Preview-Web.aspx
intial post on how to start writing your own WCF service and concepts look at this video on my previous post - http://archdipesh.blogspot.com/2007/12/creating-service-with-windows.html
HTH- Dipesh
http://keithelder.net/blog/archive/2008/01/15/How-to-Get-Around-WCFs-Lack-of-a-Preview-Web.aspx
intial post on how to start writing your own WCF service and concepts look at this video on my previous post - http://archdipesh.blogspot.com/2007/12/creating-service-with-windows.html
HTH- Dipesh
Wednesday, February 13, 2008
How to post xml file or any other file onto server through .net web services?
I was in Dallas last week and working on a release of which i was not supposed to be part of it initially and then working on a Silverlight contest (still working.) btw, you too can take part in the Silverlight contest by Microsoft here -
http://silverlight.net/Showcase/
Regardless, working little bit more on web services i figured that it is absolutely ok to pass XMl as a set of string data through .net web service.
Also, i found this interesting simple article on how to upload XML or for that matter any file onto server - http://www.c-sharpcorner.com/UploadFile/scottlysle/UploadwithCSharpWS05032007121259PM/UploadwithCSharpWS.aspx
HTH, Thanks - Dipesh
http://silverlight.net/Showcase/
Regardless, working little bit more on web services i figured that it is absolutely ok to pass XMl as a set of string data through .net web service.
Also, i found this interesting simple article on how to upload XML or for that matter any file onto server - http://www.c-sharpcorner.com/UploadFile/scottlysle/UploadwithCSharpWS05032007121259PM/UploadwithCSharpWS.aspx
HTH, Thanks - Dipesh
Calling .net web service through HTTP Post
Below are the steps how you would call a web service from .net code through HTTP POST -
Dim oXmlhttpCaller as Object;
' Create Object of MSXml2.XMLHTTP
Set oXmlhttpCaller = Server.CreateObject("Msxml2.XMLHTTP")
'oXmlhttpCaller.open "GET","http://localhost/HelloWorld/Service.asmx/HelloWorldWit'hCustomMessage?s_msg= Hope you like this article.", False
oXmlhttpCaller.open "POST","http://localhost/HelloWorld/Service.asmx/
HelloWorldWithCustomMessage", False
oXmlhttpCaller.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlhttpCaller.send("Msg= Hello World!")
HTH, in my next post i wiill try and show how to send XML message as part of your input paramter. Thanks - Dj
Dim oXmlhttpCaller as Object;
' Create Object of MSXml2.XMLHTTP
Set oXmlhttpCaller = Server.CreateObject("Msxml2.XMLHTTP")
'oXmlhttpCaller.open "GET","http://localhost/HelloWorld/Service.asmx/HelloWorldWit'hCustomMessage?s_msg= Hope you like this article.", False
oXmlhttpCaller.open "POST","http://localhost/HelloWorld/Service.asmx/
HelloWorldWithCustomMessage", False
oXmlhttpCaller.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oXmlhttpCaller.send("Msg= Hello World!")
HTH, in my next post i wiill try and show how to send XML message as part of your input paramter. Thanks - Dj
CRM 4.0 VPC (Virtual machine download)
Here's the latest Microsoft Dynamics CRM 4.0 (Titan) complete Virtual Machine
http://www.microsoft.com/downloads/details.aspx?FamilyID=dd939ed9-87a5-4c13-b212-a922cc02b469&DisplayLang=en
This VPC is a one computer setup with Microsoft Dynamics CRM 4.0 and associated Microsoft Dynamics CRM clients for Microsoft Office Outlook and Microsoft Internet Explorer.
This demonstration also contains Microsoft SQL Server 2005, Microsoft Visual Studio 2005, Microsoft Office Communications Server and client, Microsoft SharePoint services, and Microsoft PerformancePoint Server 2007. Full details about the image are included in the virtual machine itself.
This virtual machine will expire in April, 2009. Cheers - D
http://www.microsoft.com/downloads/details.aspx?FamilyID=dd939ed9-87a5-4c13-b212-a922cc02b469&DisplayLang=en
This VPC is a one computer setup with Microsoft Dynamics CRM 4.0 and associated Microsoft Dynamics CRM clients for Microsoft Office Outlook and Microsoft Internet Explorer.
This demonstration also contains Microsoft SQL Server 2005, Microsoft Visual Studio 2005, Microsoft Office Communications Server and client, Microsoft SharePoint services, and Microsoft PerformancePoint Server 2007. Full details about the image are included in the virtual machine itself.
This virtual machine will expire in April, 2009. Cheers - D
Friday, February 01, 2008
sample .net code gallery at code.msdn
Find tons of sample .net (C#, WCF, LINQ...) and others available now at MSDN code gallery - http://code.msdn.microsoft.com/
Cheers - Dipesh
Cheers - Dipesh
Subscribe to:
Posts (Atom)