Navigation

Search

Categories

On this page

Updating to DasBlog 2.2
The Future of LINQ
Silverlight Session Notes from the Atlanta Code Camp 2008
Winform Design Mode Rendering Error
Visual Studio 2005: Key not valid for use in specified state
.NET Unable to Sign Assemblies or Read WSE Keys in Windows Server 2003
New Microsoft Tool for Deploying SQL Server
ASP.Net Scroll on Post Back
Das Blog ASP.Net 2.0 Vanishing Content
Using WSE 2.0 in ASP.Net 2.0

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 17
This Year: 2
This Month: 0
This Week: 0
Comments: 1

Sign In
Pick a theme:

# Wednesday, December 24, 2008
Wednesday, December 24, 2008 11:51:00 AM UTC ( ASP.Net | Das Blog )

After a lot of false starts I finally updated this site to the latest version of DasBlog.  I had been running the older version that was distributed as an ASP.Net 1.1 application.  I had converted the old 1.1 source to compile under 2.0 and had used this configuration for about three years.

The biggest challenge was to convert the existing data files to work with the version.  The DasBlog distribution comes with a conversion utility.  This worked fairly well, but seems to trip up on some imbedded HTML in some of the posts.  About four or five posts ended up with two copies in the new system.  I simply published the converted files and then deleted the duplicates.

Once the new system was operating the old permalinks were no longer working.  I have a few posts that I was frequently getting referral notices by Google from the system.  It took two or three weeks for Google to notice the changes, but they did offer a cached version of the old page in the interim.

Comments [0] | | # 
Wednesday, December 24, 2008 4:52:50 AM UTC ( Entity Framework | LINQ | Microsoft )

Maybe Microsoft has decided I don’t need to finish that book on LINQ that I bought six months ago.  Rumors are flying that the new Entity Framework will eventually replace LINQ.  Oh well, it’s just a quarter of the book that I read.  At least I didn’t spend months writing a production application based on LINQ as some have done.  The Redmond Developer News is a worthwhile magazine to read for serfs of the Evil Empire.  This article breaks the news: http://reddevnews.com/news/article.aspx?editorialsid=10472.

Comments [1] | | # 
# Friday, April 18, 2008
Friday, April 18, 2008 9:11:55 PM UTC ( ASP.Net | Silverlight )

On Saturday, March 29, I attended the Atlanta Code Camp.  Last year I skipped around to get an overview of a lot of different areas.  This year I decided to concentrate on one of the eight offered tracks, Silverlight.  I wanted a deeper knowledge of one subject, and I haven't got around to reading the Silverlight 1.0 book I bought a few months ago.

The following is a summary of my notes from the sessions.  Any errors are probably mine during transcription.  Some parts will be fragmented and maybe only make sense to me.

 1. Introducing Silverlight 2.0
  Corey Schuman - http://simplesilverlight.wordpress.com
  What’s new in Silverlight 2.0: Controls, uses of Silverlight, animations, connection to data sources.
 

Version 2.0 can consume web services, and importantly ALL calls are asynchronous.

The XAP file is like the Flash SWF file, it is a zip file of all the DLL's.

In IIS must have XAP registered as a MIME type.

The BCL is the Base Class Library.  The isolated store will hold up to 1 MB, and you can ask the end user for more up to 10 MB.

The Silverlight List Box can be used as a Control Container.  For beginners, Corey suggested the introductory series by Scott Guthrie which can be found here

 
2. Using Blend 2.0 for Silverlight / Consuming Data with Silverlight 2.0
  Shawn Wildermuth- http://adoguy.com
 

An overview of Expression Blend 2.5 for Silverlight developers was given by Shawn.  The current beta release has several bugs, it will crash on you.  One nice thing is that Visual Studio 2008 and Blend use the same solution file.

Shawn continued with an overview of consuming data with Silverlight. 

There is no ADO in Silverlight, but there is full support for LINQ to Objects and LINQ to XML.  Beware that LINQ projections have a bug.

