<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.artinsoft.net/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>Mauricio Rojas Blog : Software Development, Interop</title><link>http://blogs.artinsoft.net/mrojas/archive/tags/Software+Development/Interop/default.aspx</link><description>Tags: Software Development, Interop</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Debug XBAP using WinForms Host</title><link>http://blogs.artinsoft.net/mrojas/archive/2009/01/26/debug-xbap-using-winforms-host.aspx</link><pubDate>Mon, 26 Jan 2009 19:13:21 GMT</pubDate><guid isPermaLink="false">871fd81c-a111-489f-851d-e9637b8e2ce4:1779</guid><dc:creator>Mrojas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.artinsoft.net/mrojas/rsscomments.aspx?PostID=1779</wfw:commentRss><comments>http://blogs.artinsoft.net/mrojas/archive/2009/01/26/debug-xbap-using-winforms-host.aspx#comments</comments><description>&lt;p&gt;Recently I had to deal with targeting an XBAP application that had some Windows Forms controls.&lt;/p&gt;  &lt;p&gt;The problem is that those controls can only be used in a trusted environment. If you try to debug an XBAP with some Windows Forms Controls you will get an exception like:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Message: Cannot create instance of &amp;#39;Page1&amp;#39; defined in assembly &amp;#39;XBAPWithWinForms, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;#39;. Exception has been thrown by the target of an invocation.&amp;#160; Error in markup file &amp;#39;Page1.xaml&amp;#39; Line 1 Position 7.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;It took me a while to found a solution, and it was thru &lt;a href="http://www.codeexperiment.com/post/Debugging-XBAPWCF-Applications.aspx"&gt;Scott Landford Blog&lt;/a&gt; that I found a way around.&lt;/p&gt;  &lt;p&gt;In short what he recommends to do is:&lt;/p&gt;  &lt;p&gt;Change your settings to:&lt;/p&gt;  &lt;p&gt;Start Action-&amp;gt;Start external program = %windir%system32\PresentationHost.exe&lt;/p&gt;  &lt;p&gt;&lt;font color="#00ff00"&gt;&amp;#160;&lt;/font&gt;&lt;font color="#008000"&gt; In my case (and the case of most people that is: c:\windows\system32\PresentationHost.exe)&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;Start Options-&amp;gt;Command line arguments = -debug &amp;quot;c:\projects\myproject\bin\debug\MyProject.xbap&amp;quot; -debugSecurityZoneUrl &amp;quot;http://localhost:2022&amp;quot;&lt;/p&gt;  &lt;p&gt;&lt;font color="#008000"&gt;Copy the value from the Start URL after the –debug argument&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;Very import for using WinForms components you must run in &lt;strong&gt;FULL TRUST&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.artinsoft.net/public_img/DebugXBAPusingWinFormsHost_9DD0/fullTrust.png"&gt;&lt;img title="fullTrust" style="border-right:0px;border-top:0px;display:inline;border-left:0px;border-bottom:0px;" height="304" alt="fullTrust" src="http://blogs.artinsoft.net/public_img/DebugXBAPusingWinFormsHost_9DD0/fullTrust_thumb.png" width="404" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is some XBAP code using a WinForms WebBrowser. They designer does not like it a lot but it works:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.artinsoft.net/public_img/" href="http://blogs.artinsoft.net/public_img/XBAPWithWinforms.zip"&gt;XBAPWithWinforms.zip&lt;/a&gt;&lt;/p&gt;&lt;img src="http://blogs.artinsoft.net/aggbug.aspx?PostID=1779" width="1" height="1"&gt;</description><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/VB6+Migration/default.aspx">VB6 Migration</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/Interop/default.aspx">Interop</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/XBAP/default.aspx">XBAP</category></item><item><title>TLBIMP SourceCode</title><link>http://blogs.artinsoft.net/mrojas/archive/2008/09/30/tlbimp-sourcecode.aspx</link><pubDate>Tue, 30 Sep 2008 21:50:00 GMT</pubDate><guid isPermaLink="false">871fd81c-a111-489f-851d-e9637b8e2ce4:1693</guid><dc:creator>Mrojas</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://blogs.artinsoft.net/mrojas/rsscomments.aspx?PostID=1693</wfw:commentRss><comments>http://blogs.artinsoft.net/mrojas/archive/2008/09/30/tlbimp-sourcecode.aspx#comments</comments><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you ever wished to modify the way Visual Studio imported a COM Class. Well finally you can.&lt;/p&gt;
&lt;p&gt;The &lt;span class="Apple-style-span" style="WORD-SPACING:0px;FONT:bold 26px &amp;#39;Segoe UI&amp;#39;;TEXT-TRANSFORM:none;TEXT-INDENT:0px;WHITE-SPACE:normal;LETTER-SPACING:normal;BORDER-COLLAPSE:separate;orphans:2;widows:2;-webkit-border-horizontal-spacing:0px;-webkit-border-vertical-spacing:0px;-webkit-text-decorations-in-effect:none;-webkit-text-size-adjust:auto;-webkit-text-stroke-width:0;"&gt;&lt;span id="ctl00_ctl00_WideContent_ProjectTitleControl1_TitleLabel"&gt;&lt;a class="NoUnderline" id="ctl00_ctl00_WideContent_ProjectTitleControl1_ProjectTitleLink" style="TEXT-DECORATION:underline;" href="http://www.codeplex.com/clrinterop"&gt;Managed, Native, and COM Interop Team&lt;/a&gt;&lt;span style="COLOR:#000000;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;(wow what a name). It looks like the name of that goverment office in the Ironman movie.&lt;/p&gt;
&lt;p&gt;Well this fine group of men, have release the source code of the TLBIMP tool. I&amp;#39;m more that happy for this.&lt;/p&gt;
&lt;p&gt;I can know finally get why are some things imported the way they are.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.codeplex.com/clrinterop"&gt;http://www.codeplex.com/clrinterop&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can dowload also the P/Invoke assistant. This assistant has a library of signatures so you can invoke any Windows API.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://blogs.artinsoft.net/aggbug.aspx?PostID=1693" width="1" height="1"&gt;</description><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/VIsual+Basic+.NET/default.aspx">VIsual Basic .NET</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/.NET+General+Tip/default.aspx">.NET General Tip</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/VB6+Migration/default.aspx">VB6 Migration</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/Software+Development/default.aspx">Software Development</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/COM/default.aspx">COM</category><category domain="http://blogs.artinsoft.net/mrojas/archive/tags/Interop/default.aspx">Interop</category></item></channel></rss>