Archive for July, 2006

Guidance Explorer

Microsoft recently released Guidance Explorer, a tool that contains a browsable collection of best-practice patterns for developing .Net and ASP.Net applications.

Guidance Explorer

Both the tool and its guidance library have regular updates, containing best-practices for performance and security related issues.

The tool also has the ability to add custom sets of guidance to allow corporate/team standards to be included.

Add comment Permalink July 19th, 2006 Adrian Banks
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

SerializationException And System.Data.SqlClient.SqlError

When remoting, it’s possible to get a strange exception if an SQLException occurs on the server.

The stack trace of the error is:

Exception: System.Runtime.Serialization.SerializationException
Message: Member name ‘System.Data.SqlClient.SqlError server’ not found.

Stack trace:
at System.Runtime.Serialization.Formatters.Binary.ReadObjectInfo.GetMemberTypes (String[] inMemberNames)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.ObjectMap.Create(String name, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (Stream serializationStream, HeaderHandler handler, Boolean fCheck, IMethodCallMessage methodCallMessage)
at System.Runtime.Remoting.Channels.CoreChannel.DeserializeBinaryResponseMessage(Stream inputStream, IMethodCallMessage reqMsg, Boolean bStrictBinding)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)



What is actually happenning here is that the System.Data dll on the client is a slightly different version to that on the server. When the SQLException is deserialised at the client end, there is a missing property on the client that cannot be deserialised.

This error usually occurs when remoting to a Windows 2003 Server box from a non-W2003 client box. The client has a System.Data.dll of version 1.1.4322.2032. The server has a System.Data.dll of version 1.1.4322.2300. The difference is that the server property of the SqlError class is never set in v1.1.4322.2032, causing the serialisation error. More detailed info can be found on the DevNewsGroups site.

Microsoft has two knowledge base articles, KB884871 and KB887549, that pertain to this issue. The suggested solution is a .NET Framework 1.1 post-SP1 hotfix, but this is only available by contacting Microsoft directory.

The hotfix solves the problem, but then stops old SqlError types from being deserialised, resulting in the exception:

Exception: System.Runtime.Serialization.SerializationException
Message: Wrong number of Members. Object System.Data.SqlClient.SqlError has 8 members, number of members deserialized is 7.

Stack trace:
at System.Runtime.Serialization.Formatters.Soap.ReadObjectInfo.PopulateObjectMembers()
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.ParseObjectEnd(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Parse(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Soap.SoapHandler.EndElement(String prefix, String name, String urn)
at System.Runtime.Serialization.Formatters.Soap.SoapParser.ParseXml()
at System.Runtime.Serialization.Formatters.Soap.SoapParser.Run()
at System.Runtime.Serialization.Formatters.Soap.ObjectReader.Deserialize(HeaderHandler handler, ISerParser serParser)
at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream, HeaderHandler handler)
at System.Runtime.Serialization.Formatters.Soap.SoapFormatter.Deserialize(Stream serializationStream)



This means that the hotfix is not backwards-compatible. The only way to get everything happy is to upgrade all W2003 boxes to SP1 and all clients (W2000 and XP) to .Net 1.1 SP1 plus the hotfix.

1 comment Permalink July 19th, 2006 Adrian Banks
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

ASP.Net Web Development Helper For IE

Nikhil Kothari has made a nice little Web Development Helper for ASP.Net. It works as a plugin for Internet Explorer and is similar to the Internet Explorer Development Toolbar, but with more of an ASP.Net twist.

Some of its most useful features are:

  • Rich error information for script errors, including call stack, script url and line number.
  • A DOM inspector with filtering to enable easy viewing of particular items.
  • A view state browser.
  • Trace information can be shown in a separate dialog instead of in the page itself.
  • A full HTTP/HTTPS logger showing all traffic between the browser and the server.

The Web Development Helper requires .Net 2.0 to run and can only work on the same machine as the server, but this should not be a problem during development.

After installation, I had the same problem that lots of other people seem to have in that clicking the newly installed toolbar button did nothing. The suggested fix of installing the Internet Explorer Development Toolbar solved the problem though. Nikhil also suggested that a reboot (or killing explorer.exe) may also work because information about plugins is cached on startup.

Add comment Permalink July 10th, 2006 Adrian Banks
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

.Net 2.0 Installation

Aaron Stebner posted a recent article about the available installation modes for the .Net Framework 2.0.

There are three supported modes:

  • Standard Mode
    All UI screens are displayed, including warnings about missing prerequisites, existing beta versions, errors and reboots.

    The setup includes a multi-lingual UI that chooses the correct language from the user's operating system UI language settings, so a user should always see the install in their preferred language.

  • Unattended Mode
    All UI screens are suppressed, except for a progress dialog during installation.

    To install in unattended mode, use the following command line:

    dotnetfx.exe /q:a /c:"install.exe /qb"

    Changing /qb to /qb! will hide the cancel button on the progress dialog, stopping the user from aborting the install.

  • Silent Mode
    All UI screens are suppressed. This is useful for a custom installer to install the .Net Framework.

    To install in silent mode, use the following command line:

    dotnetfx.exe /q:a /c:"install.exe /q"

    If using silent mode, any errors, previous beta versions or reboots must be handled by the hosting installer since the .Net Framework installer cannot display any dialogs to prompt the user. Aaron also provides details of possible return codes from the installer, how to detect previous beta versions of the framework and how to manage reboots.

Add comment Permalink July 10th, 2006 Adrian Banks
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post

The Perils Of sp_rename

Andras Belokosztolszki from Red Gate posted an interesting article about the sp_rename stored procedure in SQL Server and the pitfalls that can occur after its use.

When a stored procedure is created, an object is created in the sysobjects table (or the sys.objects view in SQL Server 2005), and the textual definition is stored in the syscomments table (or the sys.sql_modules view in SQL Server 2005).

When using sp_rename to rename a stored procudure, the definition is left intact and only the name is changed in the sysobjects table (or sys.objects view). This means that the definition of the stored procedure stored in database now has the wrong name.

The best way of renaming a stored procedure is to completely delete it and then recreate it with the new name.

The following SQL displays the definitions of all stored procedures in a database alongside their names:

SQL Server 2000

SELECT V2.[name], V1.[text]
    FROM syscomments AS V1, sysobjects AS V2
    WHERE V1.[id] = V2.[id]
    AND (V2.[xtype] = 'P' OR V2.[xtype] = 'F')

SQL Server 2005

SELECT V2.[name], V1.[definition]
    FROM sys.sql_modules AS V1, sys.objects AS V2
    WHERE V1.[object_id] = V2.[object_id]

It is worth noting that enterprise manager uses the sp_rename stored procedure when using the right-click rename option (although SQL Server 2005 management studio does try to correct this problem if you view the definition of a renamed stored procedure by replacing the original stored name with the new one).

Add comment Permalink July 10th, 2006 Adrian Banks
Subscribe to this feed Bookmark this post on del.icio.us Digg this post on digg.com Share this post


Calendar

July 2006
M T W T F S S
« Jun   Aug »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

Posts by Month

Posts by Category

RSS Feeds Feeds

Visitors

Visitor Map