Mark's Stuff

My Foray Into Weblogging. Using this to store interesting items for later review.

Thursday, December 03, 2009

"Three screens and the cloud"

Interesting blog article from Keith Elder about information from PDC 2009:

.Net 4.0 - Start Reading Between the Lines ? Learn Silverlight and Entity Framework



Here's a quote: "Three screens and the cloud"

We heard this over and over at PDC. Let's read between the lines a bit shall we?

I have three screens: Windows Desktop, Web, Mobile. Ok, if I want to write an app that will run on all three what do I as a developer have to do today? Let?s see, well, we could write a ClickOnce deployed Smart Client for the Desktop that uses WPF. For the web, well, we would have to switch gears completely and rewrite our app in Asp.Net or Asp.Net MVC to get that screen. For mobile, even tougher, we have to rewrite the app again to get the mobile version. Let?s think about this differently again. Think about it, how many technologies would a developer have to know in order to an application for these three different screens; WPF, JavaScript, HTML, and CSS will be used just to name a few.

Now, let's switch gears. What if I used Silverlight 4 to write my app? Well, it could work in the browser no doubt. Hmmm, it could also work on the Desktop using the out of browser experience with elevated permissions. What about mobile?

"Wait, didn?t you just say Keith that at Mix we?ll get to see Windows Mobile 7?"

Yes!

"And hasn't there already been talk of using Silverlight for mobile?"

Yes!

"Aha! Three screens with Silverlight, I get it!"

That's right my friendly .Net developers the writing is on the wall. The vision of WPF/e (WPF Everywhere) is about to come true. We've waited for years but it is just around the corner as I predicted would happen years ago.

Labels: , , , ,

Monday, July 06, 2009

I'm A VB!

 

I'm A VB: Mark Harr

My profile was just accepted on the Microsoft Visual Basic Team's "I'm a VB" campaign. 

Labels: , ,

Monday, June 15, 2009

Interesting problem: IIS file download = 0 bytes

I ran into an interesting problem at a client site the other day.  Another developer group had written and installed a ASP.Net application (Visual Studio 2008, .Net Framework 3.5 SP1, Windows Server 2003 R2, SQL Server 2005).  Without divulging too many details, let's just say the application had a public site where users could upload a file, and an internal admin site where the internal user could download the file.  The file is being stored in the database in a varbinary(max) column.

After the sites were installed, the internal user had a problem downloading the file; it always came back as 0 bytes.  It did not matter the file type (pdfs and word docs were used), browser type (same for IE6 (standard for company), IE7, IE8, Firefox 3.x, Chrome, Opera , Safari on Windows).  The file was definitely in the database, and the original developer wrote a Windows desktop app to download the file as a temporary workaround.  The original developer swore the file download it worked just fine on their servers, and brought in a more experienced consultant to try to help diagnose the problem.  I was at this client site on another project, and was asked to take a look to see if I could spot anything.

After a few false starts doing some troubleshooting (the original developer said the VS project was a web site project, and had the code-behind files in the web directory, so we would modify the .cs file to try to track the problem, but had no results; turns out it was a web application project, and we were not recompiling the project), we did confirm the byte array from the database field was being populated.  The code was using Response.BinaryWrite, and seemed to be setting the proper headers and sending the data.  We look at the IIS web site settings over and over, trying to find some clue. 

The server the web application was installed on did have other live applications running, so our debugging the production server was limited so as to not affect the other apps. Our next attempt was to setup another Windows IIS server (virtual, on MS Virtual Server) and install the web site app on there.  The file download worked just fine there.  So it appears that the application is OK, it must be an IIS setting causing the problem.  Now that we had a server we knew it worked on, I took the metabase.xml files from both servers and worked to compare them.

That was when I saw the problem: HTTP Compression was turned on the first server.  We had missed it on the IIS Settings because that (the "Service" tab) is only on the property dialog for the Web Sites folder, not on the web sites themselves, and not on the server settings.  Here is the dialog window:

clip_image002

