<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Danny Thorpe &#187; .NET</title>
	<atom:link href="http://dannythorpe.com/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>http://dannythorpe.com</link>
	<description>Dream &#38; Deliver</description>
	<lastBuildDate>Tue, 07 Feb 2012 17:50:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Java WS-Policy UsingAddressing Warning When Calling .NET WCF Web Service</title>
		<link>http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/</link>
		<comments>http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 21:19:30 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jax-ws]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[web services]]></category>
		<category><![CDATA[wsdl]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/?p=374</guid>
		<description><![CDATA[Create a Web Service with .NET WCF. Plink, plink, done. Create a simple Java client to call that web service. Using the default Java SE 7u2 SDK + runtime downloadable from Oracle, you run wsimport to import the service WSDL and generate proxy classes. You write a little code to instantiate the service class and <a href='http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Create a Web Service with .NET WCF. Plink, plink, done.</p>
<p>Create a simple Java client to call that web service. Using the default Java SE 7u2 SDK + runtime downloadable from Oracle, you run wsimport to import the service WSDL and generate proxy classes. You write a little code to instantiate the service class and call the service, run the app, and see the output from the successful web service call. Done! Well, not exactly.</p>
<p>When you run the Java client console app, the calls to the web service work but are accompanied by rather nasty sounding warnings about unknown policy requirements.</p>
<pre>Jan 04, 2012 12:10:46 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0075: Policy assertion "{http://www.w3.org/2006/05/addressing/wsdl}UsingAddressing" was evaluated as "UNKNOWN".
Jan 04, 2012 12:10:46 PM [com.sun.xml.internal.ws.policy.EffectiveAlternativeSelector] selectAlternatives
WARNING: WSP0019: Suboptimal policy alternative selected on the client side with fitness "UNKNOWN"</pre>
<p>How do we get rid of those warnings? There are certainly ways to suppress warning reports, but that&#8217;s not the right solution. The better question is how do we resolve the issue reported in the warning?</p>
<p>After a great deal of digging around, here&#8217;s what I&#8217;ve found:</p>
<ol>
<li>WCF defaults to placing a <strong>wsaw:UsingAddressing</strong> WS-Policy assertion in your web service WSDL.<strong></strong></li>
<li><strong>wsaw:UsingAddressing</strong> is not actually part of any SOAP standard, it&#8217;s some sort of WSDL extension to cover the gap until an official SOAP WS-Policy standard could be defined later.</li>
<li>Microsoft WCF supports <strong>wsaw:UsingAddressing</strong>.</li>
<li>Java&#8217;s JAX-WS reference implementation web service core framework (JAX-WS RI 2.2.4-b01) bundled with the JDK does <strong>not</strong> support <strong>wsaw:UsingAddressing</strong>. The rationalization seems to be that wsaw:UsingAddressing isn&#8217;t part of the WS-Policy spec, so &#8220;not our problem&#8221;. JAX-WS RI supports <strong>wsam:Addressing</strong> from the official WS-Policy spec<strong></strong>.</li>
<li>This isn&#8217;t just Java folks thumbing their noses at Microsoft. This also <a href="http://java.net/jira/browse/JAX_WS-852">causes interop problems with Java web service frameworks</a> that support and use <strong>wsaw:UsingAddressing</strong>.</li>
<li><a href="http://metro.java.net/">Java Metro</a> is another web service framework, and one which does support <strong>wsaw:UsingAddressing</strong>. Metro is the result of Sun and Microsoft working together to resolve cross-platform web service interop issues.</li>
<li>Metro is easy enough to download, but how do you use it? Documentation is all about how to install Metro into an application server environment. Many app developers have asked &#8220;<a href="http://metro.1045641.n5.nabble.com/Client-generated-by-wsimport-not-using-WS-Addressing-when-connecting-to-WCF-td1065818.html">How do I use Metro in my Java client?&#8221;</a></li>
</ol>
<p>As it turns out, Metro appears to do all of its magic at runtime. There is no IDE integration at all. All you need to do is reference the Metro .jar files in your Java project and the WS-Policy warnings will go away.</p>
<p>In the NetBeans IDE, this means adding each of the .jar files from the Metro/lib directory to the Libraries node in your Java project. Make sure they appear before the JDK reference. Make sure you select the actual .jar files, not just the Metro/lib directory.</p>
<p>In the IntelliJ IDE, this means:</p>
<ol>
<li>Right click on the JDK node under &#8220;External Libraries&#8221; in the project tree</li>
<li>Click &#8220;Open Library Settings&#8221;</li>
<li>Click &#8220;Libraries&#8221; under &#8220;Project Settings&#8221;</li>
<li>Click the New Project Library tool button</li>
<li>Click &#8220;Java&#8221;</li>
<li>Select the Metro/lib subdir in the &#8220;Select Library Files&#8221; path selector dialog.</li>
</ol>
<p>Note that in NetBeans, you have to select the actual .jar files; selecting only the Metro/lib directory won&#8217;t work in NetBeans.  Selecting only the Metro/lib directory works fine in IntelliJ.</p>
<p>To solve this UsingAddressing policy issue from the Java client end, use the Metro libraries. Period.</p>
<p>Another way to solve this interop issue would be to address the service end: Add <strong>wsam:Addresssing</strong> as an acceptable alternative to <strong>wsaw:UsingAddressing</strong> in the web service&#8217;s WSDL. With both addressing policies as siblings under an <strong>&lt;ExactlyOne&gt;</strong> element, clients that support <strong>wsaw:UsingAddressing</strong> will be happy and clients that support only <strong>wsam:Addressing</strong> will be happy. In theory, anyway.</p>
<p>However, I have yet to figure out how to add <strong>wsam:Addressing</strong> to the WSDL generated by a WCF service. Since I have a client-side solution I won&#8217;t be pursuing this further, but if anyone can provide a link to how to do this on the WCF WSDL side, I&#8217;d love to see that solution as well.</p>
<div style="text-align:center;width:100%;"><div style="margin:0px 0px 0px 0px;"><script type="text/javascript"><!--
google_ad_client = "ca-pub-0861479594738165";
/* End of Post */
google_ad_slot = "6510912161";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/" data-text="Java WS-Policy UsingAddressing Warning When Calling .NET WCF Web Service"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2012%2F01%2F04%2Fjava-wcf-usingaddressing-warning%2F&amp;title=Java%20WS-Policy%20UsingAddressing%20Warning%20When%20Calling%20.NET%20WCF%20Web%20Service" id="wpa2a_4">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2012/01/04/java-wcf-usingaddressing-warning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weird Errors With EF4 CTP5 Code First? Close All Database Connections</title>
		<link>http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/</link>
		<comments>http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 04:51:26 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Code First]]></category>
		<category><![CDATA[CTP5]]></category>
		<category><![CDATA[Entity Framework]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/?p=307</guid>
		<description><![CDATA[I&#8217;ve been exploring the recent CTP5 release of .NET Entity Frameworks 4.0.  I find the advancements in the &#8220;Code First&#8221; model of entity modeling encouraging, though I am a little concerned about discoverability.  If things just magically happen when you name your properties just the right way, how will you know how to diagnose and <a href='http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been exploring the recent CTP5 release of .NET Entity Frameworks 4.0.  I find the advancements in the &#8220;Code First&#8221; model of entity modeling encouraging, though I am a little concerned about discoverability.  If things just magically happen when you name your properties just the right way, how will you know how to diagnose and fix it when the magic smoke leaks out?</p>
<p>(You do know that computers run on smoke, right?  &#8216;Cause if you let the smoke out, the computer don&#8217;t work no more!)</p>
<p>My experiments with Code First took a turn for the worse today as my test app deteriorated from working nicely to failing with murky error messages that seemed to have little to do with the source code changes I just made. How am I supposed to figure this stuff out if they keep rearranging the maze?</p>
<p>I had configured my domain service to always drop the database tables and reset the tables with test data (using DropCreateDatabaseAlways)  whenever the entity model changed. I knew I would be making lots of changes to the model/schema, so might as well just wipe the slate clean every time.</p>
<p>As the strange failures began to mount, I noticed that sometimes after modifying my POCO entity classes (and therefore changing the entity model) running the test app did not hit my breakpoints in the context&#8217;s OnModelCreating or the initializer&#8217;s Seed methods.</p>
<p>To figure out what I had changed to cause all this pain, I started commenting out non-essential parts of the POCO classes, eliminating associations and composite keys and so forth.  The weird failures continued.  The failures weren&#8217;t even consistent &#8211; sometimes the client app would run once just fine and create all the tables it needed, then fail mysteriously with an invalid metadata error on the second run or when the page was refreshed.  Sometimes the first run didn&#8217;t even survive the first web request data query.</p>
<p>By the time I had whittled the POCO classes down to a single class with no inheritance and no associations and still had the client fail, I decided it was time to take a lunch break.  It didn&#8217;t matter what time it was, I needed to put it aside, leave it alone for awhile so I could make a fresh start later.</p>
<p>When I came back from my lunch break there was an error message box on the screen that I hadn&#8217;t seen before.  It said the database could not be dropped because it was in use by another client.  I had left the debugger paused at a breakpoint in the test app and it had trapped this exception some time after I had left my desk.</p>
<p>After a moment of head scratching, I realized the other database client was the Server View in Visual Studio that I was using to inspect the tables created by EF to see how my changes to the POCO entities affected the SQL schema.  Close the database connection in VS, restart the app and poof! Everything worked as it should.  It even worked twice in a row, which at that point was a new record for the day.</p>
<p>What was happening was the domain service in my test app was actually attempting to drop the tables from the database and build everything anew, but Visual Studio&#8217;s open connection to the SQLExpress service was blocking the drop action. Apparently, dropping the tables is a asynchronous action with a very long timeout interval.  The client would make its first request for data, the domain service would receive the request and fire up the DbContext, realize that the model and database needed to be regenerated, and issue the database drop and create operation.</p>
<p>The drop and create didn&#8217;t complete immediately, but apparently other activities proceeded asynchronously and began to fail because the schema found in the database didn&#8217;t match the expected schema.  I would see these bizarre failure error messages while stepping through the domain service code as part of the initial data request.  What I didn&#8217;t see was the root cause &#8211; the drop tables failure &#8211; because it didn&#8217;t fail until long after I had killed the test app and gone back to wondering what I was doing wrong in my source code.</p>
<p>So, simple solution: Always close any open connections in the Server Explorer before running an app that will drop tables.</p>
<h4>This is not the error you&#8217;re looking for</h4>
<p>Another tip for working with Code First Entities:  if you get a compile error about &#8220;You can&#8217;t use this entity in a method of your domain service class because it has not been exposed in your DbContext&#8221;, but you look at your DbContext class and you can see you most certainly have exposed that entity as a DbSet&lt;class&gt; property, here&#8217;s what you do:  Ignore the error message.  It&#8217;s a red herring. Instead, go check that your entity class explicitly designates a property as the primary key, using the [Key] attribute.  Fluid API calls to define a key in OnModelCreate won&#8217;t do &#8211; VS will only be satisfied by a Key attribute.</p>
<p>I don&#8217;t claim to know why, but after a day of permutations and combinations, this is what I found cleared the problem for me.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/" data-text="Weird Errors With EF4 CTP5 Code First? Close All Database Connections"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2011%2F02%2F18%2Fweird-errors-with-ef4-ctp5-code-first-close-all-database-connections%2F&amp;title=Weird%20Errors%20With%20EF4%20CTP5%20Code%20First%3F%20Close%20All%20Database%20Connections" id="wpa2a_8">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2011/02/18/weird-errors-with-ef4-ctp5-code-first-close-all-database-connections/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Silverlight 4 to Include MEF</title>
		<link>http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/</link>
		<comments>http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 20:11:56 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[MEF]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/</guid>
		<description><![CDATA[I just heard the news announced at PDC that the Managed Extensibility Framework, or MEF, is now slated to be included in Silverlight 4.  Great news! I did a bit of proof of concept work using MEF about a year ago.  MEF is all about composition of providers and consumers.  MEF&#8217;s main job is to <a href='http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>I just heard the news announced at PDC that the Managed Extensibility Framework, or <a href="http://blogs.msdn.com/gblock/archive/2009/11/29/mef-has-landed-in-silverlight-4-we-come-in-the-name-of-extensibility.aspx">MEF, is now slated to be included in Silverlight 4</a>.  Great news!</p>
<p>I did a bit of proof of concept work using MEF about a year ago.  MEF is all about composition of providers and consumers.  MEF&#8217;s main job is to connect the providers to the consumers so that when the consumer code executes, the providers they require are &#8220;just there.&#8221;</p>
<p>As trivial as that sounds, it significantly changes how you think about programming.  It forces you to think in terms of composition instead of in terms of plumbing and bushwhacking.  As a result, you can focus more energy on solving your actual problem instead of spending the majority of your time building the plumbing and scaffolding so that you can get to the point where you can begin to solve your problem.</p>
<p>For example, if you&#8217;re writing some code and you require &#8220;X&#8221; to get your work done, you write your MEF code module to declare your need for &#8220;X&#8221;.  When your module is loaded by MEF, MEF will take care of the dirty details of finding a provider to fill your need for &#8220;X&#8221;.  The provider may be the one you had in mind when you wrote the code, or it may be completely different, but as long as it implements &#8220;X&#8221; faithfully, you don&#8217;t really care.  The application defines the list of providers to choose from &#8211; whether a fixed list determined at build time or a list gathered at runtime &#8211; the point is, you and your code don&#8217;t need to deal with the how, just declare the what and keep going.</p>
<p>MEF alters your coding thought process from</p>
<blockquote><p>&#8220;I need to figure out how to load and connect to something to get the X that I need&#8221;</p></blockquote>
<p>to</p>
<blockquote><p>&#8220;I need X.  I can rely on X being here when my code executes.  If for whatever reason X isn&#8217;t available, my code won&#8217;t be loaded so I don&#8217;t have to mess with all that.&#8221;</p></blockquote>
<p>This change in thought process is similar to the shift that can and should occur when you go from writing traditional fire-brigade error handling code to writing code in an exception handling environment. For most of the code in your app (the middle layers), you can operate under the mantra of &#8220;If execution gets this far, then everything prior to this must have succeeded.  If anything back there failed, it would have thrown an exception so I wouldn&#8217;t be here now.&#8221;</p>
<p>I&#8217;ll see if I can get clearance to blog about my little MEF experiment from awhile ago.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/" data-text="Silverlight 4 to Include MEF"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2009%2F11%2F30%2Fsilverlight-4-to-include-mef%2F&amp;title=Silverlight%204%20to%20Include%20MEF" id="wpa2a_12">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2009/11/30/silverlight-4-to-include-mef/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Between EventHandler and EventHandler</title>
		<link>http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/</link>
		<comments>http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 20:36:24 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EventHandler]]></category>
		<category><![CDATA[generics]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/</guid>
		<description><![CDATA[Have you ever run into a situation where you need to bridge between code that uses the old custom EventHandler pattern for events and code that wants to use the new parameterized EventHandler&#60;&#62; code style? EventHandler style delegates are not assignment compatible with EventHandler&#60;&#62; delegates.  You&#8217;ll run into this if you&#8217;re writing a new API <a href='http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Have you ever run into a situation where you need to bridge between code that uses the old custom EventHandler pattern for events and code that wants to use the new parameterized EventHandler&lt;&gt; code style? EventHandler style delegates are not assignment compatible with EventHandler&lt;&gt; delegates.  You&#8217;ll run into this if you&#8217;re writing a new API that sits on top of older code.  You probably want to expose events in your new API using the newer EventHandler&lt;&gt; pattern, but you can&#8217;t easily wire up events from the old lower level code to fire events in your new API.</p>
<p>You could create an event handler method to catch each of the old style events fired by the old code and turn around and fire the corresponding new style event in your API, but who wants to write all that mind numbingly repetitive code?</p>
<p>There is a simpler way.  The two incompatible event patterns do have one thing in common:  the Invoke method.</p>
<p>But first, some background.</p>
<h3>Custom EventHandler Types, 1.0 Style</h3>
<p>In .NET 1.0 the pattern to define an event property was to define an EventArgs class to carry the arguments of your event and define an EventHandler delegate type which uses that EventArgs class as its args parameter.  Like this:</p>
<pre class="brush: csharp; title: ; notranslate">    public class ActivityCompletedEventArgs : EventArgs
    {
        public ActivityCompletedEventArgs(int resultCode, string result)
        {
            ResultCode = resultCode;
            Result = result;
        }

        public int ResultCode { get; private set; }
        public string Result { get; private set; }
    }

    public delegate void ActivityCompletedEventHandler(object sender,
                                                       ActivityCompletedEventArgs e);

    class Bar
    {
        public event ActivityCompletedEventHandler Completed;
    }</pre>
<h3>Generic EventHandler&lt;&gt; Types, 2.0 Style</h3>
<p>With the advent of generic types in .NET 2.0, the generic EventHandler&lt;&gt; parameterized type was born.  This parameterized EventHandler&lt;&gt; delegate type simplifies how you declare and use event handlers &#8211; you don&#8217;t have to declare a custom event handler delegate type to match your event args class every time you create a new kind of event.  This is exactly the kind of thing that parameterized types (aka generics) were created to solve. Like this:</p>
<pre class="brush: csharp; title: ; notranslate">    public class ActivityCompletedEventArgs : EventArgs
    {
        public ActivityCompletedEventArgs(int resultCode, string result)
        {
            ResultCode = resultCode;
            Result = result;
        }

        public int ResultCode { get; private set; }
        public string Result { get; private set; }
    }

    class Bar
    {
        public event EventHandler&amp;lt;ActivityCompletedEventArgs&amp;gt; Completed;
    }</pre>
<p>However, the downside is that EventHandler&lt;&gt; delegates are not assignment compatible with the old style non-generic EventHandler style delegates.</p>
<h3>The Invoke Bridge</h3>
<p>Both styles of event delegate have an Invoke method with a signature of (Object sender, EventArgs args), where EventArgs is the arguments class specific to this particular event.  You can use this point of commonality to convert between event styles without too much trouble.  The trick is to use the .Invoke method in one style of event as the callback method registered in the other style of event:</p>
<pre class="brush: csharp; title: ; notranslate">    class OldStyleClass
    {
        public event ActivityCompletedEventHandler OldStyleEvent;
    }

    class NewStyleClass
    {
        public event EventHandler&amp;lt;ActivityCompletedEventArgs&amp;gt; Completed;

        public void blah()
        {
            var obj = new OldStyleClass();
            obj.OldStyleEvent += new ActivityCompletedEventHandler(Completed.Invoke);
        }
    }</pre>
<p>The code above hooks up the events so that when OldStyleClass.OldStyleEvent fires, it will fire the NewStyleClass.Completed event.</p>
<p>The main catch to this technique (in C#) is that the reference to the event&#8217;s .Invoke method must be made from within the context of the class that defines the event. C# doesn&#8217;t allow access to the members of an event delegate outside of the class that defines the event. The rules may be different in other .NET languages.</p>
<p>If you want to use this technique in the opposite direction (to have a new style event fire an old style event), you will need to be able to modify the source code of the old style class that defines the old style event. This is much less common than making old style code to fire new style events.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/" data-text="Converting Between EventHandler and EventHandler"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2009%2F04%2F15%2Fconverting-between-eventhandler-and-eventhandler%2F&amp;title=Converting%20Between%20EventHandler%20and%20EventHandler" id="wpa2a_16">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2009/04/15/converting-between-eventhandler-and-eventhandler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Moonlight 1.0 Released &#8211; Silverlight for Linux</title>
		<link>http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/</link>
		<comments>http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 19:34:35 +0000</pubDate>
		<dc:creator>Danny Thorpe</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Moonlight]]></category>
		<category><![CDATA[Novell]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/</guid>
		<description><![CDATA[Congratulations to Miguel de Icaza and his team at Novell for the completion and release of Moonlight 1.0!  Moonlight is an open source implementation of Silverlight for the Linux platform developed in a joint effort between Novell and Microsoft. Silverlight was the primary deployment vehicle for live online video coverage of the Olympics last summer, <a href='http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/' class='excerpt-more'>[...]</a>]]></description>
			<content:encoded><![CDATA[<p>Congratulations to <a href="http://tirania.org/blog/archive/2009/Feb-11.html">Miguel de Icaza</a> and his team at Novell for the completion and <a href="http://www.novell.com/news/press/moonlight-shines-on-the-linux-desktop/">release of Moonlight 1.0</a>!  Moonlight is an open source implementation of Silverlight for the Linux platform developed in a joint effort between Novell and Microsoft.</p>
<p>Silverlight was the primary deployment vehicle for live online video coverage of the Olympics last summer, and more recently live video coverage of the Obama inaugeration last month.  Moonlight enables Linux users to view video and applications built for Silverlight on their Linux boxes.</p>
<p>Scott Guthrie has more details <a href="http://weblogs.asp.net/scottgu/archive/2009/02/11/moonlight-1-0-release.aspx">here</a>.</p>
<p><a class="a2a_button_twitter_tweet addtoany_special_service" data-count="none" data-url="http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/" data-text="Moonlight 1.0 Released &#8211; Silverlight for Linux"></a><a class="a2a_button_google_plusone addtoany_special_service" data-annotation="none" data-href="http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/"></a><a class="a2a_button_facebook_like addtoany_special_service" data-href="http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/"></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fdannythorpe.com%2F2009%2F02%2F12%2Fmoonlight-10-released-silverlight-for-linux%2F&amp;title=Moonlight%201.0%20Released%20%E2%80%93%20Silverlight%20for%20Linux" id="wpa2a_20">Share/Bookmark</a></p>]]></content:encoded>
			<wfw:commentRss>http://dannythorpe.com/2009/02/12/moonlight-10-released-silverlight-for-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  dannythorpe.com/tag/net/feed/ ) in 0.49549 seconds, on May 21st, 2012 at 6:12 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 21st, 2012 at 7:12 pm UTC -->
