Silverlight 2 RC released.... from Scott's blog ....
http://weblogs.asp.net/scottgu/archive/2008/09/25/silverlight-2-release-candidate-now-available.aspx
.NET architecture, programming tips and tricks around Microsoft technology stack - Azure, WCF Services, SQL and strategy work.
Monday, September 29, 2008
Visual Studio 2010 and .NET 4.0 Framework
Microsoft Unveils Next Version of Visual Studio and .NET Framework
The press release just went live over on MS press pass. Go and have a look at the enticing screenshots and read the Visual Studio Team System (VSTS) 2010 overview on MSDN. This is the release formally code-named “Rosario”.
And best of all, Brian Keller is running Visual Studio Team System 2010 Week on Channel9. With new videos every day this week, they are not to be missed!
Reveals extensive enhancements for simplified application life-cycle management, provides sneak peek at all key focus areas for Visual Studio 2010 and the .NET Framework 4.0.
Details on Microsoft site:
http://www.microsoft.com/presspass/press/2008/sep08/09-29VS10PR.mspx
The press release just went live over on MS press pass. Go and have a look at the enticing screenshots and read the Visual Studio Team System (VSTS) 2010 overview on MSDN. This is the release formally code-named “Rosario”.
And best of all, Brian Keller is running Visual Studio Team System 2010 Week on Channel9. With new videos every day this week, they are not to be missed!
Reveals extensive enhancements for simplified application life-cycle management, provides sneak peek at all key focus areas for Visual Studio 2010 and the .NET Framework 4.0.
Details on Microsoft site:
http://www.microsoft.com/presspass/press/2008/sep08/09-29VS10PR.mspx
Thursday, August 28, 2008
Monday, August 25, 2008
Silverlight Beta 2 Released...
Silverlight Beta 2 Released
Scott Guthrie just published this on his blog here -
http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx
Scott Guthrie just published this on his blog here -
http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx
Monday, August 11, 2008
VS .net 3.5 and TFS SP1 shipped
Brian Harry just posted this news that - Microsoft released VS .net 3.5/TFS SP1.
At a very high level, the improvements include:
Improved WPF designers
SQLServer 2008 support
ADO.NET Entity designer
Visual Basic & Visual C++ improvements (including an MFC-based Office 2007 style 'Ribbon')
Team Foundation Server improvements - detailed here
Richer JavaScript support, enhanced AJAX and data tools and web site deployment improvements
A new .NET profile for client applications that is much smaller and installs much faster
Substantial .NET performance improvements (particularly in startup time)
And much, much more...
Here are the downloads -
Visual Studio Team System 2008 Team Foundation Server Service Pack 1 -http://go.microsoft.com/fwlink/?LinkId=124829
NET Framework 3.5 Service Pack 1 - http://go.microsoft.com/fwlink/?LinkId=124150
If you have setup issues, a great first resource is Heath's blog: http://blogs.msdn.com/heaths/archive/tags/VS+2008+SP1/default.aspx
Here's a useful entry about collecting setup log information: http://blogs.msdn.com/heaths/archive/2008/05/09/visual-studio-and-net-log-collection-utility.aspx
At a very high level, the improvements include:
Improved WPF designers
SQLServer 2008 support
ADO.NET Entity designer
Visual Basic & Visual C++ improvements (including an MFC-based Office 2007 style 'Ribbon')
Team Foundation Server improvements - detailed here
Richer JavaScript support, enhanced AJAX and data tools and web site deployment improvements
A new .NET profile for client applications that is much smaller and installs much faster
Substantial .NET performance improvements (particularly in startup time)
And much, much more...
Here are the downloads -
Visual Studio Team System 2008 Team Foundation Server Service Pack 1 -http://go.microsoft.com/fwlink/?LinkId=124829
NET Framework 3.5 Service Pack 1 - http://go.microsoft.com/fwlink/?LinkId=124150
If you have setup issues, a great first resource is Heath's blog: http://blogs.msdn.com/heaths/archive/tags/VS+2008+SP1/default.aspx
Here's a useful entry about collecting setup log information: http://blogs.msdn.com/heaths/archive/2008/05/09/visual-studio-and-net-log-collection-utility.aspx
Wednesday, July 23, 2008
Accenture has been named to the Fortune Global 500 for the seventh consecutive year...
Accenture has been named to the Fortune Global 500 for the seventh consecutive year...
Accenture has been named to the Fortune Global 500 for the seventh consecutive year. The ranking of the world’s largest companies is based exclusively on revenue, for the fiscal year ending on or before March 2008.
Accenture ranks #392 this year, up from #394 last year. Accenture is listed with $21,453 million in gross revenue, up from $18,228.4 million in 2007.
Fortune ranks Accenture in a newly-created category this year, Information Technology Services, maintaining the #3 position the company had last year in Computer Services & Software. IBM (#1) and EDS (#2) joined Accenture in the new category.
Competitors Hewlett-Packard rank #41 overall, with IBM ranked #46 and EDS ranked #384 on the 2008 list.
Accenture was first named to the Fortune Global 500 in 2002 when, as a public company, it became eligible for the first time.
Accenture has been named to the Fortune Global 500 for the seventh consecutive year. The ranking of the world’s largest companies is based exclusively on revenue, for the fiscal year ending on or before March 2008.
Accenture ranks #392 this year, up from #394 last year. Accenture is listed with $21,453 million in gross revenue, up from $18,228.4 million in 2007.
Fortune ranks Accenture in a newly-created category this year, Information Technology Services, maintaining the #3 position the company had last year in Computer Services & Software. IBM (#1) and EDS (#2) joined Accenture in the new category.
Competitors Hewlett-Packard rank #41 overall, with IBM ranked #46 and EDS ranked #384 on the 2008 list.
Accenture was first named to the Fortune Global 500 in 2002 when, as a public company, it became eligible for the first time.
Wednesday, June 11, 2008
Resharper 4.0 release
This release brings you the most up-to-date support for Visual Studio 2005 and 2008, including C# 3.0 and LINQ:
http://www.jetbrains.com/resharper/features/newfeatures.html?40nl
Try ReSharper 4.0 free for a 30-day trial. Simply download ReSharper 4.0 and start running it now:
http://www.jetbrains.com/resharper/download/index.html?40nl
http://www.jetbrains.com/resharper/features/newfeatures.html?40nl
Try ReSharper 4.0 free for a 30-day trial. Simply download ReSharper 4.0 and start running it now:
http://www.jetbrains.com/resharper/download/index.html?40nl
Thursday, June 05, 2008
ASP.NET MVC Release - Preview 3
Just in case if you haven't visited Scott's blog for a long time :)
http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx
http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx
Achieving High Performance: The Sustainability Imperative
Sustainability is moving from the periphery to the heart of business and government. As that transition occurs, organizations need to transform their operations—and, in some cases, their business models—to fully integrate sustainability initiatives across the enterprise. It’s a daunting effort. But the challenges are offset by the tremendous opportunities that lie ahead.
In this Point of View (link below), Accenture examines how organizations that weave sustainability into the fabric of their strategies and operating models can drive new capabilities with far-reaching effects in four areas:
1. Revenue growth from new products and services.
2. Cost reduction and efficiency improvements.
3. Better risk management.
4. Brand and reputation enhancement.
Accenture believes sustainability is an *engine* that can drive high performance. Further, the building blocks of high performance—market focus and position, distinctive capabilities and performance anatomy—can be used to create business opportunities and lasting value, for your stakeholders and for society at large.
Read more here - http://www.accenture.com/NR/rdonlyres/88EA36BC-3EBE-4D0F-BA6E-C3481B988475/0/AccentureSustainability.pdf
In this Point of View (link below), Accenture examines how organizations that weave sustainability into the fabric of their strategies and operating models can drive new capabilities with far-reaching effects in four areas:
1. Revenue growth from new products and services.
2. Cost reduction and efficiency improvements.
3. Better risk management.
4. Brand and reputation enhancement.
Accenture believes sustainability is an *engine* that can drive high performance. Further, the building blocks of high performance—market focus and position, distinctive capabilities and performance anatomy—can be used to create business opportunities and lasting value, for your stakeholders and for society at large.
Read more here - http://www.accenture.com/NR/rdonlyres/88EA36BC-3EBE-4D0F-BA6E-C3481B988475/0/AccentureSustainability.pdf
Saturday, May 31, 2008
Accenture awarded “Best Employer” for second straight year...
For the second year in a row, Accenture has received the “Best Employer” Award in Belgium, granted by the Great place to work in Europe with the support of the Vlerick Leuven Gent Management School.
Employees in Belgium once again voted Accenture into the top 10 by completing a survey distributed by the Great Place to Work Institute Europe.
Accenture awarded “Best Employer” for second straight year.
More on Vlerick Leuven Gent Management School @ http://www.vlerick.be/en/home.html
Employees in Belgium once again voted Accenture into the top 10 by completing a survey distributed by the Great Place to Work Institute Europe.
Accenture awarded “Best Employer” for second straight year.
More on Vlerick Leuven Gent Management School @ http://www.vlerick.be/en/home.html
Microsoft releases ASP.NET MVC (Preview 3)
This Tuesday May 27th Microsoft released the Preview 3 build of the ASP.NET MVC framework. This build includes some additional features not in last month's drop, some nice enhancements/refinements, as well as Visual Studio tool integration and documentation.
You can download an integrated ASP.NET MVC Preview 3 setup package here. You can also optionally download the ASP.NET MVC Preview 3 framework source code and framework unit tests at http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=aspnet&ReleaseId=13792
Read more at Scott Guthries' blog here -http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx
- Dipesh
You can download an integrated ASP.NET MVC Preview 3 setup package here. You can also optionally download the ASP.NET MVC Preview 3 framework source code and framework unit tests at http://www.codeplex.com/Release/ProjectReleases.aspx?ProjectName=aspnet&ReleaseId=13792
Read more at Scott Guthries' blog here -http://weblogs.asp.net/scottgu/archive/2008/05/27/asp-net-mvc-preview-3-release.aspx
- Dipesh
Tuesday, May 27, 2008
StyleCop released as Microsoft Source Analysis
Source Analysis is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while Source Analysis analyzes the source code directly. For this reason, Code Analysis focuses more on the design of the code, while Source Analysis focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.
Source Analysis comes with a set of default rules analyzers covering approximately 200 best practice rules. These rules are full compatible with the default layout settings in Visual Studio 2005 and Visual Studio 2008.
Read more -
http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx
Source Analysis comes with a set of default rules analyzers covering approximately 200 best practice rules. These rules are full compatible with the default layout settings in Visual Studio 2005 and Visual Studio 2008.
Read more -
http://blogs.msdn.com/sourceanalysis/archive/2008/05/23/announcing-the-release-of-microsoft-source-analysis.aspx
Friday, May 23, 2008
Accenture ranks first in global outsourcing, unseating IBM
Unseating two-time leader IBM, Accenture placed first on the Global Outsourcing 100, the annual list of the world’s top outsourcing service providers compiled by the International Association of Outsourcing Professionals (IOP). “We won on customer testimonials—the strongest evidence you can have,” says Kevin Campbell, group chief executive-Outsourcing.
Global 2008 Outsourcing ranikings -
RANK: 1
COMPANY: Accenture
KEY STRENGTH: Customer Testimonials
RANK: 2
COMPANY: IBM
KEY STRENGTH: Size & Growth
RANK: 3
COMPANY: Infosys Technologies
KEY STRENGTH: Executive Leadership
Here's the complete list - http://www.outsourcingprofessional.org/content/23/152/1197/
Global 2008 Outsourcing ranikings -
RANK: 1
COMPANY: Accenture
KEY STRENGTH: Customer Testimonials
RANK: 2
COMPANY: IBM
KEY STRENGTH: Size & Growth
RANK: 3
COMPANY: Infosys Technologies
KEY STRENGTH: Executive Leadership
Here's the complete list - http://www.outsourcingprofessional.org/content/23/152/1197/
Thursday, May 22, 2008
Why am i not getting any SQL notifications fired?
Why am i not getting any SQL notifications fired?
What are the constraints implementing SQL Server 7/2000 Dependency Caching? (see below...)
Here are few quick things you can check real quick
- Check your query string. Is it valid?
- Be sure you don’t have select *
- Be sure you do have two-part names for the tables e.g., dbo.countries
- Ensure that you have your broker service enabled: Run SET ENABLE_BROKER
- Check the compatibility mode of your database to be set as 90 at the database level. You can see and modify this setting in the Database Properties/Options/Compatibility level. *
- If you are want to use compatiblity mode 80 then you can still achieve it by setting ARITHABORT ON for the database properties or specifying at each individual connection as an example below -
Example:
--------------------------
Dim conn As SqlConnection = New SqlConnection(connectionString)
conn.Open()
Dim cmd1 As New SqlCommand("SET ARITHABORT ON", conn)
cmd1.ExecuteNonQuery()
Dim cmd As New SqlCommand("SELECT country, country_desc FROM dbo.COUNTRY", conn)
dep = New SqlDependency(cmd)
AddHandler dep.OnChange, AddressOf TableProxy.OnDependencyChanged
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
dtLocal.Load(rdr)
---------------------------------
There are several constraints as well in the way which query you can use for SQL notifications ....
Don’t use queries whose results will change frequently.
Don’t use Select * in queries.
Do select explicit columns.
Don’t use UNION, DISTINCT, or TOP.
Don’t use Aggregate functions such as AVG, MAX, etc...
Take a detailed peek at the do's and dont's here -
http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx
Take a look at ASP.NET’s Visual Web Developer Guided Tour for implementing SQL Server 7/2000 Dependency Caching at -
http://www.asp.net/Guided-Tour/s23.aspx
HTH, Thanks - Dipesh
What are the constraints implementing SQL Server 7/2000 Dependency Caching? (see below...)
Here are few quick things you can check real quick
- Check your query string. Is it valid?
- Be sure you don’t have select *
- Be sure you do have two-part names for the tables e.g., dbo.countries
- Ensure that you have your broker service enabled: Run SET ENABLE_BROKER
- Check the compatibility mode of your database to be set as 90 at the database level. You can see and modify this setting in the Database Properties/Options/Compatibility level. *
- If you are want to use compatiblity mode 80 then you can still achieve it by setting ARITHABORT ON for the database properties or specifying at each individual connection as an example below -
Example:
--------------------------
Dim conn As SqlConnection = New SqlConnection(connectionString)
conn.Open()
Dim cmd1 As New SqlCommand("SET ARITHABORT ON", conn)
cmd1.ExecuteNonQuery()
Dim cmd As New SqlCommand("SELECT country, country_desc FROM dbo.COUNTRY", conn)
dep = New SqlDependency(cmd)
AddHandler dep.OnChange, AddressOf TableProxy.OnDependencyChanged
Dim rdr As SqlDataReader
rdr = cmd.ExecuteReader()
dtLocal.Load(rdr)
---------------------------------
There are several constraints as well in the way which query you can use for SQL notifications ....
Don’t use queries whose results will change frequently.
Don’t use Select * in queries.
Do select explicit columns.
Don’t use UNION, DISTINCT, or TOP.
Don’t use Aggregate functions such as AVG, MAX, etc...
Take a detailed peek at the do's and dont's here -
http://msdn.microsoft.com/en-us/library/aewzkxxh.aspx
Take a look at ASP.NET’s Visual Web Developer Guided Tour for implementing SQL Server 7/2000 Dependency Caching at -
http://www.asp.net/Guided-Tour/s23.aspx
HTH, Thanks - Dipesh
Tool to generate .net query or fetchXML in CRM
Following stunware tool is pretty useful that lets you graphically build a query that generates either fetchXml or c# / vb.net query which you can copy and paste in your code in CRM 4.0
http://www.stunnware.com/crm2/topic.aspx?id=Framework1
Similar tool for CRM 3.0 can be found too at - http://www.stunnware.com/crm2/topic.aspx?id=FindingData6
Often you may have faced cryptic errors from CRM web service like "0x80041103: The specified attribute does not exist on this entity. Platform" that burns quite few hours. Most of the time this is because of incorrect query statements or mispelled words or something very trivial to catch your eyes. Hence this is of great help. Though i still prefer hand coding myself as that is a great learning! :)
http://www.stunnware.com/crm2/topic.aspx?id=Framework1
Similar tool for CRM 3.0 can be found too at - http://www.stunnware.com/crm2/topic.aspx?id=FindingData6
Often you may have faced cryptic errors from CRM web service like "0x80041103: The specified attribute does not exist on this entity. Platform" that burns quite few hours. Most of the time this is because of incorrect query statements or mispelled words or something very trivial to catch your eyes. Hence this is of great help. Though i still prefer hand coding myself as that is a great learning! :)
Wednesday, May 21, 2008
Best Practices for implementing web services
Here's a codeproject article I went through for best practices for implementing web services (worth a read) - http://www.codeproject.com/KB/cpp/Web_Services.aspx
Thanks - Dipesh
Thanks - Dipesh
Best Practices for Security in WCF...
Good article to read on Microsoft MSDN site-
http://msdn.microsoft.com/en-us/library/ms731059.aspx
http://msdn.microsoft.com/en-us/library/ms731059.aspx
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
Sunday, January 27, 2008
CRM java scripting
There are plenty of javascript good sites, here's one specific to CRM java scripting: http://www.stunnware.com/crm2/topic.aspx?id=JS4
Wednesday, January 23, 2008
.net interview questions
Preparing for .net interview to face soon? or planning to take net interview? Find Scott Hanselman's post on .net interview questions here -
http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx
HL - Dipesh
http://www.hanselman.com/blog/WhatGreatNETDevelopersOughtToKnowMoreNETInterviewQuestions.aspx
HL - Dipesh
Thursday, January 17, 2008
Debug .net source code through Visual Studio 2008
With the news of open source code for Visual Studio 2008 now available i was wondering how do you achieve this and i ran into this quite detailed article by Shawn here - http://blogs.msdn.com/sburke/archive/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code.aspx
As of date .net assemblies that are currently available as open source or for symbol/source loading where developers can actually step into VS .net source code are:-
Mscorlib.DLL
System.DLL
System.Data.DLL
System.Drawing.DLL
System.Web.DLL
System.Web.Extensions.DLL
System.Windows.Forms.DLL
System.XML.DLL
WPF (UIAutomation*.dll, System.Windows.DLL, System.Printing.DLL, System.Speech.DLL, WindowsBase.DLL, WindowsFormsIntegration.DLL, Presentation*.dll, some others)
Microsoft.VisualBasic.DLL
I believe more will follow! happy debugging... Regards - Dipesh
As of date .net assemblies that are currently available as open source or for symbol/source loading where developers can actually step into VS .net source code are:-
Mscorlib.DLL
System.DLL
System.Data.DLL
System.Drawing.DLL
System.Web.DLL
System.Web.Extensions.DLL
System.Windows.Forms.DLL
System.XML.DLL
WPF (UIAutomation*.dll, System.Windows.DLL, System.Printing.DLL, System.Speech.DLL, WindowsBase.DLL, WindowsFormsIntegration.DLL, Presentation*.dll, some others)
Microsoft.VisualBasic.DLL
I believe more will follow! happy debugging... Regards - Dipesh
Wednesday, January 16, 2008
HTTP 401 Unauthorized error while inserting/updating through CRM web service
If you are experiencing 401 error - "The request failed with HTTP status 401: Unauthorized" while inserting/updating a record in CRM database through CRM web service .create or .update method even when you can access the CRM web service/meta web service through browser (IE) then you may want to probably check your "manage network password" of your windows login account. Control Panel -> Users -> User name -> Manage network password and add the server IP (where CRM web service is hosted) with correct credentials if required or if you changed your network password then try updaing your password in here as well. Stop the current process run and try running/accessing the CRM web service insert/update and it should work fine. HTH, - Dipesh
Tuesday, January 15, 2008
Code assessment and code metrics through Visual Studio 2008 and third party tools!
If you are planning to assess your old application code and generate code statistics (lines of code, complexity, etc.) then here are some tools that may help:
nDepend - http://www.ndepend.com/Features.aspx
Reflector has code metrics - http://www.codeplex.com/reflectoraddins/Wiki/View.aspx?title=CodeMetrics
Visual Studio 2008 can generate code metrics too:
http://blogs.msdn.com/fxcop/archive/2007/10/03/new-for-visual-studio-2008-code-metrics.aspx
Also, find CCFinderX that bring us another point of view in code analysis for .net and non .net code - http://www.ccfinder.net/ccfinderx.html
nDepend - http://www.ndepend.com/Features.aspx
Reflector has code metrics - http://www.codeplex.com/reflectoraddins/Wiki/View.aspx?title=CodeMetrics
Visual Studio 2008 can generate code metrics too:
http://blogs.msdn.com/fxcop/archive/2007/10/03/new-for-visual-studio-2008-code-metrics.aspx
Also, find CCFinderX that bring us another point of view in code analysis for .net and non .net code - http://www.ccfinder.net/ccfinderx.html
CRM 3.0 rollup 2 download and fixes
Tool that would allow you to rename schema name can be found as Mscrmrenameattributes.exe along with CRM 3.0 rollup update install. Unfortunately, i am not sure if Microsoft provides this as a seperate one.
Key issues that are fixed in Update Rollup 2 for Microsoft Dynamics CRM 3.0
918990 (http://support.microsoft.com/kb/918990/) You experience timeouts or slow performance after you change a security role or after you import a customization file in Microsoft Dynamics CRM 3.0
920135 (http://support.microsoft.com/kb/920135/) Error message when you try to import a customization into Microsoft Dynamics CRM 3.0: "The selected customization file does not conform to the required customization file schema"
920859 (http://support.microsoft.com/kb/920859/) Error message when you send an e-mail message in Microsoft Dynamics CRM 3.0: "You do not have enough privileges to access the Microsoft CRM Object or perform the requested operation"
921065 (http://support.microsoft.com/kb/921065/) Internet Information Services stops responding on a Microsoft Dynamics CRM 3.0 server
921235 (http://support.microsoft.com/kb/921235/) You experience timeouts or slow performance when you reassign records from one user to another user in Microsoft Dynamics CRM 3.0
923281 (http://support.microsoft.com/kb/923281/) The client stops responding when you try to go offline or to run the "Synchronize Outlook with CRM" function in Microsoft Dynamics CRM client for Outlook
925437 (http://support.microsoft.com/kb/925437/) Error message when you send an e-mail message from the Microsoft Dynamics CRM 3.0 Web client: "Insufficient Permissions"
925505 (http://support.microsoft.com/kb/925505/) Microsoft Outlook stops responding when you click a command button on the Microsoft Dynamics CRM toolbar
925874 (http://support.microsoft.com/kb/925874/) An update for the 2007 daylight saving time changes is available for Microsoft Dynamics CRM 3.0 and for the Microsoft Dynamics CRM 3.0 client for Outlook
928272 (http://support.microsoft.com/kb/928272/) Outlook exits unexpectedly when you click "Go Offline" in the Microsoft Dynamics CRM laptop client for Outlook
929488 (http://support.microsoft.com/kb/929488/) Error message when you attach a .docx file to a record in Microsoft Dynamics CRM 3.0: "File Upload Failure"
931270 (http://support.microsoft.com/kb/931270/) Error message when you use the Microsoft Dynamics CRM client for Microsoft Office Outlook: "Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconvenience"
932984 (http://support.microsoft.com/kb/932984/) How to make the 2007 daylight saving time changes by using the Update Time Zones Wizard for Microsoft Dynamics CRM 3.0
for details visit - http://support.microsoft.com/default.aspx?kbid=927751
Download rollup 2 update for MS CRM 3.0 server here -
* CRM3.0-KB927751-Server-ENU.exe package - http://www.microsoft.com/downloads/details.aspx?FamilyId=81674DA5-FFEF-492A-A7B1-7E1F1951B05F
Download CRM 3.0 client for Microsoft Office Outlook here -
* CRM3.0-KB927751-Client-ENU.exe package - http://www.microsoft.com/downloads/details.aspx?FamilyId=81674DA5-FFEF-492A-A7B1-7E1F1951B05F
Key issues that are fixed in Update Rollup 2 for Microsoft Dynamics CRM 3.0
918990 (http://support.microsoft.com/kb/918990/) You experience timeouts or slow performance after you change a security role or after you import a customization file in Microsoft Dynamics CRM 3.0
920135 (http://support.microsoft.com/kb/920135/) Error message when you try to import a customization into Microsoft Dynamics CRM 3.0: "The selected customization file does not conform to the required customization file schema"
920859 (http://support.microsoft.com/kb/920859/) Error message when you send an e-mail message in Microsoft Dynamics CRM 3.0: "You do not have enough privileges to access the Microsoft CRM Object or perform the requested operation"
921065 (http://support.microsoft.com/kb/921065/) Internet Information Services stops responding on a Microsoft Dynamics CRM 3.0 server
921235 (http://support.microsoft.com/kb/921235/) You experience timeouts or slow performance when you reassign records from one user to another user in Microsoft Dynamics CRM 3.0
923281 (http://support.microsoft.com/kb/923281/) The client stops responding when you try to go offline or to run the "Synchronize Outlook with CRM" function in Microsoft Dynamics CRM client for Outlook
925437 (http://support.microsoft.com/kb/925437/) Error message when you send an e-mail message from the Microsoft Dynamics CRM 3.0 Web client: "Insufficient Permissions"
925505 (http://support.microsoft.com/kb/925505/) Microsoft Outlook stops responding when you click a command button on the Microsoft Dynamics CRM toolbar
925874 (http://support.microsoft.com/kb/925874/) An update for the 2007 daylight saving time changes is available for Microsoft Dynamics CRM 3.0 and for the Microsoft Dynamics CRM 3.0 client for Outlook
928272 (http://support.microsoft.com/kb/928272/) Outlook exits unexpectedly when you click "Go Offline" in the Microsoft Dynamics CRM laptop client for Outlook
929488 (http://support.microsoft.com/kb/929488/) Error message when you attach a .docx file to a record in Microsoft Dynamics CRM 3.0: "File Upload Failure"
931270 (http://support.microsoft.com/kb/931270/) Error message when you use the Microsoft Dynamics CRM client for Microsoft Office Outlook: "Microsoft Office Outlook has encountered a problem and needs to close. We are sorry for the inconvenience"
932984 (http://support.microsoft.com/kb/932984/) How to make the 2007 daylight saving time changes by using the Update Time Zones Wizard for Microsoft Dynamics CRM 3.0
for details visit - http://support.microsoft.com/default.aspx?kbid=927751
Download rollup 2 update for MS CRM 3.0 server here -
* CRM3.0-KB927751-Server-ENU.exe package - http://www.microsoft.com/downloads/details.aspx?FamilyId=81674DA5-FFEF-492A-A7B1-7E1F1951B05F
Download CRM 3.0 client for Microsoft Office Outlook here -
* CRM3.0-KB927751-Client-ENU.exe package - http://www.microsoft.com/downloads/details.aspx?FamilyId=81674DA5-FFEF-492A-A7B1-7E1F1951B05F
Secure FTP connect through .net + other tools...
If you want to SFTP (secure connect) through .net here's the code that helps you achieve that using CuteFTPPro as below. If you want to compare with other options available in the market follow the link below. HTH,
public void SecureFTPConnect()
{
.....
// Open the SFTP connection
Sftp = new CuteFTPPro.TEConnectionClass();
Sftp.Host = ServerName;
Sftp.Protocol = Protocol;
Sftp.Port = PortNumber;
Sftp.Login = UserName;
Sftp.Password = Password;
Sftp.MaxConnections = 1;
Sftp.Retries = 0;
Sftp.TransferType = "ASCII";
//Connect to SFTP location
Sftp.Connect();
}
Check few more SFTP (SSH File Transfer Protocol) components for .NET (C#, VB.NET) here - http://www.eldos.com/sbb/sftpcompare.php
Thanks - DJ
public void SecureFTPConnect()
{
.....
// Open the SFTP connection
Sftp = new CuteFTPPro.TEConnectionClass();
Sftp.Host = ServerName;
Sftp.Protocol = Protocol;
Sftp.Port = PortNumber;
Sftp.Login = UserName;
Sftp.Password = Password;
Sftp.MaxConnections = 1;
Sftp.Retries = 0;
Sftp.TransferType = "ASCII";
//Connect to SFTP location
Sftp.Connect();
}
Check few more SFTP (SSH File Transfer Protocol) components for .NET (C#, VB.NET) here - http://www.eldos.com/sbb/sftpcompare.php
Thanks - DJ
Thursday, January 10, 2008
Calling web services from remote machines easy way: Test environment
If you are faced with the web service error while invoking the service from remote machine, by default, it would display the message "The test form is only available for requests from the local machine."
Add this piece of section in your web.config to enable your web service to be invoked from remote machines,
Add the following settings to the Web.Config file of the Web Service -
(XML start << and >> signs are not visible...dont know how to do that with this blogger editor!)
system.web
webservices
protocols
add name="HttpGet"
add name="HttpPost"
/protocols
/webservices>
/SYSTEM.WEB
This would enable the Web service to be able to be invoked from remote machine. This setting would only be useful in development / testing scenarios and it is advisable to remove /comment the above section when releasing for production, due to security reasons.
HTH - DJ
Add this piece of section in your web.config to enable your web service to be invoked from remote machines,
Add the following settings to the Web.Config file of the Web Service -
(XML start << and >> signs are not visible...dont know how to do that with this blogger editor!)
system.web
webservices
protocols
add name="HttpGet"
add name="HttpPost"
/protocols
/webservices>
/SYSTEM.WEB
This would enable the Web service to be able to be invoked from remote machine. This setting would only be useful in development / testing scenarios and it is advisable to remove /comment the above section when releasing for production, due to security reasons.
HTH - DJ
Wednesday, January 09, 2008
Download Visual Studio 2008 (complete software or Virtual machine)
If you are a MSDN subscriber, you can download your VS 2008 copy from the MSDN subscription site - http://msdn2.microsoft.com/subscriptions
If you are a non-MSDN subscriber, you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here -
90-Day Trial Downloads
Visual Studio 2008 Professional Edition (smaller in size)
Visual Studio Team System 2008 Team Suite
Visual Studio Team System 2008 Team Foundation Server
Visual Studio Team System 2008 Test Load Agent
If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.
If you want to just install the .NET Framework 3.5 runtime, you can download it here.
If you are looking for Virtual Machine (VPC) with Visual Studio 2008 Installed for You then check here -
Visual Studio Team System 2008 Team Suite with Visual Studio Team System 2008 Team Foundation Server
Visual Studio Team System 2008 Team Foundation Server with Team Explorer
To use these virtual machines, you must have either Virtual PC 2007 or Virtual Server 2005 R2 SP1.
If you want free MSDN library it is avaialble for download here - http://go.microsoft.com/?linkid=7947400
To help you jump start with new features with VS 2008 you can download free Visual Studio ebook here - http://go.microsoft.com/?linkid=8010142
Keep watching this blog if you are interested in exploring new features on VS 2008 apart from this ebook. Happy exploring! Cheers - Dipesh
If you are a non-MSDN subscriber, you can download a 90-day free trial edition of Visual Studio 2008 Team Suite here -
90-Day Trial Downloads
Visual Studio 2008 Professional Edition (smaller in size)
Visual Studio Team System 2008 Team Suite
Visual Studio Team System 2008 Team Foundation Server
Visual Studio Team System 2008 Test Load Agent
If you want to use the free Visual Studio 2008 Express editions (which are much smaller and totally free), you can download them here.
If you want to just install the .NET Framework 3.5 runtime, you can download it here.
If you are looking for Virtual Machine (VPC) with Visual Studio 2008 Installed for You then check here -
Visual Studio Team System 2008 Team Suite with Visual Studio Team System 2008 Team Foundation Server
Visual Studio Team System 2008 Team Foundation Server with Team Explorer
To use these virtual machines, you must have either Virtual PC 2007 or Virtual Server 2005 R2 SP1.
If you want free MSDN library it is avaialble for download here - http://go.microsoft.com/?linkid=7947400
To help you jump start with new features with VS 2008 you can download free Visual Studio ebook here - http://go.microsoft.com/?linkid=8010142
Keep watching this blog if you are interested in exploring new features on VS 2008 apart from this ebook. Happy exploring! Cheers - Dipesh
Tuesday, January 08, 2008
Generate code from WSDL/XSD from Visual Studio 2005
In my search of doing my job faster in the development of web services i found this pretty helpful tool: WSCF - Web Services Contract First. This helps us generating .net code (C#, vb.net) from WSDL, XSD and so on. You can generate proxy classes for .net/java or any other client and also .net web service - server side code all from Visual Studio 2005.
You can find the latest version here- http://www.thinktecture.com/media/7478/wscf0.7.zip
You can find the walkthrough document here - http://www.thinktecture.com/resourcearchive/tools-and-software/wscf/wscf-walkthrough
Thanks - Dipesh
You can find the latest version here- http://www.thinktecture.com/media/7478/wscf0.7.zip
You can find the walkthrough document here - http://www.thinktecture.com/resourcearchive/tools-and-software/wscf/wscf-walkthrough
Thanks - Dipesh
Friday, January 04, 2008
Improve web service performance
Mike has posted a nice article that helps one achieve faster web service performance by compressing SOAP. Read here - http://www.dotnetjunkies.com/Article/46630AE2-1C79-4D5F-827E-6C2857FF1D23.dcik
You may want to peek at Microsoft's article as well - http://msdn2.microsoft.com/en-us/library/s25h0swd.aspx
Hope that helps. - DJ
You may want to peek at Microsoft's article as well - http://msdn2.microsoft.com/en-us/library/s25h0swd.aspx
Hope that helps. - DJ
How to compress/uncompress string in .net before passing it over the network?
If you want to compress string before passing it over the network to save bandwidth or uncompress it back here is the code for the same. It usese freeware NZIPLIB library. You can download the source code and compiled assembly from this site. Download now!
using System;
using NZlib.GZip;
using NZlib.Compression;
using NZlib.Streams;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Xml;
namespace zipper
{
public class MyClass
{
public static string Compress(string uncompressedString)
{
byte[] bytData = System.Text.Encoding.UTF8.GetBytes(uncompressedString);
MemoryStream ms = new MemoryStream();
Stream s = new DeflaterOutputStream(ms);
s.Write(bytData, 0, bytData.Length);
s.Close();
byte[] compressedData = (byte[])ms.ToArray();
return System.Convert.ToBase64String(compressedData, 0, _
compressedData.Length);
}
public static string DeCompress(string compressedString)
{
string uncompressedString="";
int totalLength = 0;
byte[] bytInput = System.Convert.FromBase64String(compressedString);;
byte[] writeData = new byte[4096];
Stream s2 = new InflaterInputStream(new MemoryStream(bytInput));
while (true)
{
int size = s2.Read(writeData, 0, writeData.Length);
if (size > 0)
{
totalLength += size;
uncompressedString+=System.Text.Encoding.UTF8.GetString(writeData, _
0, size);
}
else
{
break;
}
}
s2.Close();
return uncompressedString;
}
}
}
using System;
using NZlib.GZip;
using NZlib.Compression;
using NZlib.Streams;
using System.IO;
using System.Net;
using System.Runtime.Serialization;
using System.Xml;
namespace zipper
{
public class MyClass
{
public static string Compress(string uncompressedString)
{
byte[] bytData = System.Text.Encoding.UTF8.GetBytes(uncompressedString);
MemoryStream ms = new MemoryStream();
Stream s = new DeflaterOutputStream(ms);
s.Write(bytData, 0, bytData.Length);
s.Close();
byte[] compressedData = (byte[])ms.ToArray();
return System.Convert.ToBase64String(compressedData, 0, _
compressedData.Length);
}
public static string DeCompress(string compressedString)
{
string uncompressedString="";
int totalLength = 0;
byte[] bytInput = System.Convert.FromBase64String(compressedString);;
byte[] writeData = new byte[4096];
Stream s2 = new InflaterInputStream(new MemoryStream(bytInput));
while (true)
{
int size = s2.Read(writeData, 0, writeData.Length);
if (size > 0)
{
totalLength += size;
uncompressedString+=System.Text.Encoding.UTF8.GetString(writeData, _
0, size);
}
else
{
break;
}
}
s2.Close();
return uncompressedString;
}
}
}
Wednesday, January 02, 2008
XSDObjectGen - nested schema (imports) error with XSD.exe tool
If you read my previous post http://archdipesh.blogspot.com/2008/01/xml-xsdexe-usage-tips.html you may be good if you are using a simple XSD file (no nesting). But if i have multiple XSD files and they are all nested then there is a problem! Using XSD.exe tool doesn't help and fails for nested schema files.
It seems XSD.exe doesn’t seem to recognizeelement when generating code file...and it spits out the error ... "Class generation failed, cannot recognize root element". If you are facing the same error remove imports element from the XSD just include the namespace and try specifying multiple XSD file names from the command line while executing xsd.exe tool.
OR ... sweet way would be to look at XSDObjectGen tool. This is pretty exhaustive and can handle imports/mutiple xsd files easily. (though one level down). This code can then be used as a class exposed by web services.
Download Sample Code generator from here - http://www.microsoft.com/downloads/details.aspx?familyid=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&displaylang=en
Saves lot of time and pain for sure! HTH, Thanks - Dipesh
It seems XSD.exe doesn’t seem to recognize
OR ... sweet way would be to look at XSDObjectGen tool. This is pretty exhaustive and can handle imports/mutiple xsd files easily. (though one level down). This code can then be used as a class exposed by web services.
Download Sample Code generator from here - http://www.microsoft.com/downloads/details.aspx?familyid=89e6b1e5-f66c-4a4d-933b-46222bb01eb0&displaylang=en
Saves lot of time and pain for sure! HTH, Thanks - Dipesh
XML, XSD.exe usage tips
Here are few quick tips that can help you understand and start with XML basics...
Questions - (preferably in this sequence)
How do you generate XSD ?
You need to have a valid XML file for which you want to have a schema generated ( XSD)
If you have VS .net you can just open the xml file into VS.net and then under XML menu you should see "Create Schema" option that should generate an .xsd file for you!
How do you create classes from an XSD schema?
You can create .net (C#, VB, J#) source code from the xsd using XSD tool (command line) along with MS .net framework.
http://samples.gotdotnet.com/quickstart/howto/doc/xmlserialization/xsdtocls.aspx
How do you convert (deserialize) XML into an object that you can read through .net code?
AND
How do you write out an XML file (serialize) from an object through .net code?
http://samples.gotdotnet.com/quickstart/howto/doc/xmlserialization/rwobjfromxml.aspx
Thats simple ...is it? Thanks - Dipesh
Questions - (preferably in this sequence)
How do you generate XSD ?
You need to have a valid XML file for which you want to have a schema generated ( XSD)
If you have VS .net you can just open the xml file into VS.net and then under XML menu you should see "Create Schema" option that should generate an .xsd file for you!
How do you create classes from an XSD schema?
You can create .net (C#, VB, J#) source code from the xsd using XSD tool (command line) along with MS .net framework.
http://samples.gotdotnet.com/quickstart/howto/doc/xmlserialization/xsdtocls.aspx
How do you convert (deserialize) XML into an object that you can read through .net code?
AND
How do you write out an XML file (serialize) from an object through .net code?
http://samples.gotdotnet.com/quickstart/howto/doc/xmlserialization/rwobjfromxml.aspx
Thats simple ...is it? Thanks - Dipesh
How do i authenticate web service requests before invoking web methods ?
How do i pass user name, password when calling web services ? or
How do i authenticate the web service request before invoking web methods ?
There are several ways to do this and one of the most easiest way is to pass user name, password as input parameters to web method called. but na, that is not a good way to implement as this information is at the periphery of the core business functionality of the web service exposed. Hence keeping this out makes more sense.
Another way to control anonymous access can be achieved through IIS (web server) settings. Just uncheck the anonymous access or limit the IPs that can hit your web services or validate it against your windows account group... but again you may want to implement partial anonymous access! Few web methods can be accessed by everyone, few have restricted access.
In that case, better way to do this is to pass this information into SOAP header (SOAP web services communicate through SOAP messages - which include SOAP envelope (inc. namespace and root element), SOAP Header (this is optional) and SOAP body (contains web method, input parameters and response result)
Working with SOAP Headers in order to have a Web service accept a SOAP header we need to perform the following three tasks:
1> Define a SOAP header class in the Web service project
public class AuthenticationHeader : SoapHeader
{
public string Username;
public string Password;
}
2> Add a public member variable of the SOAP header class created in step (1) to the Web service class
[WebService(Namespace=http://www.comp.com/yournamespace )]
public class MyWebService : System.Web.Services.WebService
{
public AuthenticationHeader AuthHeader;
... The Web service's methods would be defined down here ...
}
3> Add the SoapHeader attribute to the Web method(s) that need to be able to programmatically access the value of the header
Once we perform these three steps at the Web service's end, our next task is to configure the client so that it can invoke a Web service method and pass along data for the appropriate SOAP header(s). The first step, as we've discussed in earlier installments of this article series, is to create a proxy class on the client. This will auto-generate the SOAP header class defined in the Web service project and will add a public property to the proxy class through which an instance of the SOAP header can be affixed to outgoing messages.
To actually pass along a populated SOAP header when calling a Web method the client needs to first create an instance of the proxy's SOAP header class, populate its values, and then assign this header class instance to the appropriate proxy class property. Finally, calling one of the Web service's methods will invoke the method, passing along the SOAP header.
[WebMethod(), SoapHeader("AuthHeader")]
public string GetMessage()
{
// Only allow valid user/password to access this secret message...
if (AuthHeader.Username == "user" && AuthHeader.Password == "password")
return "This is the secret message!!!";
else
return "YOU ARE NOT AUTHORIZED TO SEE THIS MESSAGE!";
}
In order to send a SOAP header to the Web service method, the client should do the following:
1> Create an instance of the proxy class,
2> Create an instance of the SOAP header class and populate its values,
3> Affix the SOAP header to the proxy class by assigning the SOAP header class instance created in step (2) to the proxy class's AuthHeaderValue property, and, finally
4> Call the Web service method
The following code illustrates these four steps. The GetMessage() Web method is invoked from the client passing along a username/password pair of scott and password.
// step 1, create the proxy class
localhost.MyWebService proxy = new localhost.MyWebService();
// step 2, create and populate the header class
localhost.AuthenticationHeader authInfo = new localhost.AuthenticationHeader();
authInfo.Username = "user";
authInfo.Password = "password";
// step 3, affix the SOAP header to the proxy
proxy.AuthHeaderValue = authInfo;
// step 4, call the method
string result = proxy.GetMessage();
The value returned from GetMessage() will contain the appropriate message, based on the username/password sent via the SOAP header.
Conclusion - If you want to know more or learn real sweet about the whole web services or SOAP basics and details visit Scott Mitchell's article on http://aspnet.4guysfromrolla.com/articles/123103-1.aspx. He has written 11 part series about .net web services. Hope that helps! Thanks - Dipesh
How do i authenticate the web service request before invoking web methods ?
There are several ways to do this and one of the most easiest way is to pass user name, password as input parameters to web method called. but na, that is not a good way to implement as this information is at the periphery of the core business functionality of the web service exposed. Hence keeping this out makes more sense.
Another way to control anonymous access can be achieved through IIS (web server) settings. Just uncheck the anonymous access or limit the IPs that can hit your web services or validate it against your windows account group... but again you may want to implement partial anonymous access! Few web methods can be accessed by everyone, few have restricted access.
In that case, better way to do this is to pass this information into SOAP header (SOAP web services communicate through SOAP messages - which include SOAP envelope (inc. namespace and root element), SOAP Header (this is optional) and SOAP body (contains web method, input parameters and response result)
Working with SOAP Headers in order to have a Web service accept a SOAP header we need to perform the following three tasks:
1> Define a SOAP header class in the Web service project
public class AuthenticationHeader : SoapHeader
{
public string Username;
public string Password;
}
2> Add a public member variable of the SOAP header class created in step (1) to the Web service class
[WebService(Namespace=http://www.comp.com/yournamespace )]
public class MyWebService : System.Web.Services.WebService
{
public AuthenticationHeader AuthHeader;
... The Web service's methods would be defined down here ...
}
3> Add the SoapHeader attribute to the Web method(s) that need to be able to programmatically access the value of the header
Once we perform these three steps at the Web service's end, our next task is to configure the client so that it can invoke a Web service method and pass along data for the appropriate SOAP header(s). The first step, as we've discussed in earlier installments of this article series, is to create a proxy class on the client. This will auto-generate the SOAP header class defined in the Web service project and will add a public property to the proxy class through which an instance of the SOAP header can be affixed to outgoing messages.
To actually pass along a populated SOAP header when calling a Web method the client needs to first create an instance of the proxy's SOAP header class, populate its values, and then assign this header class instance to the appropriate proxy class property. Finally, calling one of the Web service's methods will invoke the method, passing along the SOAP header.
[WebMethod(), SoapHeader("AuthHeader")]
public string GetMessage()
{
// Only allow valid user/password to access this secret message...
if (AuthHeader.Username == "user" && AuthHeader.Password == "password")
return "This is the secret message!!!";
else
return "YOU ARE NOT AUTHORIZED TO SEE THIS MESSAGE!";
}
In order to send a SOAP header to the Web service method, the client should do the following:
1> Create an instance of the proxy class,
2> Create an instance of the SOAP header class and populate its values,
3> Affix the SOAP header to the proxy class by assigning the SOAP header class instance created in step (2) to the proxy class's AuthHeaderValue property, and, finally
4> Call the Web service method
The following code illustrates these four steps. The GetMessage() Web method is invoked from the client passing along a username/password pair of scott and password.
// step 1, create the proxy class
localhost.MyWebService proxy = new localhost.MyWebService();
// step 2, create and populate the header class
localhost.AuthenticationHeader authInfo = new localhost.AuthenticationHeader();
authInfo.Username = "user";
authInfo.Password = "password";
// step 3, affix the SOAP header to the proxy
proxy.AuthHeaderValue = authInfo;
// step 4, call the method
string result = proxy.GetMessage();
The value returned from GetMessage() will contain the appropriate message, based on the username/password sent via the SOAP header.
Conclusion - If you want to know more or learn real sweet about the whole web services or SOAP basics and details visit Scott Mitchell's article on http://aspnet.4guysfromrolla.com/articles/123103-1.aspx. He has written 11 part series about .net web services. Hope that helps! Thanks - Dipesh
XML Serialization: what can be XML serialized and what cannot be ?
Few points that you would like to know about XML serialization that may be also important if you are planning to face an interview soon :P)
Realize that XML serialization:
1> XML serialization can only be applied to classes that contain a public default (parameterless) constructor. If you create a class in the Web service that does not have a public default constructor, the Web service will still compile, but when attempting to generate the proxy class on the client's end you'll receive an error message.
2> Read-only class properties are NOT serialized. That is, if a property in the class has only a get accessor, and not a set accessor as well, the property will not be serialized.
3> ONLY public properties and fields are serialized. Private properties are not serialized.
4> To serialize a strongly-typed collection of objects, have the class derived from System.Collections.CollectionBase adding an Add() method and an indexer.
Alternatively you can send an array of the specified type.
On the last point, consider the case where you want a Web service method to accept a set of custom class instances. For example, imagine you wanted to build a Web method that accepted a number of instances of type CreditCardInfo. One option is to have the method accept an array of type CreditCardInfo, like so:
[WebMethod()]
public void FooBar(CreditCardInfo [] collectionOfCCInfos)
{
...
}
Another option is to create a strongly-typed collection class derived from System.Collections.CollectionBase. You'd then pass in an instance of this strongly-typed collection class. For example, you'd first create the class:
public class CreditCardInfoCollection : System.Collections.CollectionBase
{
public void Add(CreditCardInfo cc)
{
this.InnerList.Add(cc);
}
public CreditCardInfo this[int index]
{
get { return (CreditCardInfo) this.InnerList[index]; }
set { this.InnerList[index] = value; }
}
}
And then you'd have the Web service method accept an input of this strongly-typed collection class:
[WebMethod()]
public void FooBar(CreditCardInfoCollection collectionOfCCInfos)
{
...
}
See this article for more details on web services and XML related basics...
http://aspnet.4guysfromrolla.com/articles/121703-1.aspx
btw, Happy New Year 2008 :)
Happy programming - DJ
Realize that XML serialization:
1> XML serialization can only be applied to classes that contain a public default (parameterless) constructor. If you create a class in the Web service that does not have a public default constructor, the Web service will still compile, but when attempting to generate the proxy class on the client's end you'll receive an error message.
2> Read-only class properties are NOT serialized. That is, if a property in the class has only a get accessor, and not a set accessor as well, the property will not be serialized.
3> ONLY public properties and fields are serialized. Private properties are not serialized.
4> To serialize a strongly-typed collection of objects, have the class derived from System.Collections.CollectionBase adding an Add() method and an indexer.
Alternatively you can send an array of the specified type.
On the last point, consider the case where you want a Web service method to accept a set of custom class instances. For example, imagine you wanted to build a Web method that accepted a number of instances of type CreditCardInfo. One option is to have the method accept an array of type CreditCardInfo, like so:
[WebMethod()]
public void FooBar(CreditCardInfo [] collectionOfCCInfos)
{
...
}
Another option is to create a strongly-typed collection class derived from System.Collections.CollectionBase. You'd then pass in an instance of this strongly-typed collection class. For example, you'd first create the class:
public class CreditCardInfoCollection : System.Collections.CollectionBase
{
public void Add(CreditCardInfo cc)
{
this.InnerList.Add(cc);
}
public CreditCardInfo this[int index]
{
get { return (CreditCardInfo) this.InnerList[index]; }
set { this.InnerList[index] = value; }
}
}
And then you'd have the Web service method accept an input of this strongly-typed collection class:
[WebMethod()]
public void FooBar(CreditCardInfoCollection collectionOfCCInfos)
{
...
}
See this article for more details on web services and XML related basics...
http://aspnet.4guysfromrolla.com/articles/121703-1.aspx
btw, Happy New Year 2008 :)
Happy programming - DJ
Subscribe to:
Posts (Atom)