If you look at the new technology wrapped in VS2010 (technology is a grand term, yes I know), I think you will agree that the stage is being set for all sorts of goodies down the line, things like Azure, Increased productivity, more secure, scalable applications, Accessible products, Richer UI. It's coming, better get on board and start digging in...
That's the title of my new book. Woohoo! Should be out in February 2010. 7 Chapters, heavy on the code, light on the fluff. It will sticker for $20, printed and eBook versions along with code download. I'm targetting about 300 pages, give or take a few.
I'm ashamed for not posting any sooner than this. I forgot my password for the longest while...Have you noticed how many passwords people now have. There's work, there's home, there's social sites, there's chat clients, there's taxes, banking...On and On. And they are all different right? Because, oh no, you don't want to share the same password across all these sites. What if the booboo man gets a hold of it? I think we've pinned ourselves into a corner here...
I walked into a booby-trap with .NET 3.5 SP1. Here are the details. You receive a 401 authentication error when you upgrade your server running WCF service to .NET 3.5 SP1. The WCF run-time now requires an identity to be passed in on the call. The identity or SPN is not verified for authenticity, it just needs to be present. You can fix the issue from code or by inserting the identity tag into the url.
The authentication failure is triggered if all of the conditions are met
-
The scenario uses ClientCredentialType.Windows, which specifies the Negotiate authentication scheme.
-
The scenario uses http, https, or net.tcp.
-
The service runs under a don-domain account
More specifics
|
|
3.5 SP1
|
3.5 RTM
|
|
Default – specify NO identity
|
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oYG… snip…. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. ---> System.ComponentModel.Win32Exception: The target principal name is incorrect
|
Accepted (no identity required)
|
|
Default – specify bad identity
|
Accepted (identity not checked)
|
Accepted (identity not checked)
|
|
allowNTLM=false – specify NO identity
|
System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oYG… snip…. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. ---> System.ComponentModel.Win32Exception: The target principal name is incorrect
|
Accepted (no identity required)
|
|
allowNTLM=false – specify bad identity
|
Caught System.ServiceModel.CommunicationException: An error (The request was canceled) occurred while transmitting data over the HTTP channel. ---> System.Net.WebException: The request was canceled ---> System.Net.ProtocolViolationException: The requirement for mutual authentication was not met by the remote server.
|
Caught System.ServiceModel.CommunicationException: An error (The request was canceled) occurred while transmitting data over the HTTP channel. ---> System.Net.WebException: The request was canceled ---> System.Net.ProtocolViolationException: The requirement for mutual authentication was not met by the remote server.
|
Here is the fix, placed in the client configuration file inside the endpoint tags (<endpoint>fix goes here </endpoint>:
<identity>
<servicePrincipalName value="spn" />
</identity>
Community:
I have a one licensed, legal
VSTS 2008 with MSDN premium subscriptions to give away to the community. If you care to take part, please send me an email with 1 paragraph explaining why you think you should be considered. That's it, no gimmicks, strings or anything funny.
I'll take the best 1 on October 31st and provide the subscriptions to the lucky person. Your contact information and email will not be published or distributed.
To participate: Send email to vstsgiveaway@live.com. Subject line - VSTS Giveaway is Back. I will pay shipping and handling charges.
Community:
I have a couple of licensed, legal
VSTS 2008 with MSDN premium subscriptions to give away to the community. If you care to take part, please send me an email with 2 paragraphs explaining why you think you should be considered. That's it, no gimmicks, strings or anything funny.
I'll take the best 3 on July 31st and provide the subscriptions to the lucky ones. Your contact information and email will not be published or distributed.
To participate: Send email to vstsgiveaway@live.com. Subject line - VSTS Giveaway. I will pay shipping and handling charges.
Aint it great that the latest from MS falls short of the accessibility mark? Gotsta luv it. Here are the details.
Microsoft is aware of the issue and working on it.
DeskTop Heap Exhaustion
Ran into another mine field the other day - blew my foot right off before I could even realize what was happening.
The client received this error:
The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, or other factors. Error in d:\nt\com\complus\src\comsvcs\threads\stathread.cpp(284), hr = 80070000: CSTAThread: CoGetApartmentID failed
The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, or other factors. Error in d:\nt\com\complus\src\comsvcs\threads\stathread.cpp(271), hr = 80070057: CSTAThread: CoInitializeEx failed
The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, or other factors. Error in d:\nt\com\complus\src\comsvcs\threads\stathreadpool.cpp(1230), hr = 8000ffff: CSTAThreadPool: Unable to get bind thread.
The run-time environment has detected an inconsistency in its internal state. This indicates a potential instability in the process that could be caused by the custom components running in the COM+ application, the components they make use of, or other factors. Couldn't get ApartmentID from STAPool
The COM+ component was configured to use a large number of threads on startup but this was working fine for several years in production. The workaround was to reduce the number of pre-allocated threads, but why was this issue surfacing?
As it turns out, the desktop heap size was the root cause. Each process running on the desktop is treated differently for "Interactive User" vs "Non-interactive User". Windows reads a registry key to determine how to treat these groups of users:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows --> SharedSection = 1024,3072,512
You can read up more on this here http://blogs.msdn.com/ntdebugging/archive/2007/01/04/desktop-heap-overview.aspx.
In the settings above, you can see that the heap is set to 3072 KB for Interactive user and just 512 KB for non-interactive users. This heap is used for system resource (e.g. thread handles). The small size prevents dllhost.exe from creating more threads.
By increasing the heap allocated for non-interactive users (from 512 -->1024) the problem was solved.
Several readers found it necessary to email me with their comments and answers to the post http://msmvps.com/blogs/alvin/archive/2008/01/07/how-old-is-the-earth.aspx. Unfortunately, there isn't a correct answer though there may be several plausible answers.
The story tries to describe the starlight problem. Starlight from distant stars travel several million years to reach the earth - we all agree on that, meaning that when we look up into the night sky, what we see is the past. Based on the time we think it takes the light to travel (represented by the boat), we say the earth is a few million years old (represented by the man on the beach). The two points of view juxtapose christianity with science. Unfortunately, since we were there when the earth was formed, there isn't an definitive answer to the problem - the man doesn't answer.
Part of my day job is to lead the migration project from VB6 to .NET. You need to be shot at if you think the migration wizard will solve your problems. That's putting it bluntly. To be politically correct, there are lots of issues. I'll document those as I run into them and keep adding to this post. Hopefully, I'll have time to write some kb articles on this as well.
The estimate of 7000 lines per week of converted code is fairly accurate. This improves with familiarity and it is possible to get to around 10,000 lines of converted code per week. See this link: http://www.devx.com/vb/article/16822
-Moving a windows VB6 client to the web that uses email. Microsoft does not support .NET and exchange server and CDO. The supported approach is to use WebDav.
-For each statements in asp pages don't return valid values. Ex.
-Replacing exceptions with the enterprise library. By default Enterprise Library Data Access Application Block uses System.Data.SqlClient as the provider. In order to be able to use ODBC connectivity, you will need to configure Data Access Application Block.
-.NET 2.0 client is not able to communicate with a web service hosted on a Windows 2000 server. Search for the string hostname in the WSDL and replace it with the IP address of the server. The exception message is usually:
[WebException: The request failed with HTTP status 404: Object Not Found.]
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +533199
System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
BFGServiceApp.ReportService.ReportURLService.ReportURLInfo(String AppKey) in C:\webroot\BFGIntranet\BFGServiceApp\Web References\ReportService\Reference.vb:80
BFGServiceApp.CallReportService.Page_Load(Object sender, EventArgs e) in C:\webroot\BFGIntranet\BFGServiceApp\CallReportService.aspx.vb:8
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
-Cannot access object properties using foreach loop. Solution is to rewrite the asp code with a for statment.
A scientist and a preacher observe a man standing on the shore next to a harbor looking at the neighboring island. A boat is docked in the harbor. Both the scientist and preacher agree that the boat likely came from the island. If it did, both agree that the boat would have taken approximately 10 hours to make the journey. The scientist and preacher ask the man 'How long have you been standing there?'. The man does not answer. Instead, he turns his head to look at the boat in the harbor.
The scientist reasons that the man must have been standing there for at least 10 hours because he likely was standing on the shore watching the boat from the time it left the island to the time it arrived in the harbor. The preacher does not think it logical for the man to have been standing on the shore for 10 hours. He reasons that the man would have gotten bored or tired. He may also have just arrived on the shore a short while ago, maybe 15 or 20 minutes or so.
How long do you believe the man has been standing on the shore?
Blame it on the strong Canadian dollar! Enjoy this new price of $19.99.
I've gotten a lot of comments on shipping to different parts of the world - customers want the Black Book and they want it yesterday. Lulu will ship anywhere and expedited shipping is possible for a very reasonable price. Don't hold your breath on an eBook download; that's not happening. Period. Your best bet is to buy using expedited shipping.
The reason why the book is not on Amazon is that the ISBN package required for that type of service will add $30.00 to the current price of the book. That's not going to happen on my watch. So, it's gonna stay on www.lulu.com/owc indefinitely.
Recently, I walked right into an ambush with .NET. A client asked how best to target a CLR version from a .NET application. Easy right? Just use this in an app.config file:
<startup>
<requiredRuntimeversion="v1.0.3705" safemode="true"/>
</startup>
As it turns out, this simply won't work for any version above 2.0. Bummer! I hate those issues because it makes you look stupid as a consultant. Even worse, it makes the framework looks like it is broken - ofcourse it is. The blame game is an appropriate response, but it doesn't solve the problem at hand.
As it turns out, there is no bullet proof way to fix this issue except to recompile the application with the appropriate targetted version of the framework. Here is the link that describes this in more detail: http://support.microsoft.com/kb/556035
The Black Book, 2nd Edition is now available at an amazing price of $24.99. However, this price is only available on www.lulu.com/owc. Amazon will continue to stock the old item. I strongly recommend purchasing the new item from www.lulu.com/owc.
The book is updated to provide:
1. More code.
2. Sample working projects with code snippets for each component.
3. WCF examples.
4. Better images.
5. Corrections and updates to licensing.
I am currently wrapping up work on the 2nd edition of the Black Book. It is expected to hit shelves in October 2007. The update includes
-
Code corrections
-
Licensing information changes
-
WCF programmability with the components
-
WCF programmability with the components
-
Updates for Visual Studio 2005
-
Updates for Visual Studio 2008
-
Direct binding of components to datasets
As you know, the Black book was an independent project not backed by any major publisher. But it has been one of my most successful books in terms of financial returns. As a thank you to my customers, I've always wanted to reduce the price on the book and infact did so on the lulu.com website where the book remained in the top 10 for 18 straight months. However, lulu changed their pricing format to reflect those of Amazon etc and the price drop vanished.
The only way to reduce the price was to purchase another ISBN. I figured, if I was going that way, I met as well see update the book in the process. This would give me a chance to incorporate user feed back and correct some issues with the book.
Now, for the good part. Since I have no major distributor on my back, I can sell the book for whatever price I see fit. My new price is $24.99
This issue seems to be raised a lot in the newsgroups. When you iterate a container, ArrayList for instance, you cannot remove items in the contain inside the body of the loop. You get a nasty exception if you have no regard for the rules.
Apparently, the run-time imposes a read-only restriction on the iterating container. The read-only restriction forces all assumptions about the container to be valid during the loop iteration process. There's an article here that discusses this in more detail.
Basically, this code produces an exception:
//arr is an arraylist with some random items
foreach (string s in arr)
{
arr.Remove(s);
}
whereas this code does not:
//notice the inline declaration of the ArrayList in the loop
foreach (string s in new System.Collections.ArrayList(arr))
{
arr.Remove(s);
}
However, I did get yelled at for providing a solution that was not efficient :-).
To be fair, the solution discussed in this article is mildly inefficient; it takes well under a second to remove 10000 items from a collection. If efficiency is your main issue, you may want to make use of the generics approach. The generics approach will follow this approach:
List<string> list = new List<string>();
//add list items
...
list.RemoveAt(find);
//define find here
public bool find(string s)
{
//add some condition here, for now return true
return true
}
To be clear, the generic approach is much faster at the expense of more code. There is no free cheese. However, because both of these approaches execute in well under a second, you earn your daily wage by focusing on other inefficient points in your application such as indexing your database records. It's not worth it to optimize away 0.5 seconds for this routine while your database records run on stale indices for instance. That's pretty pointless in my humble opinion.
Something of interest to note is that while the underlying implementation of remove is implemented with a linear search followed by a delete, the generic approach also uses a linear search using the find method. But it is important to note that this linear search is a one-time expense. This sweep marks all items for deletion and then removes them in one pass. My approach essentially incurs this expense every time remove is called. This explains the jump in performance by the generics approach.
In the real world, you won't get any brownie points for that optimization. Period. Go find somewhere else in your application to spend time and energy on.
When calling code in an ASP.NET website is transferred using server.transfer in an HTTP Module, it is not technically possible to get the virtual directory for the destination page in code. There is no current work around for this issue.
Sears contacted me this week to apologize. As a token, they've offered me $75 on a gift card. I think there is a lesson in there: as a consumer, you do have a voice. And if you make a lot of noise, you can get attention. Matter closed. I'm happy about the apology. I don't really care for the token but I guess it is the thought that counts.
Occasionally, you run into some experiences that you absolutely must share with others. Here is my experience with Sears Canada.
I bought this unit in May. The Microwave glass shattered in June. I am so far unable to determine why the glass shattered. Previously, we had used the oven to bake a cake. Inspecting the microwave after the incident, the door appeared warped and the sticking agent had leaked out. I came to the conclusion that the heat from the oven must have warped the door of the Microwave. The glass door probably shattered due to some vibration in the kitchen (such as a closing door.) Sears refuses to pay for the repair bill of $160 because they claim it was not a manufacturing defect but some object must have hit the microwave. This is an embedded oven, there's nothing close to the Microwave that could cause this damage at 8Am in the morning. Frankly, $160 doesn't bug me. What bugs me is the principle of shirking their responsibility. Being dishonest about the incident just to dodge a repair cost is simply unethical.
I called Sears customer management to report the incident. Sears refused to budge. I asked to speak to a supervisor. The customer manager refused to let me talk to his supervisor. Instead, he indicated that he reported to Sears Canada and he was not allowed to give me any further information. I asked him to identify himslef. All he would say is "My name is Brian, I work out of Ontario facility. And there is no one higher that you can complain to".
I'm disgusted by the way Sears handles warranty issues. It leaves a sour taste in my mouth. All I can do is inform others that this particular product, maybe the entire line of products is defective. Based on my experience, you will have a hard time getting Sears to deliver on any warranty repair. The customer service accountability is designed to frustrate the customer into giving up. Sears pulls no punches in dodging their responsibilities even to the point of being dishonest. I'm taking my business elsewhere from now on. I'm encouraging you to do the same. I consider this matter over, the only thing left to do is write formally to Sears and let them know that I went public with my experience.
Here is a link to the new book:
https://www.microsoft.com/MSPress/books/10933.aspx
Here are a couple of paragraphs exercepted from chapter 1:
Every now and then, a product hits the market that causes a significant shift in the way software is designed and built. Excel Services is one such product; it completely changes the way Microsoft Office applications are written. Chapter 1 will focus on introducing and explaining the Excel Services architecture that drives this fundamental shift in thinking so that you can gain an appreciation for the product. The focus is less on code and more on painting Excel Services in broad strokes allowing you to grasp the grand design. Later on, we intend to probe the basic building blocks that drive this new technology. We will then work our way up to some of the more advanced concepts of building and integrating sometimes disparate applications on top of the common infrastructure backbone exposed by Microsoft Office SharePoint Server 2007.
What is Excel Services
Excel Services is a new technology that allows developers to load, calculate, and display Excel workbooks on Office SharePoint Server 2007. In some respects, Excel Services behaves much like a development framework that allows developers to build applications based on Excel workbooks. The concept of providing a framework for developers is certainly not new, think the .NET framework. However, the way in which this technology is exposed is fundamentally different from legacy approaches. It is this radically different architecture that enables new applications that target Microsoft Office and SharePoint to be efficient, robust and scalable. Legacy Office applications can scarcely make that claim ring true.
Excel Services is built on ASP.NET 2.0 and Microsoft Office SharePoint Server 2007. The architectural decision to platform Excel Services on .NET and Microsoft Office SharePoint Server (MOSS) is significant because it means that Excel Services benefits from best-of-breed software. Consider that SharePoint is a mature technology that provides, among other things, collaboration, content management and business intelligence capabilities while ASP.NET provides a framework for building web application software. Excel Services, a part of MOSS, provides for some exciting ways to build and deploy enterprise software with internal support for key SharePoint functionality and application extensibility.
More Posts
Next page »