The XDocument and the XMLDocument classes are available.  XMLDocument has a smaller footprint, but does not support XPath.  You can use XMLReader but it is difficult to work with.  Shaped results should be changed to simple types.

Silverlight tries to restrict you to calling a web service in the current domain only.  To complicate things, the client configuration is not read in the 2.0 Beta.

As stated in the first session, the asynchronous is used with Binding, EndPoint, and Proxy Classes.  If you are using the Visual Studio developer, a fixed port number is useful, as are observable collections.  The state service SOAP client uses a Sync call and completed Events.  When using WCF, you have a lot more configuration items to set.  The query-able end points should develop shape data themselves.

ADO.Net Data Services, AKA Astoria, exposes data over HTTP(S) using URI syntax and a REST interface.  The LINQ support hides REST, it is not available now but there is a Silverlight 2 library in the works.  The REST functions Get, Post, Put, and Delete do match the primary database CRUD functions.

For security cross domain calls  require permission.  The policy file "accesspolicy.xml" must be in the root of the server.  Usually this is an all or nothing situation, but you can use existing policies to allow and grant.

Only TCP sockets are allowed and are based on the platform (i.e. Winsock).  You can only connect to the local machine by "localhost".  The Beta 1 has only socket testing only, and on a small port range.

In the final session Shawn gave a brief overview of the DeepZoom composer and how to use a DeepZoom image in your Silverlight 2 application.

  Desc
 
3. Real World Silverlight Tips and Tricks
  Steve Porter and Keith Rome - http://www.wintellect.com/cs/blogs/sporter, http://www.mindfusioncorp.com/weblog
  Various Silverlight 1.0 and 2.0 tips and tricks that have been used on real projects.
  Steve and Keith presented several interesting items in their presentation, among them was the technique of using a storyboard as a timer.  The source code for these may be found at the authors weblogs. 
 
Comments [0] | | # 
# Wednesday, December 05, 2007
Wednesday, December 05, 2007 8:25:28 PM UTC ( Windows Controls )

We recently upgraded our main application to the latest version of the Infragistics controls.  Everything converted, compiled, and ran fine.  However, when you tried to open some forms in the Visual Studio designer, you got the message "The path is not of a legal form".  Looking at the project for these forms, they had invalid references to custom controls that used Infragistics controls.  I deleted the references and added the newly compiled versions to eliminate the designer rendering error.

Since we do not remove the previous version of Infragistics the older controls are found at run time. 

Comments [0] | | # 
# Friday, October 12, 2007
Friday, October 12, 2007 2:31:28 PM UTC ( )

We have recently migrated all of our workstations to a different Windows domain at our office.  Some folks were getting the following error when trying to open a DataSet in Visual Studio 2005:

Key not valid for use in specified state

The problem is caused because of the change of your username from the old domain to the new domain. This causes Visual Studio to not be able to properly decrypt some its settings.

The fix is to rename/delete the following file:

C:\Documents and Settings\YOUR USERNAME\Application Data\Microsoft\VisualStudio\8.0\ServerExplorer\DefaultView.SEView

You will now have to add back all your databases to the Server Explorer toolbox (but you only have to add them at a later time as you need them).

Thanks to Robert Stam for this tip.

Comments [0] | | # 
# Friday, August 10, 2007
Friday, August 10, 2007 8:57:34 PM UTC ( )

Recently we tried to build an older version of a system that is hosted on Windows 2003 server.  Every project in the build would fail with Visual Studio unable to sign the DLL.  Of course the DLL was not there in the target folder, but that was not the problem.  The build had worked before we rebuilt the server.

A Google search produced a suggestion to change the file permissions on:

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

We gave Administrators full access to the folders and were able to compile. 

Just a couple of days earlier, I had to give IIS_WPG access to this folder in order for a web service to be able to read the keys and decrypt a WSE message.  The service had worked fine after I had installed it and given access to the key file using the WSE key utility. 