Turning that off did solve the download file problem, but the client was uneasy about turning it off (understandably) since it was likely turned as part of the other applications that was running on that server, and they did not want to risk that apps.

Although I knew it would not affect the other apps to turn off HTTP compression, I looked further into it and saw that HTTP compression can be turned on or off for the entire server, by web site, by directory, by file type, or by individual page, all by using adsutil commands.  I also found a .cmd file in the AdminScript directory of the server turning on HTTP compression, so I modified it to turn off compression for the web site:

CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/Filters/Compression/GZIP/HcScriptFileExtensions "asp" "dll" "exe" "pdf" "aspx" "svc"
CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/Filters/Compression/DEFLATE/HcScriptFileExtensions "asp" "dll" "exe" "pdf" "aspx" "svc"
CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/Filters/Compression/GZIP/HcDynamicCompressionLevel 9
CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/Filters/Compression/DEFLATE/HcDynamicCompressionLevel 9
CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/Filters/Compression/GZIP/HcStaticCompressionLevel 9
CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/Filters/Compression/DEFLATE/HcStaticCompressionLevel 9
CSCRIPT.EXE ADSUTIL.VBS SET w3SVC/Filters/Compression/Parameters/HcDoDynamicCompression true 
CSCRIPT.EXE ADSUTIL.VBS SET w3SVC/Filters/Compression/Parameters/HcDoStaticCompression true 
REM Added exclusion for careeradmin site; mark harr; 6/3/2009
CSCRIPT.EXE ADSUTIL.VBS SET W3SVC/2129524648/root/DoDynamicCompression false

That solved the issue.  But there were a couple other interesting things:



  • I first looked to turn off compression for just the file types (pdf, etc), but it turns out that IIS determines if compression will be done based on the requested file suffix, not the response headers. So since the file was downloaded from a postback to index.aspx, turning off compression on pdf did not have any affect.

  • Then I looked to turn off just for the page doing the download. But since the site was built with a single page (index.aspx) and loading different custom controls (ascx), I could not differentiate the page for IIS.

  • So I just turned off http compression for the admin site.  Figure that was not bad, since the site will only be accessed internally, and not likely over the internet, the lack of http compression will not be an issue.

  • After I finished this, I came up with the thought that perhaps adding a "Response-encoding: gzip" header with the file download may have also solved the problem.  IIS may have already setup that header when it determined it was doing http compression, and the code may have been clearing that header when it did the Response.Clear command before setting up its BinaryWrite.  But the code putting that header would need to ensure that compression was happening and only add the encoding header when desired.  Sometime when I have a few hours to look at that, I will see if that technique will work.

Labels: , ,

Friday, June 12, 2009

Using Windows 7 and Vista features in .Net code


Just released from Microsoft:

Windows? API Code Pack for Microsoft? .NET Framework (v0.90) - Home

Vista Bridge Sample Library 1.4

Some of the newer features in Vista and Windows 7 are not exposed in the .Net Framework (yet).  This package of source code from Microsoft shows how to access and use these features from managed code.  Some of the features here are:

Windows 7 Taskbar Jump Lists, Icon Overlay, Progress Bar, Tabbed Thumbnails, and Thumbnail Toolbars.

Known Folders, Windows 7 Libraries, non-file system containers, and a hierarchy of Shell Namespace entities.

Windows 7 Explorer Browser Control.

Shell property system.

Windows Vista and Windows 7 Common File Dialogs, including custom controls.

Windows Vista and Windows 7 Task Dialogs.

Direct3D 11.0, Direct3D 10.1/10.0, DXGI 1.0/1.1, Direct2D 1.0, DirectWrite, Windows Imaging Component (WIC) APIs. (DirectWrite and WIC have partial support)

Sensor Platform APIs

Extended Linguistic Services APIs

Power Management APIs

Application Restart and Recovery APIs

Network List Manager APIs

Command Link control and System defined Shell icons.

Labels: , , ,

Thursday, May 14, 2009

