I did a presentation for our internal user group about languages other than C# including SML, Scheme, and Ruby. I was attemping to illustrate functional programming, code as data, lazy evaluation, and dynamic typing to a group who had mostly only dealt with C#, partly to talk about elements from those sources that LINQ will incorporate and partly just to share my enthusiasm.
I hadn't touched SML in quite awhile, but it was really easy to pick back up and still was just as much fun to write. It's powerful, expressive, and has a nice, clean syntax. It might fit really well in a middle-tier type setting, since that would side step the need for strongly typed database access or a web service toolkit. I need to investigate SML.NET and F# some more as potential avenues to make this happen. The OCAML syntax of F# bugs me, but I read a cool paper linked off of LtU about its template/meta-programming capabilities which seemed really promising.
The more I learn about Ruby, the more I like it as a language, too. The dynamic typing bit still scares me some (especially after SML), but metaprogramming as a means to eliminate boilerplate junk and also to build internal DSLs is just cool. The interop with .net story isn't quite there yet, but I bet it will be soon. For the time being, I'm going to play around with using Ruby to generate C#/XML/WSDL/etc.
Saturday, August 19, 2006
Tuesday, August 08, 2006
WF, ASP.NET, and transactions
My current project has some pretty simple business logic that seemed like it would be a good fit for WF. I was looking for a good excuse to try it out for real so I started investigating using it and immediately ran into several key problems.
The first is that there aren't many samples available relating to using WF with an ASP.NET host. Some of this is because it's still beta, but the only ASP.NET stuff available is either hopelessly trivial (start a workflow on a button click and then wait for it to finish before returning) or just not analogous to a real situation (no error handling, transactions, etc.). Additionally, you have to use a manual scheduler as opposed to the default one. I'm trying to get WF to replace business logic, so it would live in the service layer. I'd need extra code there to check whether we were running with the manual scheduler or not (in order to call RunWorkflow if necessary), which seems gross.
The other big issue is that it doesn't seem possible to have workflows participate in a transaction that is initiated by the host. My scenario involves keeping track of many running instances that all need to be finished and exported at once. This would involve iterating over each instance, sending it a specific event, and then, once all instances have been notified, running a stored proc (or something) once to do the export. All of that needs to be in one transaction, but it appears this isn't possible.
I might have to not use WF for this scenario if I can't find answers to those questions. I'm also concerned that if there aren't good answers, it may severely limit the applicability of WF.
The first is that there aren't many samples available relating to using WF with an ASP.NET host. Some of this is because it's still beta, but the only ASP.NET stuff available is either hopelessly trivial (start a workflow on a button click and then wait for it to finish before returning) or just not analogous to a real situation (no error handling, transactions, etc.). Additionally, you have to use a manual scheduler as opposed to the default one. I'm trying to get WF to replace business logic, so it would live in the service layer. I'd need extra code there to check whether we were running with the manual scheduler or not (in order to call RunWorkflow if necessary), which seems gross.
The other big issue is that it doesn't seem possible to have workflows participate in a transaction that is initiated by the host. My scenario involves keeping track of many running instances that all need to be finished and exported at once. This would involve iterating over each instance, sending it a specific event, and then, once all instances have been notified, running a stored proc (or something) once to do the export. All of that needs to be in one transaction, but it appears this isn't possible.
I might have to not use WF for this scenario if I can't find answers to those questions. I'm also concerned that if there aren't good answers, it may severely limit the applicability of WF.
Tuesday, August 01, 2006
More WinFX WF Beta 2 fun
Although I got my installation problems resolved on my laptop, my work machine continued to have problems with Workflow Foundation. When starting Visual Studio I'd get the following error:
Package Load Failure
Package 'Microsoft.Workflow.VSDesigner.DesignerPackage, Microsoft.Workflow.VSDesigner, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' has failed to load properly ( GUID = {FD526733-BD72-4F81-BEEC-BEB06E2AF59F} ).
I found some people who had similar problems that arose from using an incompatible WinFX beta with a pre-release version of Visual Studio, but nothing with RTM. While tracking down the problem I discovered how to generally troubleshoot Visual Studio package load failures. If you start Visual Studio from the command line with the "/log" option ("devenv /log"), an xml log file is created in "c:\Documents and Settings\[username]\Application Data\Microsoft\VisualStudio\8.0\" called "ActivityLog.xml".
Mine showed 1 warning (CheckPackageSignature failed; invalid Package Load Key {FD526733-BD72-4F81-BEEC-BEB06E2AF59F}) and 2 errors (SetSite failed for package [Microsoft.Workflow.VSDesigner.DesignerPackage, Microsoft.Workflow.VSDesigner, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35] and End package load).
Searching on those GUIDs and more detailed error messages I was able to find someone with a similar problem that resulted from having an old Add In file pointing to a location that no longer existed. Sure enough, in "C:\Documents and Settings\[username]\Application Data\Microsoft\MSEnvShared\Addins" I had a ".AddIn" file I had created ages ago in a folder that no longer exists. Once I deleted this file, Visual Studio loaded just fine.
I have no idea why this seemingly unrelated thing caused WF to fail, but at least it's resolved.
Package Load Failure
Package 'Microsoft.Workflow.VSDesigner.DesignerPackage, Microsoft.Workflow.VSDesigner, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' has failed to load properly ( GUID = {FD526733-BD72-4F81-BEEC-BEB06E2AF59F} ).
I found some people who had similar problems that arose from using an incompatible WinFX beta with a pre-release version of Visual Studio, but nothing with RTM. While tracking down the problem I discovered how to generally troubleshoot Visual Studio package load failures. If you start Visual Studio from the command line with the "/log" option ("devenv /log"), an xml log file is created in "c:\Documents and Settings\[username]\Application Data\Microsoft\VisualStudio\8.0\" called "ActivityLog.xml".
Mine showed 1 warning (CheckPackageSignature failed; invalid Package Load Key {FD526733-BD72-4F81-BEEC-BEB06E2AF59F}) and 2 errors (SetSite failed for package [Microsoft.Workflow.VSDesigner.DesignerPackage, Microsoft.Workflow.VSDesigner, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35] and End package load).
Searching on those GUIDs and more detailed error messages I was able to find someone with a similar problem that resulted from having an old Add In file pointing to a location that no longer existed. Sure enough, in "C:\Documents and Settings\[username]\Application Data\Microsoft\MSEnvShared\Addins" I had a ".AddIn" file I had created ages ago in a folder that no longer exists. Once I deleted this file, Visual Studio loaded just fine.
I have no idea why this seemingly unrelated thing caused WF to fail, but at least it's resolved.
Friday, July 21, 2006
Quick .NET Web Reference Note
Apparently setting the URL property of a web service proxy class resets the Credentials property to the default. This means that if you're setting both, make sure to set URL and then Credentials. Intuitively I guess this would make sense if the pattern of use involved reusing the same proxy for calls to identical services in different locations. Given that in reality you usually create the proxy, optionally set properties like URL and Credentials, make some calls, and ditch the proxy, I don't know why that behavior exists.
Sunday, July 16, 2006
Http.sys and Rails
I made some good progress today on my .Net web server for Rails based on Http.sys. Ultimately I want it to support a pool of ruby interpretters, URL rewriting, and serving regular files (static and dynamic (aspx)) via http.sys. I already have the basic non-Ruby file serving in place through the magic of HttpRuntime.ProcessRequest. Right now I'm working on some simple wrapper classes to handle CGI. Once I have that done, I'll add URL rewriting so I can get Rails running. The last step is the process pool, so things actually run quickly.
Initially I'm going to try using a TCP socket as a control channel where the server can signal the child process to begin working and the child can tell the server when it's done. FastCGI looks like it actually multiplexes control information along with standard input and output over the TCP. Perhaps there's a good reason for that, but I'm going to start with the server writing to and reading from the child's standard in and out directly, orchestrated by the control channel.
My goals are both to learn about Rails from a development and solution architecture perspective and to simply the process of getting a production-ready Rails server setup on Windows. Rails can definitely have a place in a real enterprise architecture, but requiring clients with Windows servers to install and maintain apache (or lighttpd, etc.) in addition to IIS is a big hurdle. Having something based on http.sys should mitigate a lot of this (unified instrumentation, etc.).
Initially I'm going to try using a TCP socket as a control channel where the server can signal the child process to begin working and the child can tell the server when it's done. FastCGI looks like it actually multiplexes control information along with standard input and output over the TCP. Perhaps there's a good reason for that, but I'm going to start with the server writing to and reading from the child's standard in and out directly, orchestrated by the control channel.
My goals are both to learn about Rails from a development and solution architecture perspective and to simply the process of getting a production-ready Rails server setup on Windows. Rails can definitely have a place in a real enterprise architecture, but requiring clients with Windows servers to install and maintain apache (or lighttpd, etc.) in addition to IIS is a big hurdle. Having something based on http.sys should mitigate a lot of this (unified instrumentation, etc.).
Thursday, July 13, 2006
WinFX WF Beta 2 installation problems resolved
Over the course of messing with a new version of LINQ and other things, my WinFX Beta 2 install somehow got corrupted. When I tried to load the Workflow Foundation Designer I got the following error message:
Method 'ElementRemoved' in type 'TypeProviderHost' from assembly 'Microsoft.Workflow.VSDesigner, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
I tried removing everything (Visual Studio Extensions for WF, Orcas CTP, Windows SDK, WinFX Runtime) and reinstalling and the same thing happened. Finally I was able to find this which solved my problem, even though the original question is about Beta 1. Basically, if you have 2 versions of EnvDTE80 in the GAC, remove the one with the lower Version (right click->Properties->Version tab).
Now everything is working and I can get back to preparing for my upcoming Devcare presentation.
Method 'ElementRemoved' in type 'TypeProviderHost' from assembly 'Microsoft.Workflow.VSDesigner, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
I tried removing everything (Visual Studio Extensions for WF, Orcas CTP, Windows SDK, WinFX Runtime) and reinstalling and the same thing happened. Finally I was able to find this which solved my problem, even though the original question is about Beta 1. Basically, if you have 2 versions of EnvDTE80 in the GAC, remove the one with the lower Version (right click->Properties->Version tab).
Now everything is working and I can get back to preparing for my upcoming Devcare presentation.
Sunday, July 09, 2006
WEBrick Issues
I spent several hours today trying to get the most basic Rails site possible running on my laptop and only recently succeeded. Initially, something prevented remote Ruby Gem installs from working at all (gem install would just hang), so I had to chase down all the gem files and download them manually. When I finally got all that done, WEBRick just wouldn't respond to requests. Everything started ok, but when I hit http://localhost:3000/ in my browser I got "Waiting for..." and nothing else. I eventually had to kill the cmd.exe process to even get WEBrick to exit.
After lots of running in circles (even attempting to install mongrel which proved difficult since I couldn't find a win32-service.gem >= version 0.5.0 anywhere) I discovered the issue. A few weeks ago I did a half a day's work for a remote client that required secure VPN access. I had to install some software that worked with the little key generator they mailed me. After ruling out all sorts of firewall and connectivity problems I thought of this Juniper Networks stuff they had me install and once I removed it everything worked fine. Both WEBrick and my remote gem installs functioned perfectly. Whatever it was doing was enough to mess up Ruby's network code, without bothering my browser or any .NET apps I wrote.
Very odd.
After lots of running in circles (even attempting to install mongrel which proved difficult since I couldn't find a win32-service.gem >= version 0.5.0 anywhere) I discovered the issue. A few weeks ago I did a half a day's work for a remote client that required secure VPN access. I had to install some software that worked with the little key generator they mailed me. After ruling out all sorts of firewall and connectivity problems I thought of this Juniper Networks stuff they had me install and once I removed it everything worked fine. Both WEBrick and my remote gem installs functioned perfectly. Whatever it was doing was enough to mess up Ruby's network code, without bothering my browser or any .NET apps I wrote.
Very odd.
Subscribe to:
Posts (Atom)