I noticed a pending Windows update icon was no longer in the system tray.  It appears that update had tightened security on that folder.

Comments [0] | | # 
# Wednesday, March 28, 2007
Wednesday, March 28, 2007 8:49:43 PM UTC ( SQL Server | Deployment )

A new tool from Microsoft creates a single SQL file with both schema and data creation commands, and works with 2000 and 2005. Read about it at Scott Guthrie's blog.

Comments [0] | | # 
# Monday, March 26, 2007
Monday, March 26, 2007 4:57:39 PM UTC ( ASP.Net Controls | ASP.Net | Javascript )

A recent project I've been working on is a knowledge base with dynamic data structures.  As such, all of the controls placed on the update page are dynamically created at runtime. 

There is a drop down list for country and state, with the country list causing a post back to fill the state list.  We needed the page to scroll back to the country list after postback to relieve the user of having to scroll down two pages. 

It didn't take much research to find the Page directive MaintainScrollPositionOnPostback="true".  While this did get the page to scroll back to the drop down list, it also caused the page to scroll back to the submit button when there was a validation error (all done on the server side).  Hey, no problem, I'll just set that directive programatically only when the post back is caused by that drop down list.

I found a nice article by Peter Bromberg on a way to determine the control that causes a post back at http://www.eggheadcafe.com/articles/20050609.asp.  I got null exceptions when trying to return the control, so I changed the code slightly to just return a string that describes the type of control.

But more null exceptions awaited me when I tried to set the scroll back directive from the drop down list call back function.  Apparently this was also related to the dynamic nature of the page.  I decided to abandon the page directive and to wade into Javascript.

An article at ASP.Net magazine by Brad McCabe, http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309bm_l/asp200309bm_l.asp got  me started in the right direction.  The functions presented would save the scroll position in a hidden field, and that field would later be used to set the scroll position.  I converted the functions to C# and implemented them in my Page.OnInit function.  After getting all the Javascript errors resolved (always a chore for me), the page refused to scroll on post back.

Using a neat Javascript trace utility from http://www.interlogy.com/~cigdem/trace/ I was able to determine that "theBody.scrollTop", which I translated as "document.body.scrollTop", was not returning anything.  So I was saving nothing to the hidden control.

Looking further I found a set of Javascript functions by "Tigra" at http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html that would find the x or y scroll postion, and the height and width of the window.  The article also has a great cross reference table for different browsers and the window/scroll functions supported by each.

I only needed the y scroll function, and used a call to it to replace the document.page.scrollTop property.  Now Tracer was confirming that I was saving the correct scroll position, but alas the page did not scroll back.  After a little more debugging I determined the page would never scroll by setting the document.body.scrollTop in this situation since this is just a property you are setting.  Something else would have to read that value to set the scroll.  I had no idea what that might be since Javascript is not my strong point. 

But there is a scroll function, and by calling scroll(0, [saved y value]) I was able to finally get the page to scroll back only to the drop down list.

The post back control function, in App_Data/Global.asax.cs:

    public static string GetPostBackControlType(System.Web.UI.Page page)
    {
        string objectType = string.Empty;
        Control control = null;
        string ctrlname = page.Request.Params["__EVENTTARGET"];

        if (ctrlname != null && ctrlname != String.Empty)
        {
            control = page.FindControl(ctrlname);
        }
          // if __EVENTTARGET is null, the control is a button type and we need to
          // iterate over the form collection to find it
        else
        {
            string ctrlStr=String.Empty;
            Control c=null;
           
            foreach (string ctl in page.Request.Form)
            {
                // handle ImageButton controls ...
                if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
                {
                    ctrlStr = ctl.Substring(0,ctl.Length-2);
                    c= page.FindControl(ctrlStr);
                }
                else
                {
                    c = page.FindControl(ctl);
                }
                if (c is System.Web.UI.WebControls.Button ||
                   c is System.Web.UI.WebControls.ImageButton)
                {
                    control = c;
                    break;
                }
            }
        }

        if (control != null)
        {
            objectType = control.GetType().ToString();
        }

        return objectType;

    } 

