<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-19252938</id><updated>2011-11-24T17:46:42.089-05:00</updated><category term='COM Interop'/><category term='green'/><category term='mono'/><category term='personal'/><category term='Test'/><title type='text'>Jonathan Chambers Web Log</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>16</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-19252938.post-3584724810912799998</id><published>2011-02-22T22:45:00.013-05:00</published><updated>2011-02-22T23:51:26.013-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Profiling Mono with AMD CodeAnalyst</title><content type='html'>&lt;div style="text-align: center;"&gt;A coworker wanted to profile his app on mono the other day. While&lt;a href="http://www.mono-project.com/Profiler"&gt; the profiler was rewritten for 2.10&lt;/a&gt; and is now greatly improved, there are a still a few issues. One is that we are not currently using 2.10 yet for our projects. Another issue is that there is no GUI to view results from the profiler.We frequently use tools like Intel VTune and AMD CodeAnalyst to profile C++ and C# at work. I knew VTune added an API to support profiling JIT'd code. Mono has a &lt;a href="http://www.mono-project.com/Performance_Tips#Profiling"&gt;profiling API&lt;/a&gt; that allows custom profilers to be loaded by the runtime.  I started coding a mono profiler for VTune a few months ago. I hit a few issues, and shelved the code.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After downloading &lt;a href="http://developer.amd.com/cpu/codeanalyst/Pages/default.aspx"&gt;AMD CodeAnalyst&lt;/a&gt; (it's free) and looking through the API headers, I found a similar API for JIT'd code support. A quick hour of hacking and the profiler was working. So, how can you use it? The profiler only is setup for usage on Windows right now, so I'll assume we are working in a Windows development environment.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Download &lt;a href="http://developer.amd.com/cpu/codeanalyst/Pages/default.aspx"&gt;AMD CodeAnalyst&lt;/a&gt;.&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Grab fresh &lt;a href="https://github.com/mono/mono"&gt;mono from GitHub&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Open mono\msvc\mono.sln in VS2010. Build target of choice.&lt;/div&gt;&lt;img src="http://4.bp.blogspot.com/-14KrikmLWCQ/TWSROlgzIrI/AAAAAAAAAiA/w9oDUSaaMgQ/s400/visual_studio.png" style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 238px; height: 400px;" border="0" alt="" id="BLOGGER_PHOTO_ID_5576741918365393586" /&gt;&lt;div&gt;At this point, you'll need a mono install to match the runtime. There's &lt;a href="http://www.mono-project.com/Compiling_Mono_on_Windows"&gt;no easy way to build a mono install&lt;/a&gt; on Windows currently. There is work ongoing for this, but it's not quite ready yet. You'll either have to bite the cygwin bullet or wait for the next mono release that you can build a mono runtime in sync with.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Once you have an install up an running, copy the mono-profiler-codeanalyst.dll into the bin directory in the install.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Create a simple test case.&lt;/div&gt;&lt;div&gt;&lt;a href="http://3.bp.blogspot.com/-SZue937oKF0/TWSROoGubDI/AAAAAAAAAiI/3ovi6tolUaA/s1600/source.png"&gt;&lt;img src="http://3.bp.blogspot.com/-SZue937oKF0/TWSROoGubDI/AAAAAAAAAiI/3ovi6tolUaA/s400/source.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5576741919061339186" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 373px; " /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Start CodeAnalyst and launch the Session settings dialog.&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); -webkit-text-decorations-in-effect: underline; "&gt;&lt;img src="http://2.bp.blogspot.com/-ZQXndzvgB-4/TWSRO95cL_I/AAAAAAAAAiQ/X0YnPCh67F4/s400/codeanalyst_settings.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5576741924911198194" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 400px; height: 237px; " /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Pass --profile=codeanalyst along with your normal mono flags.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;After running, you should get a results pane. Note the JITCode item taking up the most time samples. Also note mono-2.0.dll coming in third. That's the mono runtime itself. Note you can mix profiling managed and native code within the same application.&lt;/div&gt;&lt;div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-jtY-iEGkpcs/TWSOUuuIgOI/AAAAAAAAAhw/ctnzNGK3D60/s1600/results_pane.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 190px;" src="http://1.bp.blogspot.com/-jtY-iEGkpcs/TWSOUuuIgOI/AAAAAAAAAhw/ctnzNGK3D60/s320/results_pane.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5576738725381570786" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;Double click on JITCode and we can see the hits for the individual methods. This includes both our code, and the mono class libraries.&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/-vqtTya1Lgb4/TWSO8QCl7wI/AAAAAAAAAh4/C-BiWZtvCK0/s1600/jit_results.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 190px;" src="http://1.bp.blogspot.com/-vqtTya1Lgb4/TWSO8QCl7wI/AAAAAAAAAh4/C-BiWZtvCK0/s320/jit_results.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5576739404340653826" /&gt;&lt;/a&gt;&lt;div&gt;These results make sense, given our test case. The most interesting thing is that a non-trivial amount of time is spent in an internal method System.String.memcpy4. This is probably due to our inefficient string concatenation within a loop.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The CodeAnalyst JIT API is somewhat limited. It doesn't allow the specification of source files or line numbers. The API itself does not seem to be currently documented, or perhaps even supported. The Intel VTune API is much richer, but VTune is not free. I'll try to put together a VTune profiler, and do another post with a more interesting sample. I'm also considering producing binaries of the profiler compatible with the recent mono 2.10 release that can be dropped in an used, avoiding the issue of building a full mono install on windows.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-3584724810912799998?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/3584724810912799998/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=3584724810912799998' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/3584724810912799998'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/3584724810912799998'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2011/02/profiling-mono-with-amd-codeanalyst.html' title='Profiling Mono with AMD CodeAnalyst'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/-14KrikmLWCQ/TWSROlgzIrI/AAAAAAAAAiA/w9oDUSaaMgQ/s72-c/visual_studio.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-5718377327291392345</id><published>2009-11-13T23:30:00.001-05:00</published><updated>2009-11-13T14:11:12.111-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Mono Debugger on Windows</title><content type='html'>&lt;div&gt;I need to cleanup the changes a bit more, but here's a preview.&lt;/div&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_NBfoEkQJSSs/Svjs0gpUGnI/AAAAAAAAAXI/J-MG2nQCQYY/s1600-h/MonoDebugging.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 241px;" src="http://1.bp.blogspot.com/_NBfoEkQJSSs/Svjs0gpUGnI/AAAAAAAAAXI/J-MG2nQCQYY/s400/MonoDebugging.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5402328139891481202" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div&gt;&lt;b&gt;Update&lt;/b&gt;: Code is now checked into svn.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-5718377327291392345?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/5718377327291392345/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=5718377327291392345' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5718377327291392345'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5718377327291392345'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2009/11/mono-debugger-on-windows.html' title='Mono Debugger on Windows'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_NBfoEkQJSSs/Svjs0gpUGnI/AAAAAAAAAXI/J-MG2nQCQYY/s72-c/MonoDebugging.png' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-4485410070393337384</id><published>2009-04-03T12:44:00.004-04:00</published><updated>2009-04-04T00:05:31.887-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>ANSYS and Intel</title><content type='html'>I consider my job at ANSYS quite exciting. I get to work on some amazing software with great people. We get to push the limits of engineering simulation and computer technology. In case you've ever wondered what our software does, here's a video shot by Intel showing how we leverage their latest hardware.&lt;br /&gt;&lt;br /&gt;&lt;object width="480" height="295"&gt;&lt;param name="movie" value="http://www.youtube.com/v/2iHUOlV7q6g&amp;amp;hl=en&amp;amp;fs=1"&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;embed src="http://www.youtube.com/v/2iHUOlV7q6g&amp;amp;hl=en&amp;amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="295"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-4485410070393337384?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/4485410070393337384/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=4485410070393337384' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/4485410070393337384'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/4485410070393337384'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2009/04/ansys-and-intel.html' title='ANSYS and Intel'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-7621899280065091978</id><published>2009-04-01T21:17:00.004-04:00</published><updated>2009-04-02T07:41:18.517-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='personal'/><title type='text'>Why did I go to Best Buy?</title><content type='html'>The rumors are true. Best Buy sucks.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I went to Best Buy today to look at new laptops. I wasn't really planning on buying one at Best Buy due to the &lt;a href="http://ihatebestbuy.com/"&gt;wonderful reputation&lt;/a&gt; they have. After looking a few minutes I find a nice Dell XPS 1530 that s being discontinued for $739. I know this is a good deal as I had configured a similar laptop at dell.com a few days ago for almost $1400. A supervisor stops by and asks if I need help. I respond I'm interested in the laptop. I then ask if price is open box, floor model, etc. He laughs and assures me I'll get a new laptop in a box. I want to see some more specs. He takes me to a kiosk and punches in the SKU. It brings up a screen similar to &lt;a href="http://www.bestbuy.com/site/olspage.jsp?skuId=8989124&amp;amp;type=product&amp;amp;id=1218006773367"&gt;this&lt;/a&gt;, and I notice two things:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. The price is $1059 instead of $739.&lt;/div&gt;&lt;div&gt;2. Big red text at top of window says "Item out of stock at store."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Supervisor notices #1 and says, "Hmm, the price is more online. That's odd since they should be the same. Oh well, we price match anyway." Supervisor then walks away.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Five minutes pass. Salesman stops by.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Do you need any help?"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"I'll take the laptop."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"We don't have any in stock. And I can't give you floor model since we don't have a power cable for it."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Okay. Can you check another store?"&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Sure. I'll be right back."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;...&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"The Erie, PA store (over 3 hours away) has 7 left at same price. &lt;span class="Apple-style-span" style="font-weight: bold;"&gt;But, they won't send us any for two weeks since the are doing inventory. &lt;/span&gt;Sorry I can't help you."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, I leave and figure I'll buy laptop online. But wait, online price is ~$300 higher. I call online customer service and describe situation.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;"&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Sir, stores have more leeway than we do for pricing. We cannot match the store's prices online&lt;/span&gt;. How much cheaper was it in the store?"&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;"$300 cheaper."&lt;/div&gt;&lt;div style="text-align: left;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: left;"&gt;"&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Man, that's a great deal. Sorry I can't help you&lt;/span&gt;."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I now begin ranting at work. A guy next to me mentions his sister lives in Erie, and is coming home this weekend. She could pickup the laptop for me. Great. I call Erie store to buy laptop over phone. I start explaining whole situation again.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"So, I'd like to buy laptop and have somone pick it up for me."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"I am sorry sir. To pickup laptop, whoever purchases the laptop needs to come to the store and show ID and credit card. Sorry I cannot help you."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Grrr. I am now mad enough to call corporate customer service and explain situation to them.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Hmm. Wow. Hmm. It doesn't sound like there's a whole lot I can do."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"So, this laptop is available 3 hours from me and also online. But, in order to get one I need to drive over 6 hours roundtrip or pay an extra $300."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Yes, well. I guess I could call the store for you and talk to them."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"They explicitly told me they needed ID and credit card for pickup."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"Hmm. Well, the ball seems to be in your court sir as to what you want me to do."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;"It sounds like you can't do much."&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Best Buy has lost another customer for life. &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I dedicate this post to the &lt;a href="http://primates.ximian.com/~jackson/blog/archive2006/Aug-21.html"&gt;blog post that inspired me to take time and describe my experience&lt;/a&gt;.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-7621899280065091978?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/7621899280065091978/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=7621899280065091978' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/7621899280065091978'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/7621899280065091978'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2009/04/best-buy-sucks.html' title='Why did I go to Best Buy?'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-5789245259281432924</id><published>2008-10-30T08:00:00.000-04:00</published><updated>2009-04-01T22:36:35.555-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Biggest Flaw in .Net...Fixed?</title><content type='html'>OK, so maybe I am biased about the default security settings for managed code on a network share being the biggest flaw in .Net. However, it has to be one of the most aggravating ones (especially when considering deployment options). I never understood how allowing unmanaged code to run on a network share, but not managed code by default was security.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Quoting &lt;a href="http://blogs.msdn.com/vancem/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx"&gt;Vance Morrison&lt;/a&gt;:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:verdana;"&gt;&lt;span class="Apple-style-span"  style="font-size:x-small;"&gt;The problem is that failing to run managed code WHILE STILL ALLOWING UNMANAGED EXE's to run, does not provide any security (because hackers will simply use unmanaged code) but does cause nontrivial deployment headaches (manage apps can't be run from network locations). &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt; Anyway, it's now &lt;a href="http://blogs.msdn.com/brada/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx"&gt;fixed&lt;/a&gt;!!! &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AB99342F-5D1A-413D-8319-81DA479AB0D7&amp;amp;displaylang=en"&gt;Just grab .Net 3.5 SP1.&lt;/a&gt; Thanks to MS (and Vance) for making this change.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-5789245259281432924?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/5789245259281432924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=5789245259281432924' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5789245259281432924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5789245259281432924'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2008/10/biggest-flaw-in-netfixed.html' title='Biggest Flaw in .Net...Fixed?'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-6413193238433349122</id><published>2008-05-22T15:40:00.002-04:00</published><updated>2009-04-01T22:33:49.454-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='COM Interop'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>SIL, mono, and COM on Linux</title><content type='html'>A developer named &lt;a href="http://linux.lsdev.sil.org/blog/?author=8"&gt;Mark Strobert&lt;/a&gt; contacted me a while back about the feasibility of using &lt;a href="http://www.mono-project.com/Main_Page"&gt;mono &lt;/a&gt;and it's &lt;a href="http://www.mono-project.com/COM_Interop"&gt;COM Interop &lt;/a&gt;implementation to port Windows software written using C# and COM. I told him it should be possible, and we discussed one of the main problems being the lack of a COM infrastructure on Linux. I hadn't heard from him again for a while until...&lt;br /&gt;&lt;br /&gt;he emailed and informed me that they were open sourcing their &lt;a href="http://linux.lsdev.sil.org/blog/?p=44"&gt;basic COM implementation, a.k.a. libcom&lt;/a&gt;. In looking over their blog/wiki, it seems as if the use of mono's COM Interop and their libcom is holding together fairly well. I won't say this is the first real world test of COM Interop in mono, as &lt;a href="http://worldofcoding.blogspot.com/"&gt;Shana&lt;/a&gt; has used it quite well to implement the System.Windows.Forms WebBrowser control. However, the fact that mono's COM Interop implementation is being used by others is exciting to me (if anyone is keeping their mono COM Interop use in the closet, drop me a line to let me in on the secret).&lt;br /&gt;&lt;br /&gt;The developers are using mono to port and develop software in order to support a &lt;a href="http://www.sil.org/sil/"&gt;faith based organization&lt;/a&gt; that is involved in literacy, linguistics, and translation. I won't go on any further, because if you're interested you can click around their &lt;a href="http://www.sil.org/sil/"&gt;site&lt;/a&gt; (or &lt;a href="http://linux.lsdev.sil.org/"&gt;Linux development site&lt;/a&gt;) to see better information than I could explain here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-6413193238433349122?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/6413193238433349122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=6413193238433349122' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/6413193238433349122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/6413193238433349122'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2008/05/sil-mono-and-com-on-linux.html' title='SIL, mono, and COM on Linux'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-6356481407451728351</id><published>2007-10-30T10:35:00.001-04:00</published><updated>2007-10-30T10:35:37.063-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Test'/><title type='text'>Test</title><content type='html'>This is only a test...&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-6356481407451728351?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/6356481407451728351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=6356481407451728351' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/6356481407451728351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/6356481407451728351'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2007/10/test.html' title='Test'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-5558414848040827239</id><published>2007-08-07T08:09:00.000-04:00</published><updated>2009-04-01T22:36:35.556-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Mono.XPCOM</title><content type='html'>With a little prodding from &lt;a href="http://tirania.org/blog/index.html"&gt;Miguel&lt;/a&gt;, I finally spent some time trying to play around with &lt;a href="http://www.mono-project.com/"&gt;mono's&lt;/a&gt; &lt;a href="http://www.mono-project.com/COM_Interop"&gt;COM Interop&lt;/a&gt; support and &lt;a href="http://www.mozilla.org/projects/xpcom/"&gt;XPCOM&lt;/a&gt;. The important thing to note is that COM Interop in mono should (and does) work with XPCOM. Most of my troubles have been due to a lack of XPCOM knowledge, not any technical issues with COM Interop. I haven't worked out all the issues, but below is a little test case I am working on. (side note: there is a serious lack of decent, standalone XPCOM samples/tutorials available on the web IMO)&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; XPCOMTester&lt;br /&gt;{&lt;br /&gt;[STAThread]&lt;br /&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;int&lt;/span&gt; Main (&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args) {&lt;br /&gt;   &lt;span class="kwrd"&gt;int&lt;/span&gt; hr = NativeMethods.XPCOMGlueStartup (IntPtr.Zero);&lt;br /&gt;   nsIServiceManager sm;&lt;br /&gt;   hr = NativeMethods.NS_InitXPCOM2 (&lt;span class="kwrd"&gt;out&lt;/span&gt; sm, IntPtr.Zero, IntPtr.Zero);&lt;br /&gt;&lt;br /&gt;   nsIComponentRegistrar cr = (nsIComponentRegistrar)sm;&lt;br /&gt;&lt;br /&gt;   cr.autoRegister(IntPtr.Zero);&lt;br /&gt;&lt;br /&gt;   Guid kEventQueueServiceCID = &lt;span class="kwrd"&gt;new&lt;/span&gt; Guid(&lt;span class="str"&gt;"be761f00-a3b0-11d2-996c-0080c7cb1080"&lt;/span&gt;);&lt;br /&gt;   IntPtr ptr;&lt;br /&gt;   sm.getService(kEventQueueServiceCID, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(nsIEventQueueService).GUID, &lt;span class="kwrd"&gt;out&lt;/span&gt; ptr);&lt;br /&gt;&lt;br /&gt;   nsIEventQueueService eqs = (nsIEventQueueService)Marshal.GetObjectForIUnknown(ptr);&lt;br /&gt;   eqs.CreateThreadEventQueue();&lt;br /&gt;&lt;br /&gt;   nsIEventQueue eq = eqs.GetThreadEventQueue(IntPtr.Zero);&lt;br /&gt;&lt;br /&gt;   Guid IPC_SERVICE_CID = &lt;span class="kwrd"&gt;new&lt;/span&gt; Guid(&lt;span class="str"&gt;"9f12676a-5168-4a08-beb8-edf8a593a1ca"&lt;/span&gt;);&lt;br /&gt;   sm.getService(IPC_SERVICE_CID, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(ipcIService).GUID, &lt;span class="kwrd"&gt;out&lt;/span&gt; ptr);&lt;br /&gt;   &lt;span class="rem"&gt;// or&lt;/span&gt;&lt;br /&gt;   &lt;span class="rem"&gt;// sm.getServiceByContractID("@mozilla.org/ipc/service;1", typeof(ipcIService).GUID, out ptr);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   &lt;span class="rem"&gt;// Do more XPCOM stuff here&lt;/span&gt;&lt;br /&gt;   &lt;span class="rem"&gt;// &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   NativeMethods.NS_ShutdownXPCOM(sm);&lt;br /&gt;   NativeMethods.XPCOMGlueShutdown();&lt;br /&gt;   &lt;span class="kwrd"&gt;return&lt;/span&gt; 0;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Interfaces are defined as follows (taking nsIServiceManager as an example):&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;[Guid(&lt;span class="str"&gt;"8bb35ed9-e332-462d-9155-4a002ab5c958"&lt;/span&gt;)]&lt;br /&gt;[InterfaceType (ComInterfaceType.InterfaceIsIUnknown)]&lt;br /&gt;[ComImport()]&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; nsIServiceManager&lt;br /&gt;{&lt;br /&gt;  [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]&lt;br /&gt;  [PreserveSigAttribute]&lt;br /&gt;  &lt;span class="kwrd"&gt;void&lt;/span&gt; getService ([MarshalAs (UnmanagedType.LPStruct)] Guid clsid,&lt;br /&gt;     [MarshalAs (UnmanagedType.LPStruct)] Guid iid,&lt;br /&gt;     &lt;span class="kwrd"&gt;out&lt;/span&gt; IntPtr result);&lt;br /&gt;&lt;br /&gt;  [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]&lt;br /&gt;  [PreserveSigAttribute]&lt;br /&gt;  &lt;span class="kwrd"&gt;void&lt;/span&gt; getServiceByContractID ([MarshalAs (UnmanagedType.LPStr)] &lt;span class="kwrd"&gt;string&lt;/span&gt; contractID,&lt;br /&gt;  [MarshalAs (UnmanagedType.LPStruct)] Guid iid,&lt;br /&gt;  &lt;span class="kwrd"&gt;out&lt;/span&gt; IntPtr result);&lt;br /&gt;&lt;br /&gt;  [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]&lt;br /&gt;  [PreserveSigAttribute]&lt;br /&gt;  PRBool isServiceInstantiated ([MarshalAs (UnmanagedType.LPStruct)] Guid clsid,&lt;br /&gt;  [MarshalAs (UnmanagedType.LPStruct)] Guid iid);&lt;br /&gt;&lt;br /&gt;  [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]&lt;br /&gt;  [PreserveSigAttribute]&lt;br /&gt;  PRBool isServiceInstantiatedByContractID ([MarshalAs (UnmanagedType.LPStr)] &lt;span class="kwrd"&gt;string&lt;/span&gt; contractID,&lt;br /&gt;  [MarshalAs (UnmanagedType.LPStruct)] Guid iid);&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The above samples does have one problem at this point; the all to GetThreadEventQueue fails with a class not registered error. Again, I think this is my XPCOM ignorance I am fighting. If anyone actually has any interest in using mono and XPCOM, or has any advice, please send it my way.&lt;br /&gt;&lt;br /&gt;Also, I have started working on a Mono.XPCOM interop library that would contain definitions of standard XPCOM interfaces like the ones used above. Any advice as to where to put this code (&lt;a href="http://code.google.com/hosting/"&gt;google&lt;/a&gt;)?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-5558414848040827239?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/5558414848040827239/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=5558414848040827239' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5558414848040827239'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5558414848040827239'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2007/08/monoxpcom.html' title='Mono.XPCOM'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-5696157995872762784</id><published>2007-02-26T12:22:00.000-05:00</published><updated>2007-02-26T13:00:41.005-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='COM Interop'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Three COM Interop Updates</title><content type='html'>COM Callable Wrappers&lt;br /&gt;&lt;br /&gt;First, COM Callable Wrapper support is now in svn. This means that managed objects can be passed to C++ and interacted with as if they were unmanaged COM objects. It still needs some more work, but most basic use of this functionality should work.&lt;br /&gt;&lt;br /&gt;User Base Doubles&lt;br /&gt;&lt;br /&gt;Previously, I seemed to be the only person interested in using COM Interop, especially on Linux. However, I had an exchange with someone on IRC last week who is trying to port their C#/C++ COM application from Windows to Linux. They are investigating using COM Interop instead of having to write a C wrapper layer with pinvokes.&lt;br /&gt;&lt;br /&gt;Mozilla/XPCOM&lt;br /&gt;&lt;br /&gt;Theoretically, the COM Interop functionality should work with Mozilla/XPCOM or any COM like system at least on Windows and Linux on x86 and x86-64 architectures (COM Interop depends on the binary layout of vtables). I always planned on trying COM Interop on XPCOM but never had the time. This weekend I took an hour or so and tried to hack something together. Since &lt;a href="http://www.monodevelop.com"&gt;Monodevelop&lt;/a&gt; has an &lt;a href="http://www.mono-project.com/AspNetEdit"&gt;ASP.Net designer&lt;/a&gt; that uses Mozilla and one of the future goals is &lt;a href="http://www.mono-project.com/AspNetEdit#Plans"&gt;better DOM access&lt;/a&gt;, I decided to hack something together inside of the editor.&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-weight: bold;"&gt;good news&lt;/span&gt; is that&lt;span style="font-style: italic;"&gt; it works&lt;/span&gt;! I can traverse/access the DOM without any glue/wrapper library. I just need to define some interfaces in C# and get a pointer to the DOM. The &lt;span style="font-weight: bold;"&gt;bad news&lt;/span&gt; is that strings in Mozilla/XPCOM really stink. I couldn't figure out how to marshal the strings correctly, thus making the exercise less than complete. If anyone knows what a DOMString is, please post a comment. If it ends up being a fairly simple type it can be marshalled that would be great, however if it's just a C++ class (as I currently fear) some unmanaged glue code will be needed to convert the string to something usable by the marshaller.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-5696157995872762784?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/5696157995872762784/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=5696157995872762784' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5696157995872762784'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/5696157995872762784'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2007/02/three-com-interop-updates.html' title='Three COM Interop Updates'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-731601431611703930</id><published>2007-01-08T08:40:00.001-05:00</published><updated>2007-01-08T08:42:03.416-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='green'/><title type='text'>The electric car resurrection</title><content type='html'>The electric car has been back for awhile, but &lt;a href="http://www.teslamotors.com/"&gt;not in a form for mere mortals&lt;/a&gt;. I don't think most mortals could handle 0-60  in 4 seconds anyway.&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.teslamotors.com/"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://www.teslamotors.com/images/content/wallpaper_front3-4_view.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;However, it looks like mortals &lt;a href="http://www.earthtimes.org/articles/show/18335.html"&gt;may get their shot&lt;/a&gt;. 40 miles on a charge (with a gasoline backup) means I could use it for traveling to/from work everyday without burning any gasoline. Let's see if GM can deliver and make it affordable to the middle class.&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.earthtimes.org/articles/show/18335.html"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px;" src="http://msnbcmedia4.msn.com/j/msnbc/Components/Photos/070106/070106_chevrolet_volt_hmed7p.hmedium.jpg" alt="" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="text-decoration: underline;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-731601431611703930?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/731601431611703930/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=731601431611703930' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/731601431611703930'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/731601431611703930'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2007/01/charge-it-up.html' title='The electric car resurrection'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-115412252632073064</id><published>2006-12-11T00:05:00.000-05:00</published><updated>2009-04-01T22:36:35.556-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='COM Interop'/><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>COM Interop - COM Callable Wrappers</title><content type='html'>Support for Runtime Callable Wrappers (RCWs) has been in mono for a &lt;a href="http://jonathanchambers.blogspot.com/2006/07/com-interop-in-svn.html"&gt;few months now&lt;/a&gt;. Support for COM Callable Wrappers (CCWs) is well underway. I have a patch pending, and am cleaning up some issues with it right now. CCWs basically allow you to safely expose managed objects to unmanaged code as COM objects.&lt;br /&gt;&lt;br /&gt;I have to say the mono runtime is some cool code to hack around in; I also have to say thanks to the runtime hackers who continually help me out. Most of my time is spent translating the rules of a COM environment to the rules of the managed runtime. Essentially all of the technical functionality I need (getting a function pointer for a managed method, parameter marshalling, etc.) is already there. All I've had to do is implement some COM specific stuff in the runtime, and always remember to adhere to COM rules (AddRef the pointer returned from a QueryInterface call) and runtime rules when needed (don't hold onto an object pointer directly as that will cause big problems with the &lt;a href="http://www.mono-project.com/Compacting_GC"&gt;new moving garbage collector&lt;/a&gt;).&lt;br /&gt;&lt;br /&gt;So what's left to do? Once the CCW patch gets in, not much from my point of view. I don't have support for IDispatch complete yet for either CCWs or RCWs, so that will get some attention. Beyond that it's bugs, performance, and what anyone requests (assuming someone will use this). And who would use this? I can think of a few cases:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;This may be a good way to interact with Mozilla/XPCOM components from mono. I haven't tried this yet as my skills at getting a working Mozilla build/development setup are not very good. My goal is either to get the System.Windows.Forms WebBrowser control working, or try to get the &lt;a href="http://www.mono-project.com/AspNetEdit"&gt;ASP.Net Designer&lt;/a&gt; to work using COM Interop to communicate with Mozilla.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;This may also be a good way to interact with Open Office. I think this has less potential than XPCOM, but I'm not ruling anything out yet.&lt;/li&gt;&lt;li&gt;In general, it seems to be an ok way to wrap a C++ library if you don't want to use a C API created either manually or using one of the various tools available.&lt;/li&gt;&lt;/ol&gt;If anyone can think of other cool applications for COM Interop, or has suggestions let me know.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-115412252632073064?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/115412252632073064/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=115412252632073064' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/115412252632073064'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/115412252632073064'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2006/07/com-interop.html' title='COM Interop - COM Callable Wrappers'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-115296971473441597</id><published>2006-07-15T08:41:00.000-04:00</published><updated>2009-04-01T22:36:35.556-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>COM Interop in SVN</title><content type='html'>I just finished committing the first round of patches for COM Interop. It's been about a year since I started investigating COM Interop. This is actually the third implementation of COM Interop I've written and by far the best. It has the most compatiblity with .Net's implementation, with the least amount of code of my three implementations.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;What's working?&lt;/span&gt;&lt;br /&gt;Well, most of the functionality of RCWs (Runtime Callable Wrappers) is implemented. That means using unmanaged COM objects as managed objects. Nothing is done yet for the opposite direction for CCWs (COM Callable Wrappers); that is using managed objects as COM Objects in unmanaged code. The other main limitation is that I don't have the object marshalling done yet. That means you can't pass a COM object as a parameter (or return value) to a method on another COM object; this should be fixed shortly though. However, you can create as many COM objects as you want in managed code, and use methods/properties whose parameters (return value) are simple types. That's enough to test basic COM objects, and do stuff like start Internet Explorer and navigate to a specific url.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size:130%;"&gt;What's next?&lt;/span&gt;&lt;br /&gt;Anyway, now that the big initial patch is in, I hope it is easier to get smaller things done faster. So, be looking for fast progress in the next few weeks. I'd like to get RCW's completely done in the next month. After that, I'll either look at CCWs or else trying to extend COM Interop to work for XPCOM.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-115296971473441597?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/115296971473441597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=115296971473441597' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/115296971473441597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/115296971473441597'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2006/07/com-interop-in-svn.html' title='COM Interop in SVN'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-113357942235231844</id><published>2005-12-03T01:15:00.000-05:00</published><updated>2009-04-01T22:36:35.556-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Something Real</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/2654/1902/1600/excel.0.jpg"&gt;&lt;img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://photos1.blogger.com/blogger/2654/1902/200/excel.0.jpg" alt="" border="0" /&gt;&lt;/a&gt;Well, I've received no comments on my blog yet. Obviously, the lack of pictures is the cause. In order to remedy that, I'm posting a screenshot of the COM Interop in mono doing something real. The mono runtime is launched through Visual Studio. It runs a simple C# program that creates an Excel application, displays it, and adds a workbook.&lt;br /&gt;&lt;br /&gt;Spent alot of time working on VARIANT marshalling. And &lt;a href="http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.lcidconversionattribute.aspx"&gt;this&lt;/a&gt; little attribute caused me major pain trying to get the Excel sample working.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-113357942235231844?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/113357942235231844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=113357942235231844' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113357942235231844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113357942235231844'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2005/12/something-real.html' title='Something Real'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-113332760243601845</id><published>2005-11-30T00:12:00.000-05:00</published><updated>2009-04-01T22:36:35.556-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>COM Interop in Mono - progress</title><content type='html'>I have been making some progress in the COM Interop realm over the past couple of days. A COM object can be created in managed code. It can be cast to the various interfaces that it supports, and methods and properties can be used. All calls now go through the marshaller, with support for BSTRs and COM interfaces. That leaves VARIANTs and SAFEARRAYs. There is a few other TODOs, but I believe the only one that would directly affect a user would be support for connection points.&lt;br /&gt;&lt;br /&gt;As for XPCOM, I've been doing some research. MS COM is a binary standard. XPCOM does not seem to be a binary standard due to it's cross platform nature. Thus, I can't rely on the vtables being formatted like in MS COM. So, the consensus seems to be that the &lt;a href="http://www.mozilla.org/scriptable/xptcall-faq.html"&gt;xptcall&lt;/a&gt; is the way to go for the XPCOM interop. Not sure about interop assemblies for XPCOM yet(they can of course be hand coded). Also, haven't figured out if XPCOM interop should use the same attributes that MS COM uses, or if not where the new attributes go.&lt;br /&gt;&lt;br /&gt;After all that comes the other direction, i.e. unmanaged code using managed components as COM objects. Haven't actually done any coding for it, but I think it will be pretty easy. The marshalling code is the same as the above. Add a little bit of plumbing code and the basics should be there. I'd post a screenshot, but haven't figured out what to demo/show. Plus, my hope is that this will make it into mono in the near future anyway.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-113332760243601845?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/113332760243601845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=113332760243601845' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113332760243601845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113332760243601845'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2005/11/com-interop-in-mono-progress.html' title='COM Interop in Mono - progress'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-113280167871298535</id><published>2005-11-27T04:01:00.000-05:00</published><updated>2009-04-01T22:36:35.557-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>COM Interop in Mono (part 1)</title><content type='html'>The past few months I have been looking into supporting COM Interop in Mono. Not just for Microsoft COM on Windows, but hopefully XPCOM on Windows and Linux, as well as COM ported to Linux by third parties (&lt;a href="http://www.mainsoft.com/products/mainwin.aspx"&gt;Mainsoft&lt;/a&gt;, for example). I initially tried to do everything in managed code and did come up with a solution; but it was ugly and lacked some of the functionality of MS's implementation. So, I took the plunge and began looking into the mono runtime.&lt;br /&gt;&lt;br /&gt;COM Interop is a large topic. The definitive book for COM Interop, &lt;a href="http://www.amazon.com/gp/product/067232170X/104-6458493-7470300?v=glance&amp;n=283155&amp;amp;s=books&amp;amp;v=glance"&gt;.Net and COM: The Complete Interoperability Guide&lt;/a&gt;, is a solid 1500+ pages). So I'll skip any general explanation, and instead focus on the implementation in mono. COM Interop is bidirectional. It provides a mechanism to expose unmanaged COM objects to managed clients. The managed wrapper is called a runtime callable wrapper (RCW). It also provides a way to expose managed objects as COM objects to unmanaged clients. The wrapper exposed to unmanaged code is called a COM callable wrapper (CCW). My initial focus has been on the former.&lt;br /&gt;&lt;br /&gt;Currently, I am using the same interop assemblies that MS does. An interop assembly is generated from a COM type library, and essentially converts COM type information into metadata. This interop assembly is what is referenced by managed code. This assembly contains managed interfaces that correspond to COM interfaces, as well as managed classes that correspond to COM coclasses. The methods on each interface are in the same order as they are in the COM interface. Thus, we can determine the layout of the COM interface vtable. The usage of COM objects in managed code can be divided into two cases.&lt;br /&gt;&lt;br /&gt;The first case is when an class in the interop assembly is created in managed code. When the user creates a class that is marked with the ComImportAttribute (all classes and interfaces in the interop assembly are marked with this attribute), extra space is reserved in the class for a pointer to the unmanaged COM object.&lt;br /&gt;&lt;br /&gt;All methods on the RCW are marked as internal calls. When the runtime tries to resolve the internal call in mono, instead of looking it up in the internal call tables, a trampoline (forgive me if I'm using this term wrong) is emitted that will call the method on the underlying COM object. That trampoline first calls a helper method and passes it the MonoMethod and the MonoObject that the call is for. The pointer to the COM object is obtained from the MonoObject (stored in the extra space reserved for the pointer). Next, the interface that the method was defined on is determined. The GuidAttribute on this interface is used to call QueryInterfaces on the COM object. The returned interface pointer is the correct 'this' pointer for the unmanaged function. Then, the offset of the method in the interface is determined. This offset is used to obtain the function pointer via the vtable of the COM object. That function pointer is called using a stdcall calling convention with the 'this' pointer pushed as the first argument on the stack. Most COM methods return an HRESULT (int) that indicates success/failure. This will be translated into a managed exception.&lt;br /&gt;&lt;br /&gt;The second case occurs when an interface pointer is returned from a method/property, or when a RCW is cast to an interface that is not listed in the metadata. RCW's are special in that a cast can succeed to an interface other than those listed in the class's metadata. The runtime calls QueryInterface on the underlying COM object, and if that call succeeds the runtime allows the cast to occur. At this point, the runtime knows nothing of the COM object's identity except that it supports the given interface. The managed object's type becomes a generic type that wraps COM objects, System.__ComObject.&lt;br /&gt;&lt;br /&gt;To handle this in mono, a solution was built on top of the remoting infrastructure. First, a new internal class was defined, System.ComProxy, that derives from System.Runtime.Remoting.Proxies.RealProxy. The constructor for the ComProxy class takes an IntPtr argument, the pointer to the IUnknown interface of the COM object. System.ComProxy also implements System.Runtime.Remoting.IRemotingTypeInfo, which allows for special handling of casting via the CanCastTo method. When a COM interface pointer is returned, a new instance of ComProxy is created for the type System.__ComObject. Then a call to GetTransparentProxy is made. The transparent proxy (tp) object that is returned is cast to the expected managed interface. This in turn causes a call to CanCastTo, which calls QueryInterface on the COM object to determine whether the target interface is supported. If the interface is supported, the remoting infrastructure dynamically adds the interface and its methods to the proxy's vtable. Any method calls on this interface are now handled as in the previous case.&lt;br /&gt;&lt;br /&gt;And there it is. Too much information for the casual reader, and not enough for those of you who care. Code will hopefully follow shortly, as I have time.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-113280167871298535?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/113280167871298535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=113280167871298535' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113280167871298535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113280167871298535'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2005/11/com-interop-in-mono-part-1.html' title='COM Interop in Mono (part 1)'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19252938.post-113277796284771057</id><published>2005-11-23T15:14:00.000-05:00</published><updated>2009-04-01T22:36:35.557-04:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mono'/><title type='text'>Beginning of the End</title><content type='html'>Yes. I now have a blog.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19252938-113277796284771057?l=jonathanchambers.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://jonathanchambers.blogspot.com/feeds/113277796284771057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19252938&amp;postID=113277796284771057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113277796284771057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19252938/posts/default/113277796284771057'/><link rel='alternate' type='text/html' href='http://jonathanchambers.blogspot.com/2005/11/beginning-of-end.html' title='Beginning of the End'/><author><name>Jonathan</name><uri>http://www.blogger.com/profile/06086497145380672105</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
