<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx</link><description>Wow, it’s been a while since I’ve last posted! Don’t worry, I’m still alive and kickin’, and we’re still workin’ on cool stuff for y’all to use. Let’s take a bit of a recap of how far we’ve come. We’ve chatted about dynamic binding in C# and how that</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9845092</link><pubDate>Wed, 22 Jul 2009 21:18:48 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9845092</guid><dc:creator>samng</dc:creator><description>&lt;p&gt;Wow, sorry I haven't been on here to answer anything in a while! Let me start from the top:&lt;/p&gt;
&lt;p&gt;Commongenius:&lt;/p&gt;
&lt;p&gt;&amp;gt; Ultimately, I don't like it, because I know that these &amp;quot;features&amp;quot; won't be confined to the usages for which they were intended, to the detriment of us all. But the world is imperfect, and we have to live in it.&lt;/p&gt;
&lt;p&gt;I entirely agree. Someone else mentioned that it makes C# feel &amp;quot;dirty&amp;quot; - believe me, as the dev who implemented these things, I felt much dirtier. But it was a necessary evil I believe. &lt;/p&gt;
&lt;p&gt;Xenan:&lt;/p&gt;
&lt;p&gt;I don't think thats actually a problem, as much as it is an artifact of software engineering. You cant just move forward from version to version and simply assume you can wipe out any existing legacy concepts from previous versions. This is the nature of software design, and unfortunately is best solved through the language.&lt;/p&gt;
&lt;p&gt;chrimart:&lt;/p&gt;
&lt;p&gt;&amp;gt; If so, does that mean that Extension Properties would be back on the table?&lt;/p&gt;
&lt;p&gt;Not currently. There were several things that took Extension Properties off the table, one of which was the indexed property problem. However, note that with this release, we're providing support for *consuming* indexed properties, not *authoring* them, so nothing would have changed from the extension properties front.&lt;/p&gt;
&lt;p&gt;Richard:&lt;/p&gt;
&lt;p&gt;Great catch, I've changed it from emit to omit. Thanks!&lt;/p&gt;
&lt;p&gt;Pavel:&lt;/p&gt;
&lt;p&gt;Thanks for your help answering questions that folks have! Let me just vouch for your answers and say that you are correct in your understanding of the features. The NoPIA feature (which I'll describe in upcoming posts) embeds only the types and members you use in your code into your compiled assembly, and removes the reference to the PIA. The CLR then does some magic to note that these types are equivalent, and treats them as such at runtime. More on that later :)&lt;/p&gt;
&lt;p&gt;Thanks for your thoughts everyone, keep em coming!&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9845092" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9835622</link><pubDate>Thu, 16 Jul 2009 16:30:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9835622</guid><dc:creator>Xenan</dc:creator><description>&lt;p&gt;The real problem is, of course, that Office is still a COM application whereas it could have been a .NET application from version 2003 on.&lt;/p&gt;
&lt;p&gt;On one hand Microsoft seems to have a strong commitment to .NET but their flagship applications are still COM, which gives me mixed feelings.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9835622" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9816960</link><pubDate>Fri, 03 Jul 2009 21:31:23 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9816960</guid><dc:creator>Pavel Minaev [MSFT]</dc:creator><description>&lt;p&gt;&amp;gt; Dynamic may be &amp;quot;strictly an interop thing&amp;quot; by design, but in practice it can be used anywhere on any object, regardless of its origin. In my opinion this is a serious design flaw that will have long lasting negative consequences.&lt;/p&gt;
&lt;p&gt;What are the alternatives? Unlike the rest of it, &amp;quot;dynamic&amp;quot; is not just for COM - it's also for interop with IronPython and other dynamic friends. And there's no good way to distinguish a &amp;quot;scripting&amp;quot; object from a non-scripting one - and, from multi-language .NET perspective - there really shouldn't be.&lt;/p&gt;
&lt;p&gt;There's one more thing to consider. Let's consider IronPython interop again. Say you use &amp;quot;dynamic&amp;quot; to call a method on IPy object, and that returns you yet another object. Now you don't know what is returned - it may be another IPy object, but it also may be a C# (or other static language) object that IPy code obtained from elsewhere - and there's no reason why you should. But you have to have some common way to work with that object, and that means that &amp;quot;dynamic&amp;quot; has to work regardless of what the object is implemented in.&lt;/p&gt;
&lt;p&gt;In my opinion, it's alright. A major compromise would be if C# allowed you to define truly dynamic &amp;quot;expando&amp;quot; objects (easily), but that is not the case.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9816960" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9816959</link><pubDate>Fri, 03 Jul 2009 21:27:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9816959</guid><dc:creator>Pavel Minaev [MSFT]</dc:creator><description>&lt;p&gt;&amp;gt; How can there be no PIA deployment? Who will do the interop?&lt;/p&gt;
&lt;p&gt;If you've actually looked at what's in PIA assemblies, you'll see that there's no real code there - just interface declarations (and structs, where they apply). The framework itself does the interop.&lt;/p&gt;
&lt;p&gt;What NoPIA means, effectively, is that you no longer need those PIA assemblies with interfaces. They get embedded directly into assemblies that use COM objects, and CLR ensures that such embedded types in different assemblies, even though technically distinct from CLR point of view, are compatible and can be substituted one for another when they actually correspond to the same COM interface/struct/etc.&lt;/p&gt;
&lt;p&gt;Simply put, it's a form of structural typing specifically for COM interop artefacts.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9816959" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9816863</link><pubDate>Fri, 03 Jul 2009 19:03:20 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9816863</guid><dc:creator>Tom Kirby-Green</dc:creator><description>&lt;p&gt;What about interop'ing with 'pre VB generation' COM that returns S_OK or E_FAIL as logical booleans (i.e. soft rather than hard failure indicators). Then of course there's the S_FALSE problem.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9816863" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9816805</link><pubDate>Fri, 03 Jul 2009 17:26:59 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9816805</guid><dc:creator>richard_deeming</dc:creator><description>&lt;p&gt;It's a shame that this is required - it makes C# feel so &amp;quot;dirty&amp;quot; - but I can see why it's needed. It may have been possible to create .NET-friendly wrappers for the Office PI(T)A, but versioning would probably be a nightmare, and it wouldn't help with third-party COM libraries.&lt;/p&gt;
&lt;p&gt;&amp;quot;the parameters are optional, indicating that you can emit them&amp;quot;&lt;/p&gt;
&lt;p&gt;Shouldn't that be, &amp;quot;you can *omit* them&amp;quot;?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9816805" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9811961</link><pubDate>Thu, 02 Jul 2009 00:19:14 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9811961</guid><dc:creator>Chris.Martinez.77</dc:creator><description>&lt;p&gt;Based on your statement, is it fair to say that C# 4.0 will have intrinsic support for indexed properties? &amp;nbsp;If so, does that mean that Extension Properties would be back on the table?&lt;/p&gt;
&lt;p&gt;As I understand it, the primary reason that Extension Properties are vetoed is because C# would have to support indexed properties and, as you've stated, the C# team thinks that is ill advised.&lt;/p&gt;
&lt;p&gt;Extension Properties could be immensely useful and should have the same effective run-time capabilities as Extension Methods, since properties are ultimately a facade for get_xxx/set_xxx methods.&lt;/p&gt;
&lt;p&gt;Working with the Silverlight BCL has proven to have great need for Extension Properties in order to duct tape types that are missing capabilities commonly found in the Windows-based BCL. &amp;nbsp;For example, System.Threading.Thread.CurrentPrincipal was omitted.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9811961" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9809710</link><pubDate>Tue, 30 Jun 2009 17:51:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9809710</guid><dc:creator>David A Nelson</dc:creator><description>&lt;p&gt;@pminaev&lt;/p&gt;
&lt;p&gt;Dynamic may be &amp;quot;strictly an interop thing&amp;quot; by design, but in practice it can be used anywhere on any object, regardless of its origin. In my opinion this is a serious design flaw that will have long lasting negative consequences.&lt;/p&gt;
&lt;p&gt;However, it does appear that these changes designed for COM interop will only apply to COM objects, so the negative impact will be limited.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9809710" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9808809</link><pubDate>Mon, 29 Jun 2009 21:28:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9808809</guid><dc:creator>Pavel Minaev [MSFT]</dc:creator><description>&lt;p&gt;&amp;gt; Ultimately, I don't like it, because I know that these &amp;quot;features&amp;quot; won't be confined to the usages for which they were intended, to the detriment of us all. &lt;/p&gt;
&lt;p&gt;The good thing about all these changes is that they _only apply to COM objects_! I.e., to interfaces and classes with ComImportAttribute. So it isn't a major compromise - you still can't pass values to ref-arguments on POCOs, or declared named indexed properties, etc. It's strictly an interop thing, much like dynamic.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9808809" width="1" height="1"&gt;</description></item><item><title>re: COM Interop in C# 4.0</title><link>http://blogs.msdn.com/b/samng/archive/2009/06/16/com-interop-in-c-4-0.aspx#9770856</link><pubDate>Thu, 18 Jun 2009 01:40:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9770856</guid><dc:creator>David A Nelson</dc:creator><description>&lt;p&gt;I wish - I REALLY wish - that C# could stick to its design principles and not compromise for the sake of interoperating with languages and platforms that (IMHO) have made poor design choices.&lt;/p&gt;
&lt;p&gt;However, I am forced to agree that COM isn't going away (as much as I wish it would), and many people still have to interoperate with it (as much as they probably wish they didn't). The only other thing I might consider is pushing these &amp;quot;features&amp;quot; into a secondary layer of the language that would have to be explicitly enabled (a la &amp;quot;Allow unsafe code&amp;quot;). But I can understand why that would be considered too extreme for this case (although I would be interested in knowing if something like that were even considered).&lt;/p&gt;
&lt;p&gt;Ultimately, I don't like it, because I know that these &amp;quot;features&amp;quot; won't be confined to the usages for which they were intended, to the detriment of us all. But the world is imperfect, and we have to live in it.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9770856" width="1" height="1"&gt;</description></item></channel></rss>