New version ASP.NET AJAX Control Toolkit

New version (3.0.30512) ASP.Net Ajax Control toolkit.  Added 3 new controls, including an HTMLEditor and ComboBox (windows-like, dropdownlist and textbox). Also 20 bugfixes to existing controls.

ASP.NET AJAX Control Toolkit

Note that these controls work only with VS 2008 and .Net Framework 3.5.

Thanks to @shanselman who twittered this announcement.

Labels: ,

Thursday, December 04, 2008

A little geek humor at Microsoft

Just discovered a little geek humor at Microsoft. 

I have the unfortunate task of upgrading a VB6 app to run properly under Vista.  No, I could not upgrade the app to .Net, just "fix" the VB app and its installer.  So I'm installing VB6 in a Vista virtual machine (do not want to mess up my host machine), and having a little problem when starting VB, an error that mscomctl.ocx is not registered.  But it is, and I hunt down Dependency Walker (Depends) to make sure.  It's OK, and its components are OK, also. 

So I run profiler from Depends to start up VB6 and see what happens.  Find an error message*, and stop the profiler. That in turn stops the VB6 application, and profiler dutifully logs the exit return code, and helpfully translates the exit code to hex:

Terminating process by user's request.
Exited "VB6.EXE" (process 0xB84) with code 57005 (0xDEAD).

Had to chuckle.  And then went to calc.exe to confirm, decimal 57005 is hex 0xDEAD.

