Thoughts from Dan Miser RSS 2.0
 Wednesday, May 24, 2006
I recently needed to monitor the HTTP traffic of an application that I wrote in order to debug why things were failing. Unfortunately, a simple proxy wouldn't work since the HTTPS traffic is encryped by SSL. This makes sense, since you really would hope that the data you send when surfing on a secure web page would be secure. I ended up solving this problem the same way you can solve every programming problem in the world: add a layer of indirection.

To start, I downloaded and installed the latest binaries of stunnel. Before starting, I modified the conf file to add the following entry:


[dor]
accept=localhost:8080
connect=www.MySuperSecureSite.com:443

Then, I installed tcpTrace and set things up to Listen on port 8079 and forward to localhost:8080. Lastly, in my application, I connected to http://localhost:8079/MyPath. This would eventually forward all of the traffic to the real destination, but I was able to spy on the details in tcpTrace since that was just HTTP traffic.

After doing this, I could see where things were malformed and clean my code up to submit things in the desired format.

Wednesday, May 24, 2006 1:08:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -

 Tuesday, May 16, 2006
In the README for the LINQ download, one big feature that was mentioned was the ability to use an external XML mapping file instead of attributes. This decouples the schema information from the code, which is good as a database schema tends to change over time, and you don't want to recompile every time your DBA decides to change something on you. The down side is that there isn't much information out there on how to get it to work. Hopefully, this entry fills that gap.

The first thing to note is the syntax of the XML mapping file. You can take a look at LINQ Preview\Docs\DLINQ Mapping Schema.xsd for more information on the mapping format, but here is a shortened extract from LINQ Preview\Data\samplemapping.xml to give you a look at a concrete implementation:


<?xml version="1.0" encoding="Windows-1252"?>
<Database Name="Northwind">
  <Table Name="Categories">
    <Type Name="Mapping.Category">
      <Column Name="CategoryID" Member="CategoryID" Storage="_CategoryID" DbType="Int NOT NULL IDENTITY" IsIdentity="True" IsAutoGen="True" />
      <Column Name="CategoryName" Member="CategoryName" Storage="_CategoryName" DbType="NVarChar(15) NOT NULL" />
      <Column Name="Description" Member="Description" Storage="_Description" DbType="NText" UpdateCheck="Never" />
      <Column Name="Picture" Member="Picture" Storage="_Picture" DbType="Image" UpdateCheck="Never" />
      <Association Name="FK_Products_Categories" Member="Products" Storage="_Products" ThisKey="CategoryID" OtherTable="Products" OtherKey="CategoryID" />
    </Type>
  </Table>
</Database>

The above code shows how the Categories table in the Northwind database could be mapped in an XML file. One thing of special note here is the Association element which will allow data hierarchies to be established, much like you can do in the DLINQ designer. You can generate this file by hand if you want, or you can use the new version of LINQ Preview\bin\sqlMetal.exe to generate the starting point for you. sqlMetal has a lot of options for you to look at, including a bunch to take save snapshots of database schema information to an xml file, and generate classes and XML mapping files from that saved XML file. A sample command would look like this:


sqlmetal /server:(local) /database:Northwind /map:nwindmapping.xml /namespace:Mapping /code:nwind.cs

The resulting nwind.cs file does not contain any attributes, as they are all stored in the xml file. To use this file, use code like this:


    XmlMappingSource mappingSource = XmlMappingSource.FromXml(File.ReadAllText("nwindmapping.xml"));
    Mapping.Northwind db = new Mapping.Northwind("Integrated Security=SSPI;database=northwind;server=(local)", mappingSource);
    var q = from c in db.Categories 
            select c.CategoryName;
    foreach (string s in q)
        listBox1.Items.Add(s);
Tuesday, May 16, 2006 12:10:00 PM (Central Standard Time, UTC-06:00)  #    Comments [2] -
LINQ
 Friday, May 12, 2006
While ActiveX has enjoyed a (mostly) deserved reputation for being ill-tempered and hard to work with, I've used it successfully for many years as a deployment vehicle for rich-client web applications that run inside the context of IE. I'll attribute most of that success to Delphi and ActiveForms since the most complicated plumbing is taken care of for me automatically, but still gives me the ability to override what I need. Special thanks should go to Lino Tadros and Steve Teixeira, former members of the Delphi R&D team, to allow this.

Fast forward to today. My goal is relatively simple. I have a .NET application built with WinForms. I'd like the same type of ease of use in deploying this WinForm application to my users. I've done quite a bit of research on the best way to achieve this, but I haven't come up with the perfect solution yet. I'm close, but it's not buttoned up all of the way yet. For starters, I would highly recommend the following articles:

I wasn't able to find this nugget anywhere, though. If you want to call methods from your HTML page via (e.g.) JScript, you need to make your EXE assembly COM visible. The easiest way to do this is to select Properties for the EXE in the Project Manager, and press Assembly Information. There, you'll find a checkbox to make this assembly COM visible.

So far, I've been able to get a WinForm EXE hosted in IE, strong-name it and communicate from the web page to the control. I still have several items left to tackle, like wrapping everything up in a CAB file for easier deployment, and getting calls to other assemblies working. I'll comment on those as I get to them, but if you have any pointers on better ways to do any of this, I'm all ears!