The Javascript placed in the body of the aspx page:

    <script type="text/javascript" language="javascript">
        
       function SaveScrollLocation () {
            //trace('Scroll Top = ' + f_scrollTop());
            window.document.forms[0].__SCROLLLOC.value = f_scrollTop();
        }
        window.document.body.onscroll=SaveScrollLocation;

       function f_scrollTop() {
            return f_filterResults (
                window.pageYOffset ? window.pageYOffset : 0,
                document.documentElement ? document.documentElement.scrollTop : 0,
                document.body ? document.body.scrollTop : 0);
        }

       function f_filterResults(n_win, n_docel, n_body) {
            var n_result = n_win ? n_win : 0;
            if (n_docel && (!n_result || (n_result > n_docel)))
                n_result = n_docel;
            return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
        }
    </script>

The C# snippit placed in the Page OnInit function:

            // hidden field to store scroll location
            Page.ClientScript.RegisterHiddenField("__SCROLLLOC", "0");

            if (Page.IsPostBack)
            {
                string ctrlType = Global.GetPostBackControlType(this);

                if (ctrlType.Contains("DropDownList"))
                {
                    // Keep scroll at the country drop down list
                    SetScrollLocation();
                }
            }

The C# function to Set the Scroll Location:

    private void SetScrollLocation()
    {
        StringBuilder jsSB = new StringBuilder();

        jsSB.Append("<script language='javascript'>");
        jsSB.Append("function SetScrollLocation () {");
        jsSB.Append("  scroll(0," + Request["__SCROLLLOC"] + ");");
        jsSB.Append("}");
        jsSB.Append("window.document.body.onload=SetScrollLocation;");
        jsSB.Append("</script>");
       
        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "setScroll", jsSB.ToString());

    }

While this implementation only acts on the DropDownList, you could easily extend it to different controls or different dropdowns by returning the ID of the control causing the postback.

Comments [0] | | # 
# Monday, March 05, 2007
Monday, March 05, 2007 9:02:54 PM UTC ( ASP.Net | Das Blog )

I recently had all my entries disappear from this blog.  After reading about the problem at dasblog.us I extended the session timeout on the site.  It looks to me like the session expired during a lengthy editing session, and left the system in an unstable state.  I had to upload a new version of web.config to get my content to display once more. 

This entry was created using Widows Live Writer, which writes directly to the site and will avoid any session timeouts. 

Comments [0] | | # 
Monday, March 05, 2007 7:02:12 PM UTC ( ASP.Net | Web Services | WSE )

I was tasked with developing a web service for our development team that would mimick the operation of a client web service that has access limited by IP address. This target service was developed with WSE 2.0.  The encryption used in WSE 2.0 is different from that in 3.0.  Allthough some posts I read said you could change the encryption mode, I decided it would be less risky to adapt WSE 2.0 to ASP.NET 3.0. 

There are lots of sample programs for using WSE 3.0 in ASP.Net 2.0, but none using WSE 2.0. Here are a couple of things that I had to change in the Web.Config given in the sample projects that come with the WSE install:


<
security>
<
x509 storeLocation="LocalMachine" allowTestRoot="true" allowRevocationUrlRetrieval="false" verifyTrust="true"/>
<!--
Replaced UsernameSignCodeService with App_Code for using WSE 2.0 in VS2005!!!! -->
<
securityTokenManager type="EcsMockWebService.CustomUsernameTokenManager, App_Code" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" qname="wsse:UsernameToken" />
</
security>


<
webServices>
<
soapExtensionTypes>
<!--
group="0" removed from the end of the following line to use WSE 2.0 in ASP.Net 2.0 -->
<
add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1"/>
</
soapExtensionTypes>
</
webServices>

Comments [0] | | #