<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/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>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Using thisXDocument with Managed C# code</title><link>https://www.infopathdev.com:443/forums/thread/43127.aspx</link><pubDate>Thu, 18 Jun 2009 15:09:14 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:43127</guid><dc:creator>Razor</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/43127.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=43127</wfw:commentRss><description>&lt;p&gt;By God Sir, You are right! And now it works perfectly. &lt;/p&gt;
&lt;p&gt;Thanks for Your much needed advice.&lt;/p&gt;</description></item><item><title>Re: Using thisXDocument with Managed C# code</title><link>https://www.infopathdev.com:443/forums/thread/43126.aspx</link><pubDate>Thu, 18 Jun 2009 15:05:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:43126</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/43126.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=43126</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Chances are your form is set up to use the InfoPath 2007 object model.&amp;nbsp; Code that uses thisXDocument is using the InfoPath &lt;b&gt;2003 &lt;/b&gt;object model, which is considerably different.&amp;nbsp; But even in InfoPath 2007 you can work in the 2003 object model by changing the programming language to &amp;quot;C# (InfoPath 2003 compatible)&amp;quot; in the form options.&lt;/p&gt;&lt;p&gt;&amp;nbsp;In the 2007 object model, you can check if a document is new by referencing &lt;b&gt;this.New&lt;/b&gt; or just &lt;b&gt;New&lt;/b&gt; without anything before it.&lt;/p&gt;&lt;p&gt;Here are a few links that might get you started on the 2007 OM:&lt;/p&gt;&lt;p&gt;http://msdn.microsoft.com/en-us/library/bb251747.aspx&lt;/p&gt;&lt;p&gt;http://msdn.microsoft.com/en-us/library/aa945227(VS.80).aspx&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Using thisXDocument with Managed C# code</title><link>https://www.infopathdev.com:443/forums/thread/43122.aspx</link><pubDate>Thu, 18 Jun 2009 12:50:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:43122</guid><dc:creator>Razor</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/43122.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=43122</wfw:commentRss><description>&lt;p&gt;Infopath 2007 Visual Studio 2008, .NET 3.5, C#&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Hi, I&amp;#39;m new on C# and Infopath 2007. &lt;/p&gt;
&lt;p&gt;I&amp;#39;m trying to write code in &lt;font size="2"&gt;FormEvents_Loading &lt;/font&gt;to check if the current form is new (not previously saved) but I can not use the examples I find on web:&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;public&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;partial&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;class&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;FormCode&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;{&lt;br /&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp; private&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; Microsoft.Office.Interop.InfoPath.SemiTrust.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;XDocument&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; thisXDocument;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp; private&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; Microsoft.Office.Interop.InfoPath.SemiTrust.&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;Application&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; thisApplication;&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&amp;nbsp; void&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; FormEvents_Loading(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;object&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; sender, &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;LoadingEventArgs&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; e)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; (thisXDocument.IsNew == &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;true&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Some code...&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;br /&gt;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;}&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;When previewing the template there is a NullReferenceException saying &amp;quot;Object reference not set to an instance of an object&amp;quot;.&lt;/p&gt;
&lt;p&gt;According to the information i&amp;#39;ve found on the web there should be an auto generated _Startup event where the thisXDocument variable should be initialized but I do not have such an event at all. If I add such an event like below it&amp;#39;s never even called and I get the same exception. There is a Startup event on the other hand but I can&amp;#39;t see how I could use it.&lt;/p&gt;
&lt;p&gt;public void &lt;strong&gt;_Startup&lt;/strong&gt;(Application app, XDocument doc)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thisXDocument = doc;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; thisApplication = app;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;/Lars&lt;/p&gt;</description></item></channel></rss>