Friday, May 12, 2006 2:29:00 PM (Central Standard Time, UTC-06:00)  #    Comments [3] -
Delphi
 Wednesday, May 10, 2006
LINQ is coming along nicely. This release is full of goodies. Among my favorites: join support, DLINQ graphical designer, LINQ over DataSet, multi-tier enhancements, and improved conflict resolution. But the thing I'm most excited about is the addition of XML mapping of elements! I attended a talk on ORM by Sean McCormack at the WI .NET User Group last night. He is an excellent speaker and spoke about DLINQ for a couple minutes, but hated the fact that it didn't have XML mapping. Maybe this will bring him around. :-) It also looks like I'll be speaking at the WI .NET User Group on LINQ in the medium-term future. I'll be sure to post more about that event and more findings with LINQ. In the meantime, download the CTP now.
Wednesday, May 10, 2006 6:51:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
LINQ
 Thursday, March 09, 2006
Here are my notes on hosting remote objects in .NET:

  1. MSDN has a Remoting Example for hosting in IIS. The nice thing about the sample is that it shows how to use the BinaryFormatter for optimized communication over the HTTP channel.
  2. When using the HttpChannel and BinaryFormatter combination, HTTP errors still come back as text. This leads to SerializationException errors on the client. Richard Blewett wrote a custom channel sink to fix the HttpChannel/BinaryFormatter/ASP.NET host bug.
  3. The connectionStrings element in the web.config file is only valid when running ASP.NET 2.0. You can change your virtual directory to use ASP.NET 2.0 by running Internet Information Services, right-clicking on your virtual directory and selecting Properties. Then, go to the ASP.NET tab and select the 2.0 ASP.NET version in the combo box. You can also modify the web.config file here by pressing the Edit Configuration button.
  4. Put the web.config file in the root of the virtual directory, and the assemblies in the bin subdirectory.
  5. If you want to test the remote object, you can't just surf to the URI of the object (e.g. http://localhost/tipnet/MyAppServer.rem). If you do, you'll get a "Requested Service Not Found" error. You need to go to http://localhost/tipnet/MyAppServer.rem?wsdl instead. Be sure you explicitly specified the SdlChannelSink if you use other channel sinks.
  6. Lastly, be careful when defining channel tags in web.config. Don't close XML elements out prematurely. It's easy to do, and hard to spot once you've done it. :-)
Thursday, March 09, 2006 1:00:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -

 Monday, March 06, 2006
Here's an article from MSDN that talks about how to host your .NET Remote objects in an NT Service. Also be sure to check out the information on the ServiceController class to work with NT Services programatically and the ServiceInstaller class. Lastly, this article talks about how to debug and deploy NT Service applications.
Monday, March 06, 2006 10:12:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -

 Friday, March 03, 2006
First things first: I hate that ASP.NET forces you to put all assemblies in a bin subdirectory. To make matters worse, there is no way to change the private probing path in an ASP.NET application. Couple this with the directory structure that VS.NET creates for projects (e.g. MyProject\bin\Debug), and you end up with the fact that you can't simply create a virtual directory that points to the location of your assemblies that were generated by doing a build in VS.NET

I couldn't find anything to easily deploy my project with remote objects and a web.config to an ASP.NET virtual directory. I did see some documentation about Visual WebDeveloper, but I don't have that installed here. Perhaps I didn't install it when I installed VS.NET. Regardless, I really don't want to go back to install this since I'm not creating aspx pages and the like, but I do want to host my remoting objects in IIS (more details on this in a later post).

What I ended up doing was using the post-build Build Event to create events to copy the files over to the IIS directory, e.g.:

copy $(TargetDir)\*.* \inetpub\wwwroot\tipnet\bin
copy $(ProjectDir)\web.config \inetpub\wwwroot\tipnet

At least this way, my IIS files stay in sync with what I just compiled. It might not be the most beautiful thing ever, but it works.

Friday, March 03, 2006 10:05:00 AM (Central Standard Time, UTC-06:00)  #    Comments [2] -

 Thursday, March 02, 2006
Building on my last post on .NET Remoting Sinks, you may notice that when you define a serverProvders block in the config file, you no longer are able to reference the WSDL from your remote object (e.g. http://localhost/tipnet/MyAppServer.rem?wsdl). The reason for this is that when there is no serverProviders block, .NET creates a few default sinks, including the sink that generates WSDL output of your object. However, when you define sinks manually, .NET expects you to explicitly list all of the sinks that you want to use. The WSDL output is generated by the SdlChannelSink class. So to get WSDL back with your custom sinks, simply use a block like this:
<serverProviders>
   <formatter ref="binary" />
   <provider ref="wsdl" />
   <provider type="LoggingSink.ServerSinkLoggerProvider, LoggingSink" />
</serverProviders>

The ref syntax is a shorthand way of referencing the SdlChannelSink class. You could use the full type name by specifying the strong name of the SdlChannelSink class if you wish, but this is much easier.

Thursday, March 02, 2006 8:11:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -

Navigation
Archive
<May 2006>
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
About the author/Disclaimer

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

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 310
This Year: 25
This Month: 1
This Week: 0
Comments: 605
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)