CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Rod Paddock

September 2007 - Posts

  • Spelunking Silverlight Article Published

    I just received word Part 1 of my Spelunking Silverlight article was published on the VB DevCenter!

     http://msdn2.microsoft.com/en-us/vbasic/default.aspx crossposted from blog.dashpoint.com
  • Accessing External Assemblies from SQL Server CLR Stored Procedures

    Accessing External Assemblies from SQL Server CLR Stored Procedures

    In the last couple of weeks I have been working on a specialized set of CLR Stored procedures for communicating with a mainframe via an ODBC driver. Each CLR stored proc will send an SQL query to the server and then dump the results of that query into a SQL Server table. There will be around 50 CLR stored procedures used to do this.

    During this process I created an abstract class. This abstract class would be the basis for each CLR stored procedure. Because of the nature of CLR stored procedures (they are all shared/static functions) I had to create a new class for each mainframe call and then instantiate that from a separate CLR stored proc.

    The code is like this:

     

    <Microsoft.SqlServer.Server.SqlProcedure()> _      
    Public Shared Sub CardholderNamesCLR(ByVal cAcctNo As String)

    Dim oTest As New CardHolderNamesLib             

    oTest.cAcctNo = cAcctNo             

    oTest.RunProc()     

    End Sub

     

    From the code you can see that I create an instance of the CardHolderNamesLib class which inherits from my abstract class. This was all fine and good when all my concrete classes and abstract class existed in the same assembly.

    So after creating two or three of these classes the client came back to me and said: “We want to put each class and CLR stored proc in its own assembly. Note I said that my abstract and concrete classes existed in the same assembly.

    To a .NET programmer this would be simple. Just create new assembly and reference it from each CLR stored proc assembly. No problem right? Well… I wouldn’t be writing this post if it was that easy.

    So I created an external assembly… Went to my CLR stored procedure project and tried adding my assembly. Right clicked on my project…selected Add Reference and…. The list was rather limited:

     Add Ref Dialog Part1

    As you can see there’s no real way to add a reference to an external assembly.

    Well I did what all good developers do. I hit Google and after consulting numerous blogs and MSDN pages there I found no answer to my question.

    Well today I found my answer…by accident actually but I found it….

    After deploying an assembly to my SQL Server I returned to my project and went to add a reference to one of the built in assemblies and what did I see. The assembly I had just deployed was there in the reference list.  Bingo! Now I could add a reference to an “external” assembly. The only requirement is the “external” assembly must be “pre-deployed” to the server.

    So I created a new SQL Server project from Visual Studio, added my abstract class and deployed that assembly to the server. Then I returned to my CLR stored procedure, went to the Add Reference dialog and there it was my assembly was included in the list of assemblies.

    Add CLR Reference Part 2

    After this it was pretty simple to refactor all my code using the abstract class contained in my "external" assembly. The funny thing about this was the total lack of posts about this subject. I guess the concept of abstract classes, concrete classes and inheritance has not made it far into the SQL Server world.

      

     

    crossposted from blog.dashpoint.com
  • MSDN Canada Speaking Engagements and INETA

     

    I have a couple of speaking engagements coming up in British Columbia.

     

    Tuesday October 9th, 2007

    Vancouver BC

    http://www.netbc.ca/DNCal/NetBcEvents.aspx

     Silverlight Adventures

    At MIX 07 in Las Vegas Microsoft released a new web development platform known as Silverlight. This session will demonstrate a number of features of Silverlight.

    Come prepared to learn: How to create a basic Silverlight application, how to control the Browser DOM with Silverlight, how to retrieve data into your Silverlight application using web services and finally how to send data to your web services from Silverlight. You should walk away from this session with a good understanding of the capabilities and limitations of Silverlight.

      

    Wed October 10th, 2007

    Victoria, BC

    http://vicdotnet.org/Default.aspx

     Ajaxing Your Applications

    Last Year Microsoft released a set of ASP.NET Ajax extensions. These extensions enable you to add Web 2.0 Style features to your ASP.NET Applications with little or no effort. In this session you will learn how to create new ASP.NET Ajax applications, how to incorporate Ajax into existing ASP.NET applications, what happens when you incorporate Ajax features into your web forms and overall how you can make your web forms smoother and more interactive. You will also learn how to incorporate the controls provided by the ASP.NET Ajax Control Toolkit.

     

    November 26 to 30th

    DevTeach

    www.devteach.com

     INETA Bound

    Also some good news… Last week I became an INETA speaker. I look forward to speaking at more user groups around the country and potentially the world. Thanks for all of those who helped make that happen.

     

    crossposted from blog.dashpoint.com
  • Fiddler to the Rescue

    Fiddler to the Rescue

    Last week I was working on a Sliverlight 1.1 article for the Visual Basic DevCenter (http://msdn2.microsoft.com/en-us/vbasic/default.aspx)  and ran into some problems making my Silverlight application communicate with a web service I included in my examples.

    After some discussion with Rick Strahl (www.west-wind.com/weblog) he told me to use Fiddler to diagnose my problem. Fiddler is a free HTTP sniffer that can be found at http://www.fiddlertool.com/fiddler/

    Fiddler is a tool that “sniffs” all HTTP traffic by inserting a proxy between the WinInet stack your web calls.  The proxy then outputs its results to a very cool windows application that will display your traffic real time. The following screen shows the output of the current version of fiddler.

    Flddler 2.0 screen

     

    After installing Fiddler it took me all of 5 minutes to see that I was not properly flushing a send buffer resulting in a bunch of “500” results calls. I added a single line of code and my code was working properly.

    On item of note Fiddler will not trace calls made to 127.0.0.1 or localhost. If you are debugging local applications you will need to address them via your machine name.

     

     

    crossposted from blog.dashpoint.com
More Posts