(*for what it's worth, the error is "GetProcAddress(0x75E70000 [KERNEL32.DLL], "IsTNT") called from "MSCOMCTL.OCX" at address 0x27588909 and returned NULL. Error: The specified procedure could not be found (127)."  Now I got to got figure that one out.)

Labels: , ,

Tuesday, December 02, 2008

New ASP.NET Charting Control

 

Microsoft has now released a ASP.Net Chart control.  Formerly from Dundas, this control was recently added to Reporting Services, and is now available for free for ASP.Net developers.

  • Download the free Microsoft Chart Controls
  • Download the VS 2008 Tool Support for the Chart Controls
  • Download the Microsoft Chart Controls Samples
  • Download the Microsoft Chart Controls Documentation
  • Visit the Microsoft Chart Control Forum
  • Ref from Scott Guthrie's blog: New ASP.NET Charting Control: - ScottGu's Blog

    Labels: ,

    Tuesday, November 18, 2008

    An Ajax Cross Browser GridView Fixed Header Extender

     

    DevArchive.net Blog: Cross Browser GridView Fixed Header Extender, ASP.NET AJAX

    A nice AJAX extender control for GridView to provide fixed header row for scrolling grid.

    Labels: ,

    Saturday, November 15, 2008

    jQuery Update: Intellisense

     

    Microsoft has released a patch for VS 2008 to enable better intellisense support for Javascript files, esp. jQuery.  This patch enhances VS to look for like-named javascript files for intellisense documentation.  For instance, for jQuery, you would have these lines in the head of your page:

    Downloads:

    VS 2008 SP1 Hotfix: http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736

    jQuery:
    http://docs.jquery.com/Downloading_jQuery#Download_jQuery

    jQuery Doc:
    http://code.jquery.com/jquery-1.2.6-vsdoc.js
    (or use jQuery download above, and select the "Documentation: Visual Studio" link)

    Labels: ,

    Friday, October 17, 2008

    What is jQuery?

    I first heard of jQuery when Microsoft (actually, Scott Guthrie, the Microsoft VP for Developer Division) announced support for it (see the link below). Then, the .Net Developer User Group had a session on it last week. This is something simple, easy to implement and add to our toolkit, and can save a ton of time adding desirable features to our websites.

    If you have not heard about jQuery before:

    • JavaScript library, just link a javascript file to your web page to enable it.
      e.g. : <script type="text/javascript" src="../jquery.min.js"></script>
    • a lightweight JavaScript library, only 15kb in size.
    • Licensed under GPL or MIT (any and all use is free, commercial or otherwise permitted)
    • supported browsers: Firefox 1.5+, Internet Explorer 6+, Safari 2.0.2+, Opera 9+

    Good beginning description of it from Scott Guthrie’s blog (http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx):

    A big part of the appeal of jQuery is that it allows you to elegantly (and efficiently) find and manipulate HTML elements with minimum lines of code.  jQuery supports this via a nice "selector" API that allows developers to query for HTML elements, and then apply "commands" to them.  One of the characteristics of jQuery commands is that they can be "chained" together - so that the result of one command can feed into another.  jQuery also includes a built-in set of animation APIs that can be used as commands.  The combination allows you to do some really cool things with only a few keystrokes.

    For example, the below JavaScript uses jQuery to find all <div> elements within a page that have a CSS class of "product", and then animate them to slowly disappear:

    clip_image002

    As another example, the JavaScript below uses jQuery to find a specific <table> on the page with an id of "datagrid1", then retrieves every other <tr> row within the datagrid, and sets those <tr> elements to have a CSS class of "even" - which could be used to alternate the background color of each row:

    clip_image004

    Microsoft will be bundling and supporting jQuery from now on

    Again from Scott Guthrie’s blog:

    • “Microsoft will be shipping jQuery with Visual Studio going forward”
    • “We will distribute the jQuery JavaScript library as-is, and will not be forking or changing the source from the main jQuery branch.  The files will continue to use and ship under the existing jQuery MIT license.”
    • “will also distribute intellisense-annotated versions that provide great Visual Studio intellisense and help-integration at design-time.”
    • “add the jQuery library by default to all new projects.”
    • “We will also extend Microsoft product support to jQuery beginning later this year, which will enable developers and enterprises to call and open jQuery support cases 24x7 with Microsoft PSS.”
    • “Going forward we'll use jQuery as one of the libraries used to implement higher-level controls in the ASP.NET AJAX Control Toolkit.”

    Here are some links on jQuery:

    · http://jquery.com/

    · Download: http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.min.js&downloadBtn=%3CSPAN%3EDownload%3C%2FSPAN%3E

    · Documentation: http://docs.jquery.com/Main_Page

    · Tutorials: http://docs.jquery.com/Tutorials

    · Scott Hanselmann’s tutorial using jQuery in Visual Studio and Ajax and ADO.Net Data Services: http://www.hanselman.com/blog/jQuerytoshipwithASPNETMVCandVisualStudio.aspx

    Labels: , ,

    Thursday, July 03, 2008

    Windows Mobile: Configuration Steps to Test localhost Web-Services

    This blog entry describes how to configure VS2008, WMDC and Windows Mobile Device Emulator to call local web services running under VS debugging.

    This was also useful as it fixed my perplexing problem trying to get Device Emulator to connect to WMDC so that I can install .Net CF 3.5.  Specifically, making sure transport mode is DMA in WMDC, VS, and the device; and device emulator must be in Cradle mode.

    Public Sector Developer Weblog : Windows Mobile 6: Configuration Steps to Test localhost Web-Services

    Labels: , ,

    Wednesday, May 28, 2008

    Introducing RockScroll

     

    Very cool add-in for Visual Studio, from:

    Scott Hanselman's Computer Zen - Introducing RockScroll

    The basic (as in "only") idea is that RockScroll extends the scrollbar in Visual Studio to show a syntax highlighted thumbnail view of your source. This is really useful for those excessively long source code files...

    RockScroll

    Labels: ,

    Tuesday, February 19, 2008

    Microsoft DreamSpark

     

    Microsoft DreamSpark

    Today, Microsoft announced that college students can download Visual Studio, SQL Server, Expression Blend, even Windows Server FOR FREE!

    How would you like a free copy of Microsoft Visual Studio 2008? How about the entire Microsoft Expression Studio? Not enough...... how about Microsoft Windows Server 2003 and more?
    For once, something that sounds too good to be true really is this good and really is true. Starting today (or soon in some areas), students worldwide will be able to download our professional development and design tools for free! It's called DreamSpark and it is upon us.

    Wow.  Why?  From PressPass:

    PressPass: What is the thinking behind Microsoft DreamSpark? And how did you come up with the name?

    Wilson: Microsoft DreamSpark is a community-based program to provide students with free access to Microsoft’s industry-leading software development, gaming and design tools. Working with schools, governments, partners and student organizations worldwide, we will be making this available starting today in Belgium, China, Finland, France, Germany, Spain, Sweden, Switzerland, the United Kingdom and the United States. Other countries will come online over the next year, as well as expanding the program to include high school students. The program is open to all students at education institutions worldwide, though those studying science, technology, engineering and math disciplines (STEM-D) are expected to be the first to jump on it. All eligible students need is access to a computer with an internet connection to download the products, as well as free access keys at http://channel8.msdn.com.

    We call it DreamSpark because every great technology breakthrough starts life as someone’s dream or idea. We want to make sure that students have the tools to spark their own dreams plus the power to turn them into reality.

    PressPass: Why is Microsoft doing this?

    Wilson: We believe students can do amazing things with technology if given access to the right tools. This is a way to make sure that they have what they need to test the boundaries of what today’s technology can do and also prepare for a great career at the same time. The added benefit to industry is that we’re addressing one of the toughest challenges confronting employers today: attracting and developing qualified IT professionals. We’re trying to help close this gap by giving students globally the opportunity to get the tools they’ll need after they graduate and jump-start their careers to land that first job.

    Making sure there is a strong pipeline of technically skilled students is key to the future of the global economy. The ability to create new software and services will be an essential part of the skill set of the next generation of workers. Technology is one of the chief drivers pushing worldwide economic development and job creation. As well as giving students important exposure to the tools they can expect to use in the workplace, DreamSpark is about putting professional-level tools in the hands of students to amplify the impact of their studies and fire up their imaginations about the power of technology.

    Labels: , , ,

    Tuesday, January 29, 2008

    VS2008 Web Deployment Project Released

    Scott Guthrie's blog announces "RTW (release to web) support for VS 2008 Web Deployment projects".

    Web Deployment projects can be used with either the "ASP.NET Web Site" or "ASP.NET Web Application Project" options built-into VS 2008, and provide a few additional build, packaging and deployment options for you to use.

    It also adds additional support for:

    • Easily migrating VS 2005 Web Deployment Projects to VS 2008 Web Deployment Projects
    • Replacing output only if web deployment builds succeed
    • IIS7 Support

    Labels:

    Thursday, January 03, 2008

    The Visual Basic Team : Hidden Gems in Visual Basic 2008 (Amanda Silver)

    The Visual Basic Team : Hidden Gems in Visual Basic 2008 (Amanda Silver): "Hidden Gems in Visual Basic 2008"


    0) Multi-targetting
    1) Type Inference
    2) If Operator
    3) Object Initializers
    4) Nullable
    5) LINQ to DataSet
    6) Syntax Tooltips
    7) XML Namespace support in Intellisense
    8) GoTo Type Definition
    9) Type inference for loop variables
    10) Performance improvements and? Non-blocking operations!

    Labels:

    Tuesday, October 23, 2007

    ASP.NET MVC Framework - ScottGu's Blog

    ASP.NET MVC Framework - ScottGu's Blog

    Scott Guthrie is working on implementing a bolt-on MVC framework for ASP.Net 3.5; should be out shortly after VS2008, and built into .Net 3.5 SP1.

    MVC (Model-View-Controller) framework may be the piece that I considered missing in AJAX, but could not put my finger on. Like many new things, it is based on some older tech (Smalltalk in 80's), and its underlying architecture is not too far different from what has been done in the past. But this could help to really tie things together, especially with some web controls that have inherit MVC functionalality.

    HMMM

    Labels:

    Wednesday, July 11, 2007

    Doug Seven : Windows Server 2008, Visual Studio 2008 and Microsoft SQL Server 2008 Joint Launch Announced