<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Yves Peneveyre's Blog - Programming</title>
    <link>http://www.peneveyre.com/blog/</link>
    <description>Your .NET and Microsoft technologies specialist in Western Switzerland</description>
    <language>en-us</language>
    <copyright>Yves Peneveyre</copyright>
    <lastBuildDate>Wed, 27 Jan 2010 15:24:29 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>yves@peneveyre.com</managingEditor>
    <webMaster>yves@peneveyre.com</webMaster>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=0d706f60-030d-4eb7-b08f-f0aedfc3e835</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,0d706f60-030d-4eb7-b08f-f0aedfc3e835.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,0d706f60-030d-4eb7-b08f-f0aedfc3e835.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=0d706f60-030d-4eb7-b08f-f0aedfc3e835</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Google is working on a new language named <a href="http://golang.org/">"Go"</a> and
they call it a "systems programming language". It is not the intent to make a review
or to compare it with other existing language, far from that, but it worth having
a look at that new language.<br />
First, the syntax is similar to the languages that most of the people are used to.
It is more or less the same as C or Java. A bit closer to C anyway for some reason
described further in this post. One notable difference is that the type is defined
after a variable name, for example.<br />
One of the goal of the language is to simplify the code or to make it less verbose.
But, as a tradeoff, it makes the code reading more difficult, or maybe it is just
a matter of getting used to the syntax. For example, there is only one keyword for
the loops : for<br />
A thing I find nice is the possibility for a function to return more than one value
and therefore they introduced multiple return functions.<br />
The other features of the language are summarized here :<br />
Anonymous functions<br />
Slices; a part of an 0-based array<br />
Maps; other word for dictionary<br />
Object orientation using structures; which makes it closer to C than Java and in my
opinion not the best thing the language could have<br />
Interfaces<br />
No inheritance; Instead of supporting object inheritance, the creators of the language
prefer to use composition of structs<br />
Real-Time flavour; My ADA background reveals to the surface when I see the constructs
of Go to support multitasking. What I liked a lot in ADA was the possibility to write
methods that were callable from other tasks and how easy it was to create a multi-task
program. With Go, it seems that simple. You define a method and rather than calling
it normally, you prefix it with the keyword "go" :
</p>
        <p>
go MyParallelTask;
</p>
        <p>
Communication in a multi-task program can also be a challenge, being just to exchange
information or data or just to synchronize two tasks. With Go, you need to instantiate
a channel and use arrows (channelname &lt;- value and variablename := &lt;- channelname)
to send to or received data from the channel. That channel can be synchronous or in
other words blocking enabling the synchronization between two tasks or can by asynchronous
(under certain limits given by the buffer size of the channel).
</p>
        <p>
On the side of what is not in Go, we have :<br />
Generics or templates<br />
Exceptions
</p>
        <p>
For those two points, the Go team has not yet decided if they would add these features
for the reasons that can be read here : <a href="http://golang.org/doc/go_lang_faq.html#generics">http://golang.org/doc/go_lang_faq.html#generics</a></p>
        <p>
In conclusion, it is too early to say if this language will succeed and gain many
market shares in the programming world. It will mainly depend on the built-in libraries
and the platform that will support it. Less important for such system languages is
the interoperability features and how a Go program will be able to communicate with
the external world. Another success factor is the developer community. Today, Go is
only available for Linux or Mac OS X and probably some tools or IDEs would be needed
in the future, but not sure because as it is mentioned a number of times, the aim
of the language is system programming language and therefore not playing in the same
field as C# and other high-level languages.
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=0d706f60-030d-4eb7-b08f-f0aedfc3e835" />
      </body>
      <title>Google and the Go Language</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,0d706f60-030d-4eb7-b08f-f0aedfc3e835.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,0d706f60-030d-4eb7-b08f-f0aedfc3e835.aspx</link>
      <pubDate>Wed, 27 Jan 2010 15:24:29 GMT</pubDate>
      <description>&lt;p&gt;
Google is working on a new language named &lt;a href="http://golang.org/"&gt;"Go"&lt;/a&gt; and
they call it a "systems programming language". It is not the intent to make a review
or to compare it with other existing language, far from that, but it worth having
a look at that new language.&lt;br&gt;
First, the syntax is similar to the languages that most of the people are used to.
It is more or less the same as C or Java. A bit closer to C anyway for some reason
described further in this post. One notable difference is that the type is defined
after a variable name, for example.&lt;br&gt;
One of the goal of the language is to simplify the code or to make it less verbose.
But, as a tradeoff, it makes the code reading more difficult, or maybe it is just
a matter of getting used to the syntax. For example, there is only one keyword for
the loops : for&lt;br&gt;
A thing I find nice is the possibility for a function to return more than one value
and therefore they introduced multiple return functions.&lt;br&gt;
The other features of the language are summarized here :&lt;br&gt;
Anonymous functions&lt;br&gt;
Slices; a part of an 0-based array&lt;br&gt;
Maps; other word for dictionary&lt;br&gt;
Object orientation using structures; which makes it closer to C than Java and in my
opinion not the best thing the language could have&lt;br&gt;
Interfaces&lt;br&gt;
No inheritance; Instead of supporting object inheritance, the creators of the language
prefer to use composition of structs&lt;br&gt;
Real-Time flavour; My ADA background reveals to the surface when I see the constructs
of Go to support multitasking. What I liked a lot in ADA was the possibility to write
methods that were callable from other tasks and how easy it was to create a multi-task
program. With Go, it seems that simple. You define a method and rather than calling
it normally, you prefix it with the keyword "go" :
&lt;/p&gt;
&lt;p&gt;
go MyParallelTask;
&lt;/p&gt;
&lt;p&gt;
Communication in a multi-task program can also be a challenge, being just to exchange
information or data or just to synchronize two tasks. With Go, you need to instantiate
a channel and use arrows (channelname &amp;lt;- value and variablename := &amp;lt;- channelname)
to send to or received data from the channel. That channel can be synchronous or in
other words blocking enabling the synchronization between two tasks or can by asynchronous
(under certain limits given by the buffer size of the channel).
&lt;/p&gt;
&lt;p&gt;
On the side of what is not in Go, we have :&lt;br&gt;
Generics or templates&lt;br&gt;
Exceptions
&lt;/p&gt;
&lt;p&gt;
For those two points, the Go team has not yet decided if they would add these features
for the reasons that can be read here : &lt;a href="http://golang.org/doc/go_lang_faq.html#generics"&gt;http://golang.org/doc/go_lang_faq.html#generics&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
In conclusion, it is too early to say if this language will succeed and gain many
market shares in the programming world. It will mainly depend on the built-in libraries
and the platform that will support it. Less important for such system languages is
the interoperability features and how a Go program will be able to communicate with
the external world. Another success factor is the developer community. Today, Go is
only available for Linux or Mac OS X and probably some tools or IDEs would be needed
in the future, but not sure because as it is mentioned a number of times, the aim
of the language is system programming language and therefore not playing in the same
field as C# and other high-level languages.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=0d706f60-030d-4eb7-b08f-f0aedfc3e835" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,0d706f60-030d-4eb7-b08f-f0aedfc3e835.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=15de429c-6a4d-4801-ba96-e64f235bb326</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,15de429c-6a4d-4801-ba96-e64f235bb326.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,15de429c-6a4d-4801-ba96-e64f235bb326.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=15de429c-6a4d-4801-ba96-e64f235bb326</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>Title :</strong>
          <a href="http://www.amazon.com/Foundations-BizTalk-Server-Daniel-Woolston/dp/1590597753/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1262713482&amp;sr=8-1">Foundations
of BizTalk Server 2006</a>
        </p>
        <p>
          <strong>Author :</strong> Daniel Woolston
</p>
        <p>
          <strong>
            <img style="WIDTH: 126px; HEIGHT: 133px" src="http://ecx.images-amazon.com/images/I/51lJRsZwPWL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg" width="130" height="152" />
          </strong>
        </p>
        <p>
          <strong>Summary :</strong>
          <br />
          <a href="http://www.microsoft.com/biztalk/en/us/default.aspx">BizTalk Server 2006</a> was
until last year, the latest version of the middleware product from Microsoft. Since,
the new version, BizTalk Server 2009, has been released. Despite BizTalk Server 2006
is not the first or second version of the product, it really needs documentation on
how to use and develop on this platform as it is absolutely difficult or impossible
to start on such product like this.<br />
The book is structured around the different component or pieces of BizTalk : Messaging,
Schemas, Maps, Ports, Orchestrations. It covers all the aspects of the product even
tackling the application deployment.<br />
It is full of useful screenshots and the explanations are clear enough even if you
don't have the software at hand.
</p>
        <p>
          <strong>Review :</strong>
          <br />
Working with BizTalk since couple of years, I found the book quite basic. Ok, the
title contains "Foundations", so don't expect advanced explanation but rather take
it as a first look at BizTalk. A good example is to read it before an intermediate
or advanced training. At the end, it gives an excellent overview of what can be done
and how can specific problems can be solved with BizTalk Server 2006. Another good
point is that it is not a big pad to read and can be absorbed in a week-end :-)
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=15de429c-6a4d-4801-ba96-e64f235bb326" />
      </body>
      <title>Book Review : Foundations of BizTalk Server 2006</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,15de429c-6a4d-4801-ba96-e64f235bb326.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,15de429c-6a4d-4801-ba96-e64f235bb326.aspx</link>
      <pubDate>Tue, 05 Jan 2010 17:59:14 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;Title :&lt;/strong&gt; &lt;a href="http://www.amazon.com/Foundations-BizTalk-Server-Daniel-Woolston/dp/1590597753/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1262713482&amp;amp;sr=8-1"&gt;Foundations
of BizTalk Server 2006&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Author :&lt;/strong&gt; Daniel Woolston
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;img style="WIDTH: 126px; HEIGHT: 133px" src="http://ecx.images-amazon.com/images/I/51lJRsZwPWL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg" width=130 height=152&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Summary :&lt;/strong&gt;
&lt;br&gt;
&lt;a href="http://www.microsoft.com/biztalk/en/us/default.aspx"&gt;BizTalk Server 2006&lt;/a&gt; was
until last year, the latest version of the middleware product from Microsoft. Since,
the new version, BizTalk Server 2009, has been released. Despite BizTalk Server 2006
is not the first or second version of the product, it really needs documentation on
how to use and develop on this platform as it is absolutely difficult or impossible
to start on such product like this.&lt;br&gt;
The book is structured around the different component or pieces of BizTalk : Messaging,
Schemas, Maps, Ports, Orchestrations. It covers all the aspects of the product even
tackling the application deployment.&lt;br&gt;
It is full of useful screenshots and the explanations are clear enough even if you
don't have the software at hand.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Review :&lt;/strong&gt;
&lt;br&gt;
Working with BizTalk since couple of years, I found the book quite basic. Ok, the
title contains "Foundations", so don't expect advanced explanation but rather take
it as a first look at BizTalk. A good example is to read it before an intermediate
or advanced training. At the end, it gives an excellent overview of what can be done
and how can specific problems can be solved with BizTalk Server 2006. Another good
point is that it is not a big pad to read and can be absorbed in a week-end :-)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=15de429c-6a4d-4801-ba96-e64f235bb326" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,15de429c-6a4d-4801-ba96-e64f235bb326.aspx</comments>
      <category>Book Review</category>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=9156ccf4-98a9-4a06-a848-744fb7fbb3bc</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,9156ccf4-98a9-4a06-a848-744fb7fbb3bc.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,9156ccf4-98a9-4a06-a848-744fb7fbb3bc.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9156ccf4-98a9-4a06-a848-744fb7fbb3bc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>Summary :</strong>
          <br />
F# is a new language that is coming in the pipe of Microsoft for the Visual Studio
platform. It aims to tackle the functional programming paradigm eventhough it is possible
to use the imperative or object oriented programming.<br />
Robert Pickering starts his book by explaining the basics of F#, how to get and how
to use the tools. Then, the book describes the F# syntax to be used in the three language
paradigm, functional programming, imperative programming and finally object oriented
programming. Among other things, the notion of type inference is presented. Once the
syntax is presented, the book describes the way to develop web, windows or even WPF
applications using the .NET framework. Data access is also addressed using the current
technologies available, such as ADO.NET or LINQ. Then, a quick look at DSLs, compilation
and code generation is given, presenting the lex and yacc tools coming with the language.
Finally, a full chapter is dedicated to the interoperability between .NET and F#,
because even if F# is based on the CLI, the language introduces several types that
are not available in the other .NET languages (C# or VB.NET).
</p>
        <p>
          <strong>Review :</strong>
          <br />
Discovering a new language is really interesting and with F#, it is the occasion to
see a new paragigm, functional programming. In really short, with F#, everything is
a value, even a function. It means that you can use a function as a function parameter.
The concept of type inference is also very attracting. The book is very easy to understand
and a lot of little examples are explained in details, making the reading very fast.
The first half of the book is dedicated to the language itself. The second half is
more on using the .NET framework and I would say that it is the less interesting of
the book. Indeed, during the first part, you have came across various examples using
types and classes of the framework and user interface development being web or windows,
or data access meaning that the second part does not bring a lot a information. Once
you know these topics from the .NET documentation or from another book and once you
have read how to access the .NET BCL from F#, then this part is pretty straightforward
and not really useful. Moreover, the examples used to depict the topics are more explaining
how to use the BCL classes than the language itself. Nevertheless, the last parts
discussing the interoperability and the possibility of generating DSLs are more interesting.<br />
My final words are that it is a very intersting book if you want to see another land
(functional programming). Unfortunately, on my bookshelf, I also have "Expert F#"
that I just opened to see what is inside and I saw that it takes the explanations
and descriptions of the language from the beginning. If I had knew that before, maybe
I would have bought this one instead. So, if the goal is just to scratch the surface
of F#, "<a href="http://www.amazon.com/Expert-F-Experts-Voice-Net/dp/1590598504/ref=pd_bbs_sr_2?ie=UTF8&amp;s=books&amp;qid=1232011330&amp;sr=8-2">Foundations
of F#</a>" is the best suited, otherwise, if the goal is to go really deeper in the
topic, then prefer "<a href="http://www.amazon.com/Expert-F-Experts-Voice-Net/dp/1590598504/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1232011385&amp;sr=1-1">Expert
F#</a>" (a review of that one will be posted).
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=9156ccf4-98a9-4a06-a848-744fb7fbb3bc" />
      </body>
      <title>Book Review : Foundations of F#</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,9156ccf4-98a9-4a06-a848-744fb7fbb3bc.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,9156ccf4-98a9-4a06-a848-744fb7fbb3bc.aspx</link>
      <pubDate>Thu, 15 Jan 2009 09:21:33 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;Summary :&lt;/strong&gt;
&lt;br&gt;
F# is a new language that is coming in the pipe of Microsoft for the Visual Studio
platform. It aims to tackle the functional programming paradigm eventhough it is possible
to use the imperative or object oriented programming.&lt;br&gt;
Robert Pickering starts his book by explaining the basics of F#, how to get and how
to use the tools. Then, the book describes the F# syntax to be used in the three language
paradigm, functional programming, imperative programming and finally object oriented
programming. Among other things, the notion of type inference is presented. Once the
syntax is presented, the book describes the way to develop web, windows or even WPF
applications using the .NET framework. Data access is also addressed using the current
technologies available, such as ADO.NET or LINQ. Then, a quick look at DSLs, compilation
and code generation is given, presenting the lex and yacc tools coming with the language.
Finally, a full chapter is dedicated to the interoperability between .NET and F#,
because even if F# is based on the CLI, the language introduces several types that
are not available in the other .NET languages (C# or VB.NET).
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Review :&lt;/strong&gt;
&lt;br&gt;
Discovering a new language is really interesting and with F#, it is the occasion to
see a new paragigm, functional programming. In really short, with F#, everything is
a value, even a function. It means that you can use a function as a function parameter.
The concept of type inference is also very attracting. The book is very easy to understand
and a lot of little examples are explained in details, making the reading very fast.
The first half of the book is dedicated to the language itself. The second half is
more on using the .NET framework and I would say that it is the less interesting of
the book. Indeed, during the first part, you have came across various examples using
types and classes of the framework and user interface development being web or windows,
or data access meaning that the second part does not bring a lot a information. Once
you know these topics from the .NET documentation or from another book and once you
have read how to access the .NET BCL from F#, then this part is pretty straightforward
and not really useful. Moreover, the examples used to depict the topics are more explaining
how to use the BCL classes than the language itself. Nevertheless, the last parts
discussing the interoperability and the possibility of generating DSLs are more interesting.&lt;br&gt;
My final words are that it is a very intersting book if you want to see another land
(functional programming). Unfortunately, on my bookshelf, I also have "Expert F#"
that I just opened to see what is inside and I saw that it takes the explanations
and descriptions of the language from the beginning. If I had knew that before, maybe
I would have bought this one instead. So, if the goal is just to scratch the surface
of F#, "&lt;a href="http://www.amazon.com/Expert-F-Experts-Voice-Net/dp/1590598504/ref=pd_bbs_sr_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1232011330&amp;amp;sr=8-2"&gt;Foundations
of F#&lt;/a&gt;" is the best suited, otherwise, if the goal is to go really deeper in the
topic, then prefer "&lt;a href="http://www.amazon.com/Expert-F-Experts-Voice-Net/dp/1590598504/ref=sr_1_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1232011385&amp;amp;sr=1-1"&gt;Expert
F#&lt;/a&gt;" (a review of that one will be posted).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=9156ccf4-98a9-4a06-a848-744fb7fbb3bc" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,9156ccf4-98a9-4a06-a848-744fb7fbb3bc.aspx</comments>
      <category>Book Review</category>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=84769dc7-b15d-4450-95d6-ec30dc181a53</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,84769dc7-b15d-4450-95d6-ec30dc181a53.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,84769dc7-b15d-4450-95d6-ec30dc181a53.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=84769dc7-b15d-4450-95d6-ec30dc181a53</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been needing a BPMN and a UML 2 stencil for Visio 2007, and, truth said, I
think I found my happyness in the following stencils :
</p>
        <p>
For UML 2, I found one at <a href="http://www.softwarestencils.com">softwarestencils</a>.
There are plenty of different stencils, even for Visio 2007. It offers all the
shapes, but for some of them, you need to change the properties of them to
have them appearing on your design surface. So, for UML 2, go <a href="http://www.softwarestencils.com/uml/index.html">there</a>.
</p>
        <p>
Regarding <a href="http://www.bpmn.org">BPMN</a>, the <a href="http://tynerblain.com/blog/2006/09/26/bpmn-stencils/">one
proposed</a> by <a href="http://tynerblain.com/blog/">Tyner Blain</a> is a goodfit
and it seems, at a first glance, it fits all my current needs. It offers all the BPMN
shapes, the only thing missing, maybe, are the swimlanes.
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=84769dc7-b15d-4450-95d6-ec30dc181a53" />
      </body>
      <title>BPMN and UML 2.0 Stencils</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,84769dc7-b15d-4450-95d6-ec30dc181a53.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,84769dc7-b15d-4450-95d6-ec30dc181a53.aspx</link>
      <pubDate>Tue, 20 May 2008 18:43:23 GMT</pubDate>
      <description>&lt;p&gt;
I have been needing a BPMN and a UML 2 stencil for Visio 2007, and, truth said, I
think I found my happyness in the following stencils :
&lt;/p&gt;
&lt;p&gt;
For UML 2, I found one at &lt;a href="http://www.softwarestencils.com"&gt;softwarestencils&lt;/a&gt;.
There are plenty of different stencils, even for Visio 2007. It offers&amp;nbsp;all the
shapes, but&amp;nbsp;for some of them, you need to change the properties of them&amp;nbsp;to
have them appearing on&amp;nbsp;your design surface. So, for UML 2, go &lt;a href="http://www.softwarestencils.com/uml/index.html"&gt;there&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Regarding &lt;a href="http://www.bpmn.org"&gt;BPMN&lt;/a&gt;, the &lt;a href="http://tynerblain.com/blog/2006/09/26/bpmn-stencils/"&gt;one
proposed&lt;/a&gt; by &lt;a href="http://tynerblain.com/blog/"&gt;Tyner Blain&lt;/a&gt; is a goodfit
and it seems, at a first glance, it fits all my current needs. It offers all the BPMN
shapes, the only thing missing, maybe, are the swimlanes.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=84769dc7-b15d-4450-95d6-ec30dc181a53" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,84769dc7-b15d-4450-95d6-ec30dc181a53.aspx</comments>
      <category>English</category>
      <category>Programming</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=2ca81749-7f1b-4f49-ac80-cc47f913e859</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,2ca81749-7f1b-4f49-ac80-cc47f913e859.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,2ca81749-7f1b-4f49-ac80-cc47f913e859.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=2ca81749-7f1b-4f49-ac80-cc47f913e859</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It is done !
</p>
        <p>
I successfully passed the <a href="http://www.microsoft.com/learning/mcp/mcts/spservices/config/default.mspx">70-631</a> exam
and I am now <a href="http://www.microsoft.com/learning/mcp/mcts/default.mspx">MCTS</a> on <a href="http://www.microsoft.com/sharepoint/default.mspx">Sharepoint</a>,
more precisely "Configuring" SharePoint.
</p>
        <p>
It was not so easy (that is why it is a certification) and it required a bit of work
in order to be able to see the different aspects of the SharePoint configuration. <a href="http://www.measureup.com/">MeasureUp</a> helps,
but when you are in front of the screen for the exam, you realize and you thank the
experience you have with SharePoint...
</p>
        <p>
But, it is done, and now, go for the next one...
</p>
        <p>
          <a href="http://www.microsoft.com/learning/mcp/mcts/default.mspx">
            <img src="http://www.peneveyre.com/blog/content/binary/mcts.jpg" border="0" />
          </a>
        </p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=2ca81749-7f1b-4f49-ac80-cc47f913e859" />
      </body>
      <title>Sharepoint Certification</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,2ca81749-7f1b-4f49-ac80-cc47f913e859.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,2ca81749-7f1b-4f49-ac80-cc47f913e859.aspx</link>
      <pubDate>Mon, 17 Mar 2008 12:06:41 GMT</pubDate>
      <description>&lt;p&gt;
It is done !
&lt;/p&gt;
&lt;p&gt;
I successfully passed the &lt;a href="http://www.microsoft.com/learning/mcp/mcts/spservices/config/default.mspx"&gt;70-631&lt;/a&gt; exam
and I am now &lt;a href="http://www.microsoft.com/learning/mcp/mcts/default.mspx"&gt;MCTS&lt;/a&gt; on &lt;a href="http://www.microsoft.com/sharepoint/default.mspx"&gt;Sharepoint&lt;/a&gt;,
more precisely "Configuring" SharePoint.
&lt;/p&gt;
&lt;p&gt;
It was not so easy (that is why it is a certification) and it required a bit of work
in order to be able to see the different aspects of the SharePoint configuration. &lt;a href="http://www.measureup.com/"&gt;MeasureUp&lt;/a&gt; helps,
but when you are in front of the screen for the exam, you realize and you thank the
experience you have with SharePoint...
&lt;/p&gt;
&lt;p&gt;
But, it is done, and now, go for the next one...
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/learning/mcp/mcts/default.mspx"&gt;&lt;img src="http://www.peneveyre.com/blog/content/binary/mcts.jpg" border=0&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=2ca81749-7f1b-4f49-ac80-cc47f913e859" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,2ca81749-7f1b-4f49-ac80-cc47f913e859.aspx</comments>
      <category>English</category>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=1cfbf769-db44-4e8c-9216-a77e843c3cd6</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,1cfbf769-db44-4e8c-9216-a77e843c3cd6.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,1cfbf769-db44-4e8c-9216-a77e843c3cd6.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1cfbf769-db44-4e8c-9216-a77e843c3cd6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The coming weeks, I am going to have a look at the latest Beta of Visual Studio 2008
Team Foundation Server and Microsoft has done all it was possible to make it easier
(or almost).
</p>
        <p>
First, they released Virtual PC hard drives (vhd) with all the software included.
So, as I have the luck of having a MSDN subscription, I first downloaded the 9 parts
of the VHD file. Yes ! A total of 4.2GB to download, taking the whole night to get
it. But, once deflated, it takes more or less 13GB ! That's ok for me, on an external
420GB hard drive, I can afford it.
</p>
        <p>
The only problem I had was that when I launched the VPC image, it simply failed, telling
me that "The parent virtual hard disk has been deleted or has been moved from its
previous location. Please select the new location of the parent virtual hard disk".
That was strange, because, on the MSDN subscriptions site, there is no mention about
a parent virtual hard disk. Or, at least, not enough visible for me.
</p>
        <p>
To solve this little issue, it is better to download the VHD from the Microsoft download <a href="http://download.microsoft.com">site</a>.
There, you have all the instructions you would need, and, the most important, where
to download this parent virtual hard drive.
</p>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=60a5b34b-98b0-4702-b2dd-6fc0bef7e494&amp;DisplayLang=en">Link
to the Visual Studio 2008 Beta 2 Team Foundaction Server</a> download
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=1cfbf769-db44-4e8c-9216-a77e843c3cd6" />
      </body>
      <title>Testing Visual Studio 2008 Team Foundation Server</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,1cfbf769-db44-4e8c-9216-a77e843c3cd6.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,1cfbf769-db44-4e8c-9216-a77e843c3cd6.aspx</link>
      <pubDate>Sat, 04 Aug 2007 20:22:19 GMT</pubDate>
      <description>&lt;p&gt;
The coming weeks, I am going to have a look at the latest Beta of Visual Studio 2008
Team Foundation Server and Microsoft has done all it was possible to make it easier
(or almost).
&lt;/p&gt;
&lt;p&gt;
First, they released Virtual PC hard drives (vhd) with all the software included.
So, as I have the luck of having a MSDN subscription, I first downloaded the 9 parts
of the VHD file. Yes ! A total of 4.2GB to download, taking the whole night to get
it. But, once deflated, it takes more or less 13GB ! That's ok for me, on an external
420GB hard drive, I can afford it.
&lt;/p&gt;
&lt;p&gt;
The only problem I had was that when I launched the VPC image, it simply failed, telling
me that "The parent virtual hard disk has been deleted or has been moved from its
previous location. Please select the new location of the parent virtual hard disk".
That was strange, because, on the MSDN subscriptions site, there is no mention about
a parent virtual hard disk. Or, at least, not enough visible for me.
&lt;/p&gt;
&lt;p&gt;
To solve this little issue, it is better to download the VHD from the Microsoft download &lt;a href="http://download.microsoft.com"&gt;site&lt;/a&gt;.
There, you have all the instructions you would need, and, the most important, where
to download this parent virtual hard drive.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=60a5b34b-98b0-4702-b2dd-6fc0bef7e494&amp;amp;DisplayLang=en"&gt;Link
to the Visual Studio 2008 Beta 2 Team Foundaction Server&lt;/a&gt; download
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=1cfbf769-db44-4e8c-9216-a77e843c3cd6" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,1cfbf769-db44-4e8c-9216-a77e843c3cd6.aspx</comments>
      <category>Programming</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=50654134-547c-4617-9c2d-ef94e1934c8f</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,50654134-547c-4617-9c2d-ef94e1934c8f.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,50654134-547c-4617-9c2d-ef94e1934c8f.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=50654134-547c-4617-9c2d-ef94e1934c8f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I found a very interesting post about "How to build a SharePoint development
machine". I think there is a lot of good points there, along with a list of useful
tools to develop SharePoint application smoothly.
</p>
        <p>
Thanks to Eli Robillard (MVP SharePoint) for <a href="http://weblogs.asp.net/erobillard/archive/2007/02/23/build-a-sharepoint-development-machine.aspx">his
excellent post</a></p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=50654134-547c-4617-9c2d-ef94e1934c8f" />
      </body>
      <title>SharePoint developments - How to have a good development environment</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,50654134-547c-4617-9c2d-ef94e1934c8f.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,50654134-547c-4617-9c2d-ef94e1934c8f.aspx</link>
      <pubDate>Sat, 31 Mar 2007 16:28:17 GMT</pubDate>
      <description>&lt;p&gt;
I found a very&amp;nbsp;interesting post about "How to build a SharePoint development
machine". I think there is a lot of good points there, along with a list of useful
tools to develop SharePoint application smoothly.
&lt;/p&gt;
&lt;p&gt;
Thanks to Eli Robillard (MVP SharePoint)&amp;nbsp;for &lt;a href="http://weblogs.asp.net/erobillard/archive/2007/02/23/build-a-sharepoint-development-machine.aspx"&gt;his
excellent post&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=50654134-547c-4617-9c2d-ef94e1934c8f" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,50654134-547c-4617-9c2d-ef94e1934c8f.aspx</comments>
      <category>Programming</category>
      <category>SharePoint</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=aecbd1b7-63de-4cad-ade5-0f8523cbc6e4</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,aecbd1b7-63de-4cad-ade5-0f8523cbc6e4.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,aecbd1b7-63de-4cad-ade5-0f8523cbc6e4.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=aecbd1b7-63de-4cad-ade5-0f8523cbc6e4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
When you have a lot of pressure on a project regarding the planning especially, sometimes,
just a little thing that makes your developer life tougher is not supportable.
</p>
        <p>
It was the case this week, during a migration from an application written in ASP to
.NET. I migrated several dialogs that were supposed to be displayed as modal dialogs.
During the developments and the testing, everything went fine. No bugs.
</p>
        <p>
But, when integrated in the whole application, it simply did not work at all, just
because my .NET web forms were displayed using the showModalDialog javascript function.
In one of them, I had a datagrid with a column containing hyperlinks. What a surprise
when you click on the link and that a page with the url javascript:__dopostback(...)
opens ! And you know why ?
</p>
        <p>
Just because you have to add a &lt;base&gt; tag in your head section of the page,
like below :
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">&lt;head&gt;<br />
   ....<br />
   &lt;base target=<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"_self"</span>&gt;<br />
   ....<br />
&lt;/head&gt;<br /><br /></span>
        </p>
        <p>
I spent almost half a day to fix this, but I also learned it.... :-)
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=aecbd1b7-63de-4cad-ade5-0f8523cbc6e4" />
      </body>
      <title>showModalDialog, .NET and the &lt;base&gt; tag</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,aecbd1b7-63de-4cad-ade5-0f8523cbc6e4.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,aecbd1b7-63de-4cad-ade5-0f8523cbc6e4.aspx</link>
      <pubDate>Thu, 22 Mar 2007 21:46:09 GMT</pubDate>
      <description>&lt;p&gt;
When you have a lot of pressure on a project regarding the planning especially, sometimes,
just a little thing that makes your developer life tougher is not supportable.
&lt;/p&gt;
&lt;p&gt;
It was the case this week, during a migration from an application written in ASP to
.NET. I migrated several dialogs that were supposed to be displayed as modal dialogs.
During the developments and the testing, everything went fine. No bugs.
&lt;/p&gt;
&lt;p&gt;
But, when integrated in the whole application, it simply did not work at all, just
because my .NET web forms were displayed using the showModalDialog javascript function.
In one of them, I had a datagrid with a column containing hyperlinks. What a surprise
when you click on the link and that a page with the url javascript:__dopostback(...)
opens ! And you know why ?
&lt;/p&gt;
&lt;p&gt;
Just because you have to add a &amp;lt;base&amp;gt; tag in your head section of the page,
like below :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;lt;head&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;....&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;base target=&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"_self"&lt;/span&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;....&lt;br&gt;
&amp;lt;/head&amp;gt;&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
I spent almost half a day to fix this, but I also learned it.... :-)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=aecbd1b7-63de-4cad-ade5-0f8523cbc6e4" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,aecbd1b7-63de-4cad-ade5-0f8523cbc6e4.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font color="#000000">In this project, I had to work on an Excel file getting its
data from a database in order to generate a document usable for the end-user. The
problem was that a lot of pivot tables were included everywhere in the document making
the manual update of these tables really painful. So, my problem was to automate the
process of this update in order to refresh all the pivot tables in all the worksheets.
In finally wrote a little piece of code that could be triggered either manually or
automatically after an event, for example.</font>
        </p>
        <p class="MsoNormal" style="MARGIN: 0cm 0cm 10pt">
          <font color="#000000">As it could be also useful for you, here is the VBA code :
</font>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Scans all the Pivot tables contained in the file and refresh the data</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> RefreshPivotTables()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> aWorksheet <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Worksheet<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> aPivotTable <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> PivotTable<br /></span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   '
Find the pivot tables in all worksheets</span>
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   For</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Each</span> aWorksheet <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">In</span> Worksheets<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      '
If a worksheet contains more than one pivot table, refresh all of them</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      For</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Each</span> aPivotTable <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">In</span> aWorksheet.PivotTables<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">         '
Updates also the range of data to be sure that the pivot table uses all the data</span><br />
         ' <font color="#008000"><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">If</span> the
range of data never changes, it <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">is</span><span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">not</span> necessary <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">to</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">call</span> the <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sub</span> below.<br /></font>         RefreshPivotTableRange
aPivotTable<br />
         aPivotTable.PivotCache.Refresh<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">      Next</span> aPivotTable<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Next</span> aWorksheet<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'
Adapts a pivot table data range</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> RefreshPivotTableRange(aPivotTable <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> PivotTable)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">On</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Resume</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Next</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> newRange <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Range<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> WorksheetName <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">String</span><br /></span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            </span>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   '
Get the worksheet name</span>
            <br />
   WorksheetName <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Left</span>(aPivotTable.SourceData, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">InStr</span>(aPivotTable.SourceData, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"!"</span>) <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">-</span> 1)<br /><font color="#008000">   ' The GetDataRangeForWorksheet <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#008000">is</font></span> a <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#008000">sub</font></span> that
returns the <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#008000">new</font></span> range
of data <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><font color="#008000">in</font></span> the
given worksheet.<br /></font><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Set</span> newRange <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> GetDataRangeForWorksheet(Worksheets(WorksheetName))<br />
   aPivotTable.SourceData <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> WorksheetName
&amp; <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"!"</span> &amp;
newRange.Address(ReferenceStyle:=xlR1C1)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /></span>
        </p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8" />
      </body>
      <title>Automatically Refresh PivotTables in an Excel Workbook</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8.aspx</link>
      <pubDate>Thu, 25 Jan 2007 13:11:51 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;In this project, I had to work on an Excel file getting its data
from a database in order to generate a document usable for the end-user. The problem
was that a lot of pivot tables were included everywhere in the document making the
manual update of these tables really painful. So, my problem was to automate the process
of this update in order to refresh all the pivot tables in all the worksheets. In
finally wrote a little piece of code that could be triggered either manually or automatically
after an event, for example.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 10pt"&gt;
&lt;font color=#000000&gt;As it could be also useful for you, here is the VBA code :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Scans all the Pivot tables contained in the file and refresh the data&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; RefreshPivotTables()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; aWorksheet &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Worksheet&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; aPivotTable &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; PivotTable&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;'
Find the pivot tables in all worksheets&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Each&lt;/span&gt; aWorksheet &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;In&lt;/span&gt; Worksheets&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'
If a worksheet contains more than one pivot table, refresh all of them&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Each&lt;/span&gt; aPivotTable &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;In&lt;/span&gt; aWorksheet.PivotTables&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'
Updates also the range of data to be sure that the pivot table uses all the data&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;' &lt;font color=#008000&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;If&lt;/span&gt; the
range of data never changes, it &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;is&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;not&lt;/span&gt; necessary &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;to&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;call&lt;/span&gt; the &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sub&lt;/span&gt; below.&lt;br&gt;
&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;RefreshPivotTableRange
aPivotTable&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;aPivotTable.PivotCache.Refresh&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/span&gt; aPivotTable&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;/span&gt; aWorksheet&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'
Adapts a pivot table data range&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; RefreshPivotTableRange(aPivotTable &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; PivotTable)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;On&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Resume&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Next&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; newRange &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Range&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; WorksheetName &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;String&lt;/span&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;'
Get the worksheet name&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;WorksheetName &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Left&lt;/span&gt;(aPivotTable.SourceData, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;InStr&lt;/span&gt;(aPivotTable.SourceData, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"!"&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;-&lt;/span&gt; 1)&lt;br&gt;
&lt;font color=#008000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;'&amp;nbsp;The GetDataRangeForWorksheet &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#008000&gt;is&lt;/font&gt;&lt;/span&gt; a &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#008000&gt;sub&lt;/font&gt;&lt;/span&gt; that
returns the &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#008000&gt;new&lt;/font&gt;&lt;/span&gt; range
of data &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#008000&gt;in&lt;/font&gt;&lt;/span&gt; the
given worksheet.&lt;br&gt;
&lt;/font&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/span&gt; newRange &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; GetDataRangeForWorksheet(Worksheets(WorksheetName))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;aPivotTable.SourceData &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; WorksheetName
&amp;amp; &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"!"&lt;/span&gt; &amp;amp;
newRange.Address(ReferenceStyle:=xlR1C1)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;/p&gt;
&gt;&gt;&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,7d580a02-fdcd-4b1f-a4dd-dea57ca9e5d8.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
      <category>VBA</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=0e6766f6-446b-4d0c-89b5-dc284fbad104</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,0e6766f6-446b-4d0c-89b5-dc284fbad104.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,0e6766f6-446b-4d0c-89b5-dc284fbad104.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=0e6766f6-446b-4d0c-89b5-dc284fbad104</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Couple of days ago, writing an ASP page enabling users to download attachment generated
on the fly, I struggled a bit on a nice "Internet Explorer was not able to open this
Internet site. The requested site is either unavailable or cannot be found" error.
As I know that GIYVBF (for those of you who are wondering what it is stands for,
try <a href="http://www.google.ch/search?hl=fr&amp;q=GIYF&amp;meta="><font color="#334477">this</font></a>)
</p>
        <p>
          <br />
        </p>
        <p>
First, I checked several times that I used the <a href="http://support.microsoft.com/?kbid=317208"><font color="#334477">correct
caching expiration</font></a> and attachment settings without any success. Finally,
the only thing I did not find was this :
</p>
        <p>
          <br />
        </p>
        <p>
If, during the generation of your attachment, there is an non-handled error or exception,
the attachment genaration will abort and you will get this famous error message. Thus,
this is another way of getting the nice error box....In my case, there was some code
accessing a database and when it failed it displayed this message.
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=0e6766f6-446b-4d0c-89b5-dc284fbad104" />
      </body>
      <title>Another way to raise the "Internet Explorer was not able to open this Internet site" error</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,0e6766f6-446b-4d0c-89b5-dc284fbad104.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,0e6766f6-446b-4d0c-89b5-dc284fbad104.aspx</link>
      <pubDate>Mon, 27 Nov 2006 13:39:11 GMT</pubDate>
      <description>&lt;p&gt;
Couple of days ago, writing an ASP page enabling users to download attachment generated
on the fly, I struggled a bit on a nice "Internet Explorer was not able to open this
Internet site. The requested site is either unavailable or cannot be found" error.
As I know that GIYVBF (for those of you who are wondering&amp;nbsp;what it is stands for,
try &lt;a href="http://www.google.ch/search?hl=fr&amp;amp;q=GIYF&amp;amp;meta="&gt;&lt;font color=#334477&gt;this&lt;/font&gt;&lt;/a&gt;)
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
First, I checked several times that I used the &lt;a href="http://support.microsoft.com/?kbid=317208"&gt;&lt;font color=#334477&gt;correct
caching expiration&lt;/font&gt;&lt;/a&gt; and attachment settings without any success. Finally,
the only thing I did not find was this :
&lt;/p&gt;
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
If, during the generation of your attachment, there is an non-handled error or exception,
the attachment genaration will abort and you will get this famous error message. Thus,
this is another way of getting the nice error box....In my case, there was some code
accessing a database and when it failed it displayed this message.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=0e6766f6-446b-4d0c-89b5-dc284fbad104" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,0e6766f6-446b-4d0c-89b5-dc284fbad104.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=1e7eca96-c78c-41f5-8c7d-424caad83982</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,1e7eca96-c78c-41f5-8c7d-424caad83982.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,1e7eca96-c78c-41f5-8c7d-424caad83982.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=1e7eca96-c78c-41f5-8c7d-424caad83982</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I remember a discussion I had with a colleague about workflow engine developments
and moreover, about the real needs of starting such developments. But, the topic was
not only and not really about the development itself, but more about the existence
of such engines.
</p>
        <p>
Last June, <a href="http://www.gartner.com/">Gartner</a> published a <a href="http://www.gartner.com/DisplayDocument?id=493187">document</a> presenting
the major actors of BPM solutions. Among them, we can find <a href="http://www.k2workflow.com/default.aspx">K2</a> with
a coming product called <a href="http://www.k2workflow.com/default.aspx">K2.NET</a>,
based on the new <a href="http://wf.netfx3.com/">Windows Workflow Foundation</a> from <a href="http://www.microsoft.com">Microsoft</a>.
We can also find <a href="http://www.filenet.com">FileNet</a> which has been bought
by the giant <a href="http://www.ibm.com">IBM</a> in the meanwhile, but also Fuego
and last but not least, Microsoft with <a href="http://www.microsoft.com/biztalk/default.mspx">BizTalk
Server</a> 2006.
</p>
        <p>
Then, on one side we have ready-to-use products, proprietary and requesting customization,
and on the other side, Microsoft with the WF. Thus, the question that has come on
the table was : When to use the WF and when to use BTS ?<br />
Since this time, I tried to figure out the different criteria needed to help to decide.
But the list is absolutely not finished and I am sure that a lot of points could be
added.<br />
In fact, what needs to be understood is that the WF has never been designed to replace
BTS, not at all. In one case, we have a framework on top of which our application
has to be developed and which will be part of the developed application. In the second
case, it is a licensed product which needs a bit of understanding (I would say that
the learning curve is quite big...) to implement orchestrations between existing applications,
building the final solution. Nevertheless, these technologies are complementary.
</p>
        <p>
First, BTS comes with a lot of features and functionalities that are not necessary
needed for the majority of the applications.<br />
But, if your application needs to interact with one or more other applications, hosted
on different servers or using different technologies (such as Java, for example),
BTS is certainly an advantage. With this, BTS allows document transformations quite
easily, some of them or some of the file formats are already implemented or just need
the installation of an add-in (<a href="http://www.hl7.org/">HL7</a>, <a href="http://www.swift.com/">SWIFT</a> for
example).<br />
With BTS, it is also easy to know what is happening in the system using the BAM (Business
Activity Monitoring) and when you need to share credentials or authentication informations
between systems whether they are Windows or not, the use of SSO (Single Sign-On) is
a big plus over the WF.<br />
At the opposite, if the application has to contain the workflow, the use the WF. And
finally, if none of the BTS features is required, of course, then use of the WF is
quite obvious.
</p>
        <p>
Again, this list is not exhaustive and would need more points to add, but, in my opinion,
it is an interesting start when we think about using a workflow engine.
</p>
        <p>
Comments are welcome...
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=1e7eca96-c78c-41f5-8c7d-424caad83982" />
      </body>
      <title>How to decide between the use of Microsoft BizTalk Server and the Workflow Foundation ? A start</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,1e7eca96-c78c-41f5-8c7d-424caad83982.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,1e7eca96-c78c-41f5-8c7d-424caad83982.aspx</link>
      <pubDate>Mon, 20 Nov 2006 22:17:33 GMT</pubDate>
      <description>&lt;p&gt;
I remember a discussion I had with a colleague about workflow engine developments
and moreover, about the real needs of starting such developments. But, the topic was
not only and not really about the development itself, but more about the existence
of such engines.
&lt;/p&gt;
&lt;p&gt;
Last June, &lt;a href="http://www.gartner.com/"&gt;Gartner&lt;/a&gt; published a &lt;a href="http://www.gartner.com/DisplayDocument?id=493187"&gt;document&lt;/a&gt; presenting
the major actors of BPM solutions. Among them, we can find &lt;a href="http://www.k2workflow.com/default.aspx"&gt;K2&lt;/a&gt; with
a coming product called &lt;a href="http://www.k2workflow.com/default.aspx"&gt;K2.NET&lt;/a&gt;,
based on the new &lt;a href="http://wf.netfx3.com/"&gt;Windows Workflow Foundation&lt;/a&gt; from &lt;a href="http://www.microsoft.com"&gt;Microsoft&lt;/a&gt;.
We can also find &lt;a href="http://www.filenet.com"&gt;FileNet&lt;/a&gt; which has been bought
by the giant &lt;a href="http://www.ibm.com"&gt;IBM&lt;/a&gt; in the meanwhile, but also Fuego
and last but not least, Microsoft with &lt;a href="http://www.microsoft.com/biztalk/default.mspx"&gt;BizTalk
Server&lt;/a&gt; 2006.
&lt;/p&gt;
&lt;p&gt;
Then, on one side we have ready-to-use products, proprietary and requesting customization,
and on the other side, Microsoft with the WF. Thus, the question that has come on
the table was : When to use the WF and when to use BTS ?&lt;br&gt;
Since this time, I tried to figure out the different criteria needed to help to decide.
But the list is absolutely not finished and I am sure that a lot of points could be
added.&lt;br&gt;
In fact, what needs to be understood is that the WF has never been designed to replace
BTS, not at all. In one case, we have a framework on top of which our application
has to be developed and which will be part of the developed application. In the second
case, it is a licensed product which needs a bit of understanding (I would say that
the learning curve is quite big...) to implement orchestrations between existing applications,
building the final solution. Nevertheless, these technologies are complementary.
&lt;/p&gt;
&lt;p&gt;
First, BTS comes with a lot of features and functionalities that are not necessary
needed for the majority of the applications.&lt;br&gt;
But, if your application needs to interact with one or more other applications, hosted
on different servers or using different technologies (such as Java, for example),
BTS is certainly an advantage. With this, BTS allows document transformations quite
easily, some of them or some of the file formats are already implemented or just need
the installation of an add-in (&lt;a href="http://www.hl7.org/"&gt;HL7&lt;/a&gt;, &lt;a href="http://www.swift.com/"&gt;SWIFT&lt;/a&gt; for
example).&lt;br&gt;
With BTS, it is also easy to know what is happening in the system using the BAM (Business
Activity Monitoring) and when you need to share credentials or authentication informations
between systems whether they are Windows or not, the use of SSO (Single Sign-On) is
a big plus over the WF.&lt;br&gt;
At the opposite, if the application has to contain the workflow, the use the WF. And
finally, if none of the BTS features is required, of course, then use of the WF is
quite obvious.
&lt;/p&gt;
&lt;p&gt;
Again, this list is not exhaustive and would need more points to add, but, in my opinion,
it is an interesting start when we think about using a workflow engine.
&lt;/p&gt;
&lt;p&gt;
Comments are welcome...
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=1e7eca96-c78c-41f5-8c7d-424caad83982" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,1e7eca96-c78c-41f5-8c7d-424caad83982.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=d1bcad2f-b807-46fc-b540-e68772726528</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,d1bcad2f-b807-46fc-b540-e68772726528.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,d1bcad2f-b807-46fc-b540-e68772726528.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d1bcad2f-b807-46fc-b540-e68772726528</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The project I am currently working on involves a lot of Javascript code to validate
values entered by the users and to ensure that business rules are followed in complex
forms. Unfortunately, and as everyone knows, it is tough like the hell to develop
and debug Javascript code.
</p>
        <p>
However, I recently found an article talking about a tool that was just under my nose
and that I was not aware of. Here, I speak about the Microsoft Script Debugger. And,
in this, it is a real little pearl. Working with Visual Studio since long time, I
knew it was possible to debug Javascript code by attaching the Internet Explorer process,
but the files needed to be local. Otherwise it is impossible.
</p>
        <p>
But, the Microsoft Script Debugger tries to find all Internet Explorer sessions and,
by selecting the instance you want, it is then possible to do a "Break At Next Statement".
The next line which will be executed will switch you to the debugger window allowing
you to execute the application step by step. It is even possible to watch the values
held by the variables. You don't need to have the files locally and it allows you
to debug a production environment as well where it is not possible to access the source
code.
</p>
        <p>
Well I would not say I am going the best friend of Javascript, but at least, it makes
this task less tough. This application is in the Start menu, under Programs, Accessories,
Microsoft Script Debugger. With Windows 2000, if it is not there, it just need to
be installed from the Windows 2000 version, as a Windows component.
</p>
        <p>
For the other Windows versions, please follow this <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&amp;DisplayLang=en">link</a>.
</p>
        <p>
          <img alt="" hspace="0" src="http://www.peneveyre.com/blog/content/binary/MSDebug.jpg" align="baseline" border="0" />
        </p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d1bcad2f-b807-46fc-b540-e68772726528" />
      </body>
      <title>My New Toy</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,d1bcad2f-b807-46fc-b540-e68772726528.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,d1bcad2f-b807-46fc-b540-e68772726528.aspx</link>
      <pubDate>Tue, 26 Sep 2006 15:14:48 GMT</pubDate>
      <description>&lt;p&gt;
The project I am currently working on involves a lot of Javascript code to validate
values entered by the users and to ensure that business rules are followed in complex
forms. Unfortunately, and as everyone knows, it is tough like the hell to develop
and debug Javascript code.
&lt;/p&gt;
&lt;p&gt;
However, I recently found an article talking about a tool that was just under my nose
and that I was not aware of. Here, I speak about the Microsoft Script Debugger. And,
in this, it is a real little pearl. Working with Visual Studio since long time, I
knew it was possible to debug Javascript code by attaching the Internet Explorer process,
but the files needed to be local. Otherwise it is impossible.
&lt;/p&gt;
&lt;p&gt;
But, the Microsoft Script Debugger tries to find all Internet Explorer sessions and,
by selecting the instance you want, it is then possible to do a "Break At Next Statement".
The next line which will be executed will switch you to the debugger window allowing
you to execute the application step by step. It is even possible to watch the values
held by the variables. You don't need to have the files locally and it allows you
to debug a production environment as well where it is not possible to access the source
code.
&lt;/p&gt;
&lt;p&gt;
Well I would not say I am going the best friend of Javascript, but at least, it makes
this task less tough. This application is in the Start menu, under Programs, Accessories,
Microsoft Script Debugger. With Windows 2000, if it is not there, it just need to
be installed from the Windows 2000 version, as a Windows component.
&lt;/p&gt;
&lt;p&gt;
For the other Windows versions, please follow this &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2f465be0-94fd-4569-b3c4-dffdf19ccd99&amp;amp;DisplayLang=en"&gt;link&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;img alt="" hspace=0 src="http://www.peneveyre.com/blog/content/binary/MSDebug.jpg" align=baseline border=0&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d1bcad2f-b807-46fc-b540-e68772726528" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,d1bcad2f-b807-46fc-b540-e68772726528.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=5b70fe49-14a3-4771-8c48-c76332731475</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,5b70fe49-14a3-4771-8c48-c76332731475.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,5b70fe49-14a3-4771-8c48-c76332731475.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=5b70fe49-14a3-4771-8c48-c76332731475</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you are in the <a href="http://en.wikipedia.org/wiki/Service-oriented_architecture">SOA
(Service Oriented Architecture)</a> field, you should go to the <a href="http://www.zapthink.com/event.html?id=124">ZapThink's
5th SOA Practitioner's Conference</a> in Geneva, at the <a href="http://www.genevahotels.crowneplaza.com">Crowne
Plaza Hotel</a>.
</p>
        <p>
This event, sponsored by my <a href="http://www.ctp.com">Company</a>, amongst some
others, will held several interesting topics such as the basics of SOA (Fundamental
SOA Concepts) and real world application of SOA (Real implementation cases of SOA).
</p>
        <p>
Go there and have fun with SOA...
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=5b70fe49-14a3-4771-8c48-c76332731475" />
      </body>
      <title>(I Will) Be There !</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,5b70fe49-14a3-4771-8c48-c76332731475.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,5b70fe49-14a3-4771-8c48-c76332731475.aspx</link>
      <pubDate>Fri, 08 Sep 2006 08:02:54 GMT</pubDate>
      <description>&lt;p&gt;
If you are in the &lt;a href="http://en.wikipedia.org/wiki/Service-oriented_architecture"&gt;SOA
(Service Oriented Architecture)&lt;/a&gt; field, you should go to the &lt;a href="http://www.zapthink.com/event.html?id=124"&gt;ZapThink's
5th SOA Practitioner's Conference&lt;/a&gt; in Geneva, at the &lt;a href="http://www.genevahotels.crowneplaza.com"&gt;Crowne
Plaza Hotel&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
This event, sponsored by my &lt;a href="http://www.ctp.com"&gt;Company&lt;/a&gt;, amongst some
others, will held several interesting topics such as the basics of SOA (Fundamental
SOA Concepts) and real world application of SOA (Real implementation cases of SOA).
&lt;/p&gt;
&lt;p&gt;
Go there and have fun with SOA...
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=5b70fe49-14a3-4771-8c48-c76332731475" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,5b70fe49-14a3-4771-8c48-c76332731475.aspx</comments>
      <category>English</category>
      <category>Programming</category>
      <category>SOA</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=d7c74eb3-72b4-4883-93b9-057f49f81a77</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,d7c74eb3-72b4-4883-93b9-057f49f81a77.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,d7c74eb3-72b4-4883-93b9-057f49f81a77.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d7c74eb3-72b4-4883-93b9-057f49f81a77</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <font color="#000000">Currently developping a little application using the <a href="http://msdn2.microsoft.com">Framework
2.0</a> and the <a href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport(VS.80).aspx">System.IO.Ports.SerialPort</a> class,
I got this nice exception when trying to set the <a href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.stopbits(VS.80).aspx">StopBits</a> property
of my SerialPort instance to StopBits.None :</font>
        </p>
        <p>
          <img alt="" hspace="0" src="http://www.peneveyre.com/blog/content/binary/StopBitsException.jpg" align="baseline" border="0" />
        </p>
        <p>
Quite strange, isn't it ?
</p>
        <p>
Knowing that GIMF, nothing to read about this problem, or a little in the mono version
of .NET. So, I launched one of my favourite tool, <a href="http://www.aisto.com/roeder/dotnet/">Reflector</a>,
to see inside the System.dll (Version 2.0.0.0 in the Framework version v2.0.50727)
assembly. And here is the result when we look at the set_StopBits sub :
</p>
        <p>
          <img alt="" hspace="0" src="http://www.peneveyre.com/blog/content/binary/StopBitsSource.jpg" align="baseline" border="0" />
        </p>
        <p>
As we can see, before setting the property to the value passed in parameter, a little
check is done on its value. And if that value is less than StopBits.<strong>O</strong>ne,
it throws the ArgumentOutOfRangeException. Maybe the guy who wrote this code forgot
to add a "N" at the beginning of the enum value....
</p>
        <p>
Or, if it is what they really wanted to implement, nothing in the documentation is
telling it is forbidden to set the StopBits property to None.
</p>
        <p>
If anyone reading this post has an answer, I would appreciate at its own value and
I thank you for your comments....
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d7c74eb3-72b4-4883-93b9-057f49f81a77" />
      </body>
      <title>First bug in the .NET Framework 2.0 ??</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,d7c74eb3-72b4-4883-93b9-057f49f81a77.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,d7c74eb3-72b4-4883-93b9-057f49f81a77.aspx</link>
      <pubDate>Wed, 10 May 2006 21:18:14 GMT</pubDate>
      <description>&lt;p&gt;
&lt;font color=#000000&gt;Currently developping a little application using the &lt;a href="http://msdn2.microsoft.com"&gt;Framework
2.0&lt;/a&gt; and the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport(VS.80).aspx"&gt;System.IO.Ports.SerialPort&lt;/a&gt; class,
I got this nice exception when trying to set the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.io.ports.serialport.stopbits(VS.80).aspx"&gt;StopBits&lt;/a&gt; property
of my SerialPort instance to StopBits.None :&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;img alt="" hspace=0 src="http://www.peneveyre.com/blog/content/binary/StopBitsException.jpg" align=baseline border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Quite strange, isn't it ?
&lt;/p&gt;
&lt;p&gt;
Knowing that GIMF, nothing to read about this problem, or a little in the mono version
of .NET. So, I launched one of my favourite tool, &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;Reflector&lt;/a&gt;,
to see inside the System.dll (Version 2.0.0.0 in the Framework version v2.0.50727)
assembly. And here is the result when we look at the set_StopBits sub :
&lt;/p&gt;
&lt;p&gt;
&lt;img alt="" hspace=0 src="http://www.peneveyre.com/blog/content/binary/StopBitsSource.jpg" align=baseline border=0&gt;
&lt;/p&gt;
&lt;p&gt;
As we can see, before setting the property to the value passed in parameter, a little
check is done on its value. And if that value is less than StopBits.&lt;strong&gt;O&lt;/strong&gt;ne,
it throws the ArgumentOutOfRangeException. Maybe the guy who wrote this code forgot
to add a "N" at the beginning of the enum value....
&lt;/p&gt;
&lt;p&gt;
Or, if it is what they really wanted to implement, nothing in the documentation is
telling it is forbidden to set the StopBits property to None.
&lt;/p&gt;
&lt;p&gt;
If anyone reading this post has an answer, I would appreciate at its own value and
I thank you for your comments....
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d7c74eb3-72b4-4883-93b9-057f49f81a77" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,d7c74eb3-72b4-4883-93b9-057f49f81a77.aspx</comments>
      <category>English</category>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=8dbdbd8b-e95f-4dfa-ba26-21087adea771</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,8dbdbd8b-e95f-4dfa-ba26-21087adea771.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,8dbdbd8b-e95f-4dfa-ba26-21087adea771.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=8dbdbd8b-e95f-4dfa-ba26-21087adea771</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
C'est bon, j'ai reçu la confirmation de ma participation aux <a href="http://www.techdays.ch">TechDays
2006 </a>qui se tiendront les 5 et 6 avril à Genève.
</p>
        <p>
Au menu :
</p>
        <p>
Windows Vista, WinFX, Sharepoint et BizTalk Server 2006, entre autre.
</p>
        <p>
A mon avis, les conférences sur LINQ, Atlas/AJAX et Aero risquent d'être fort intéressante
</p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=8dbdbd8b-e95f-4dfa-ba26-21087adea771" />
      </body>
      <title>TechDays, j'y serai à nouveau</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,8dbdbd8b-e95f-4dfa-ba26-21087adea771.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,8dbdbd8b-e95f-4dfa-ba26-21087adea771.aspx</link>
      <pubDate>Thu, 09 Mar 2006 10:01:53 GMT</pubDate>
      <description>&lt;p&gt;
C'est bon, j'ai reçu la confirmation de ma participation aux &lt;a href="http://www.techdays.ch"&gt;TechDays
2006 &lt;/a&gt;qui se tiendront les 5 et 6 avril à Genève.
&lt;/p&gt;
&lt;p&gt;
Au menu :
&lt;/p&gt;
&lt;p&gt;
Windows Vista, WinFX, Sharepoint et BizTalk Server 2006, entre autre.
&lt;/p&gt;
&lt;p&gt;
A mon avis, les conférences sur LINQ, Atlas/AJAX et Aero risquent d'être fort intéressante
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=8dbdbd8b-e95f-4dfa-ba26-21087adea771" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,8dbdbd8b-e95f-4dfa-ba26-21087adea771.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=8047f50d-a905-4317-9d40-8a2ba2152024</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,8047f50d-a905-4317-9d40-8a2ba2152024.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,8047f50d-a905-4317-9d40-8a2ba2152024.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=8047f50d-a905-4317-9d40-8a2ba2152024</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Au détour d'une rencontre avec un guru du SQL, j'ai pu admirer le code suivant, permettant
d'effacer tous le doublon d'une table. Imaginons une table (aTable) avec une seule
colonne (aNumber), aucune clé, mais avec plusieurs lignes contenant la même valeur
:
</p>
        <p>
1<br />
1<br />
2<br />
1<br />
3<br />
3<br />
3<br />
1<br />
2<br />
1
</p>
        <p>
Le but est du supprimer tous les doublons, ceci en une seule requête. Vous avez la
réponse ?
</p>
        <p>
Voici le code SQL :
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">set</span> rowcount
1<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">select</span> 1<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">while</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@rowcount</span> &gt;
0<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">delete</span> test 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">where</span> 1
&lt; (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">select</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">count</span>(*) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">from</span> test
t2 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">where</span> test.id
= t2.id)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">set</span> rowcount
0<br /></span>
        </p>
        <p>
 
</p>
        <p>
 
</p>
        <p>
          <em>Some couple of weeks ago, I had the opportunity to meet SQL guru, and I have seen
a very nice SQL code, deleting duplicates rows in a table. Let's imagine a table (aTable)
with only one field (aNumber), without any key but multiple rows with the same value
:</em>
        </p>
        <p>
          <em>1<br />
1<br />
2<br />
1<br />
3<br />
3<br />
3<br />
1<br />
2<br />
1</em>
        </p>
        <p>
          <em>The goal is to delete duplicate values in only one SQL request. You have the answed
?</em>
        </p>
        <p>
          <em>Here is the code :</em>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">set</span> rowcount
1<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">select</span> 1<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">while</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@rowcount</span> &gt;
0<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">delete</span> test 
<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">where</span> 1
&lt; (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">select</span><span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">count</span>(*) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">from</span> test
t2 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">where</span> test.id
= t2.id)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">set</span> rowcount
0</span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
          </span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          </span>
        </p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=8047f50d-a905-4317-9d40-8a2ba2152024" />
      </body>
      <title>SQL Efficace - Efficient SQL</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,8047f50d-a905-4317-9d40-8a2ba2152024.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,8047f50d-a905-4317-9d40-8a2ba2152024.aspx</link>
      <pubDate>Fri, 29 Jul 2005 15:06:39 GMT</pubDate>
      <description>&lt;p&gt;
Au détour d'une rencontre avec un guru du SQL, j'ai pu admirer le code suivant, permettant
d'effacer tous le doublon d'une table. Imaginons une table (aTable) avec une seule
colonne (aNumber), aucune clé, mais avec plusieurs lignes contenant la même valeur
:
&lt;/p&gt;
&lt;p&gt;
1&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
1&lt;br&gt;
3&lt;br&gt;
3&lt;br&gt;
3&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
1
&lt;/p&gt;
&lt;p&gt;
Le but est du supprimer tous les doublons, ceci en une seule requête. Vous avez la
réponse ?
&lt;/p&gt;
&lt;p&gt;
Voici le code SQL :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;set&lt;/span&gt; rowcount
1&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;select&lt;/span&gt; 1&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;while&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@rowcount&lt;/span&gt; &amp;gt;
0&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;delete&lt;/span&gt; test 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;where&lt;/span&gt; 1
&amp;lt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;select&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;count&lt;/span&gt;(*) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;from&lt;/span&gt; test
t2 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;where&lt;/span&gt; test.id
= t2.id)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;set&lt;/span&gt; rowcount
0&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Some couple of weeks ago, I had the opportunity to meet SQL guru, and I have seen
a very nice SQL code, deleting duplicates rows in a table. Let's imagine a table (aTable)
with only one field (aNumber), without any key but multiple rows with the same value
:&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;1&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
1&lt;br&gt;
3&lt;br&gt;
3&lt;br&gt;
3&lt;br&gt;
1&lt;br&gt;
2&lt;br&gt;
1&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;The goal is to delete duplicate values in only one SQL request. You have the answed
?&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Here is the code :&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;set&lt;/span&gt; rowcount
1&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;select&lt;/span&gt; 1&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;while&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@rowcount&lt;/span&gt; &amp;gt;
0&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;delete&lt;/span&gt; test 
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;where&lt;/span&gt; 1
&amp;lt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;select&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;count&lt;/span&gt;(*) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;from&lt;/span&gt; test
t2 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;where&lt;/span&gt; test.id
= t2.id)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;set&lt;/span&gt; rowcount
0&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;/p&gt;
&gt;&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=8047f50d-a905-4317-9d40-8a2ba2152024" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,8047f50d-a905-4317-9d40-8a2ba2152024.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=d62b1d7a-5494-486d-a3f8-95378525befc</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,d62b1d7a-5494-486d-a3f8-95378525befc.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,d62b1d7a-5494-486d-a3f8-95378525befc.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d62b1d7a-5494-486d-a3f8-95378525befc</wfw:commentRss>
      <title>Comment détecter l'arrêt d'une orchestration - How to detect when an orchestration stops</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,d62b1d7a-5494-486d-a3f8-95378525befc.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,d62b1d7a-5494-486d-a3f8-95378525befc.aspx</link>
      <pubDate>Mon, 11 Jul 2005 12:34:22 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;&lt;font color=#000000&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;A
voir, BizTalk rencontre passablement de problèmes pour gérer les fichiers dont le
volume est important. Pourtant, malgré les efforts entrepris pour ré architecturer
l’application, il est parfois impossible de s’affranchir de ses OutOfMemoryException.
Dans le cas du projet actuel, le problème ne se passe que lorsque BizTalk doit traiter
plus d’un fichier en même temps. J’ai donc décidé, provisoirement, de ne soumettre
à BizTalk qu’un seul fichier à la fois, et attendre qu’il en ait terminé le traitement
avant d’en soumettre le suivant. Or, il me semble qu’il n’est pas possible d’être
averti lorsqu’une orchestration se termine, dans le framework .NET.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;&lt;font color=#000000&gt;La méthode que
j’ai trouvée passe par WMI. Ainsi, pour connaître quand une orchestration se termine&amp;nbsp;:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font face="Times New Roman" color=#000000&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; MountBTSOrchestrationMonitoring()&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//
Only one watch to mount, because we can only monitor orchestration deletion&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;WqlEventQuery q &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; WqlEventQuery(__InstanceDeletionEvent,&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new&lt;/span&gt; TimeSpan(0,0,0,10),&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"TargetInstance
isa \"MSBTS_ServiceInstance\""&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;m_btsWatcher &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementEventWatcher(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementScope(root/MicrosoftBizTalkServe),&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;q);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;m_btsWatcher.EventArrived += &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; EventArrivedEventHandler(bts_OrchestrationDeleted);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;m_btsWatcher.Start();&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; bts_OrchestrationDeleted(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArrivedEventArgs e)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//
Do something&lt;/span&gt;
&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;&lt;font color=#000000&gt;Ainsi,
lorsqu’une orchestration se terminera, l’événement bts_OrchestrationDeleted sera appelé.
Le seul petit problème, c’est qu’il n’est pas possible de connaître quelle orchestration
s’est terminée. Il faut alors interroger BizTalk, via WMI, à nouveau, pour savoir
si une instance de l’orchestration observée est encore active&amp;nbsp;:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font face="Times New Roman" color=#000000&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; OrchestrationInstanceCount(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; strOrchestrationName)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Text.StringBuilder sb &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; System.Text.StringBuilder(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SELECT
* FROM MSBTS_ServiceInstance WHERE ServiceName=\""&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;sb.Append(strOrchestrationName);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;sb.Append(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"\""&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;WqlObjectQuery w &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; WqlObjectQuery(sb.ToString());&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ManagementObjectSearcher objSearcher &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementObjectSearcher(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementScope(kstrWMIBTSNamespace),&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;w);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; objSearcher.Get().Count;&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;&lt;font color=#000000&gt;Si la
méthode retourne 0, aucune orchestration avec le nom donné en paramètre n’est active.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;&lt;font color=#000000&gt;Attention toute
fois&amp;nbsp;! BizTalk met un certain temps avant de mettre en route une orchestration,
faisant que même si un fichier est déposé dans un répertoire d’accueil de BizTalk,
la méthode risque de renvoyer la valeur 0, car l’orchestration n’aura pas encore démarré.
Il serait alors judicieux de voir si des fichiers sont encore présent dans le répertoire
d’accueil avant d’en poster de nouveaux.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;span lang=FR-CH style="mso-ansi-language: FR-CH"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;&lt;em&gt;According to a lot of blogs, BizTalk has some issues with
large files. However, despite of the efforts for rearchitecturing the application,
it is sometimes not possible to avoid the OutOfMemoryException.&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;&lt;em&gt;In the case of the actual project, that happens only when
BizTalk has to process more than one file at a time. So, I temporary decided to pass
to BizTalk only one file at a time and to wait the orchestration stops before copying
the next file to the receive location. But, it seems that it is not possible to be
warned when an orchestration stops with .NET.&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;&lt;em&gt;The way I found is using WMI. To know when an orchestration
stops, I install an event handler :&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;o:p&gt;
&lt;font color=#000000&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;o:p&gt;
&lt;font face=Arial color=#000000&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; MountBTSOrchestrationMonitoring()&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//
Only one watch to mount, because we can only monitor orchestration deletion&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;WqlEventQuery q &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; WqlEventQuery(__InstanceDeletionEvent,&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new&lt;/span&gt; TimeSpan(0,0,0,10),&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"TargetInstance
isa \"MSBTS_ServiceInstance\""&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;m_btsWatcher &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementEventWatcher(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementScope(root/MicrosoftBizTalkServe),&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;q);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;m_btsWatcher.EventArrived += &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; EventArrivedEventHandler(bts_OrchestrationDeleted);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;m_btsWatcher.Start();&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; bts_OrchestrationDeleted(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; sender,
EventArrivedEventArgs e)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//
Do something&lt;/span&gt;
&lt;br&gt;
}&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;/font&gt;
&lt;/o:p&gt;
&lt;font color=#000000&gt;&lt;em&gt;When an orchestration will stop, the bts_OrchestrationDeleted
event will be called. There is only one little issue. It is impossible to know which
orchestration stopped. We have to get the answer from BizTalk itself, through WMI
again, and getting the number of active instance with a given name :&lt;/em&gt;&lt;/font&gt;&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;&lt;/font&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; OrchestrationInstanceCount(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; strOrchestrationName)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Text.StringBuilder sb &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; System.Text.StringBuilder(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"SELECT
* FROM MSBTS_ServiceInstance WHERE ServiceName=\""&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;sb.Append(strOrchestrationName);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;sb.Append(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"\""&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;WqlObjectQuery w &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; WqlObjectQuery(sb.ToString());&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ManagementObjectSearcher objSearcher &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementObjectSearcher(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ManagementScope(kstrWMIBTSNamespace),&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;w);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&lt;/span&gt; objSearcher.Get().Count;&lt;br&gt;
}&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;&lt;em&gt;If the method returns 0, no orchestration with the given name
is still running.&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0cm 0cm 0pt"&gt;
&lt;font color=#000000&gt;&lt;em&gt;But, warning ! BizTalk needs a bit of time before starting
an orchestration and event a file is dropped in a BizTalk receive location, the method
will certainly return 0, because the orchestration is not yet started. It would be
a good idea to test is there are files in the receive location before dropping new
files.&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d62b1d7a-5494-486d-a3f8-95378525befc" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,d62b1d7a-5494-486d-a3f8-95378525befc.aspx</comments>
      <category>BTS2004</category>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=bd71eb1d-5791-41a7-ad8a-a15649752131</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,bd71eb1d-5791-41a7-ad8a-a15649752131.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,bd71eb1d-5791-41a7-ad8a-a15649752131.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=bd71eb1d-5791-41a7-ad8a-a15649752131</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Une fois un SQL-Server et un BizTalk Server 2004 installés, il est loin d'être trivial,
ensuite, de modifier le nom du serveur hébergeant ces services.
</p>
        <p>
Le service de Single Sign-On est d'ailleurs le plus embêtant à remettre sur ses pieds.
Le plus simple restant encore à rechercher les occurences de l'ancien nom du serveur
dans la base de registre et de les remplacer par le nouveau nom (en tout cas là où
cela est pertinent...).
</p>
        <p>
En revanche, l'exécution de l'outil de configuration de BTS2004 (ConfigFramework.exe)
va échouer sur la modification des jobs que BTS2004 installe dans SQL-Server. La cause
de l'erreur provient du fait que le serveur ayant généré ce job n'est plus le même
que celui qui essaye de le modifier. Pour éviter ceci, il est possible d'exécuter
la commande SQL suivante (dans le cas où il n'y aurait que des jobs BizTalk. Dans
le cas contraire, il faudra filtrer la requête) :
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">UPDATE</span> msdb.dbo.<span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sysjobs</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> originating_server
= <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@SERVERNAME</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span><br />
originating_server &lt;&gt; <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@SERVERNAME</span></span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" color="#000000" size="2">Ceci
à pour effet de changer le nom du serveur original du job.</font>
            </span>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" color="#000000" size="2">A
noter que changer le nom d'un serveur hébergeant déjà des services tels que BizTalk
n'est pas recommandé et ceci fait donc déjà partie des bidouilles...</font>
            </span>
          </span>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" color="#000000" size="2">
              </font>
            </span>
          </span> 
</p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <font face="Verdana" color="#000000" size="2">
              <p>
                <em>Once SQL-Server and BizTalk Server 2004 installed, it is very hard to
change the server name.</em>
              </p>
              <p>
                <em>The Single Sign-On is one of the most difficult to fix afterward. The way I found
is to search-and-replace all occurences of the old server name by the new one in the
registry.</em>
              </p>
              <p>
                <em>On the other hand, running the BTS2004 configuration tool (ConfigFramework.exe)
will fail on the update of the BTS2004 SQL jobs. The root cause of this is that the
server which generated these jobs is not the same as the one attempting to update
them. To avoid this, it is possible to run the following SQL command (in the case
of all jobs are Biztalk jobs. If not, you have to add a filter to your request) :</em>
              </p>
              <p>
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">UPDATE</span> msdb.dbo.<span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">sysjobs</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SET</span> originating_server
= <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@SERVERNAME</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">WHERE</span><br />
originating_server &lt;&gt; <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">@@SERVERNAME</span></span>
              </p>
              <p>
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                    <font face="Verdana" color="#000000" size="2">
                      <em>This
will change all originating server of all jobs.</em>
                    </font>
                  </span>
                </span>
              </p>
              <p>
                <em>
                  <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                    <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                      <font face="Verdana" color="#000000" size="2">Please
notice that to change the server name hosting services like SQL-Server or BizTalk
is absolutely not a recommended way...</font>
                    </span>
                  </span>
                  <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                    <span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                      <font face="Verdana" color="#000000" size="2">
                      </font>
                    </span>
                  </span>
                </em>
              </p>
            </font>
          </span>
        </span>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=bd71eb1d-5791-41a7-ad8a-a15649752131" />
      </body>
      <title>Changer le nom du serveur hébergeant un serveur BizTalk - Changing the name of a BizTalk host server</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,bd71eb1d-5791-41a7-ad8a-a15649752131.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,bd71eb1d-5791-41a7-ad8a-a15649752131.aspx</link>
      <pubDate>Mon, 04 Jul 2005 13:54:29 GMT</pubDate>
      <description>&lt;p&gt;
Une fois un SQL-Server et un BizTalk Server 2004 installés, il est loin d'être trivial,
ensuite, de modifier le nom du serveur hébergeant ces services.
&lt;/p&gt;
&lt;p&gt;
Le service de Single Sign-On est d'ailleurs le plus embêtant à remettre sur ses pieds.
Le plus simple restant encore à rechercher les occurences de l'ancien nom du serveur
dans la base de registre et de les remplacer par le nouveau nom (en tout cas là où
cela est pertinent...).
&lt;/p&gt;
&lt;p&gt;
En revanche, l'exécution de&amp;nbsp;l'outil de configuration de BTS2004 (ConfigFramework.exe)
va échouer sur la modification des jobs que BTS2004 installe dans SQL-Server. La cause
de l'erreur provient du fait que le serveur ayant généré ce job n'est plus le même
que celui qui essaye de le modifier. Pour éviter ceci, il est possible d'exécuter
la commande SQL suivante (dans le cas où il n'y aurait que des jobs BizTalk. Dans
le cas contraire, il faudra filtrer la requête) :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;UPDATE&lt;/span&gt; msdb.dbo.&lt;span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sysjobs&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; originating_server
= &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@SERVERNAME&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt;
&lt;br&gt;
originating_server &amp;lt;&amp;gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@SERVERNAME&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt;Ceci
à pour effet de changer le nom du serveur original du job.&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt;A
noter que changer le nom d'un serveur hébergeant déjà des services tels que BizTalk
n'est pas recommandé et ceci fait donc déjà partie des bidouilles...&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt; 
&lt;p&gt;
&lt;em&gt;Once&amp;nbsp;SQL-Server and&amp;nbsp;BizTalk Server 2004 installed, it is very hard to
change the server name.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;The Single Sign-On is one of the most difficult to fix afterward. The way I found
is to search-and-replace all occurences of the old server name by the new one in the
registry.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;On the other hand, running the BTS2004 configuration tool (ConfigFramework.exe)
will fail on the update of the BTS2004 SQL jobs. The root cause of this is that the
server which generated these jobs is not the same as the one attempting to update
them. To avoid this, it is possible to run the following SQL command (in the case
of all jobs are Biztalk jobs. If not, you have to add a filter to your request) :&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;UPDATE&lt;/span&gt; msdb.dbo.&lt;span style="FONT-SIZE: 11px; COLOR: lawngreen; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;sysjobs&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SET&lt;/span&gt; originating_server
= &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@SERVERNAME&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;WHERE&lt;/span&gt;
&lt;br&gt;
originating_server &amp;lt;&amp;gt; &lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;@@SERVERNAME&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt;&lt;em&gt;This
will change all originating server of all jobs.&lt;/em&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt;Please
notice that to change the server name hosting services like SQL-Server or BizTalk
is absolutely not a recommended way...&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: fuchsia; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana color=#000000 size=2&gt;&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/em&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=bd71eb1d-5791-41a7-ad8a-a15649752131" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,bd71eb1d-5791-41a7-ad8a-a15649752131.aspx</comments>
      <category>BTS2004</category>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=c5ae58c3-879c-4683-88c7-b4271bd46206</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,c5ae58c3-879c-4683-88c7-b4271bd46206.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,c5ae58c3-879c-4683-88c7-b4271bd46206.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=c5ae58c3-879c-4683-88c7-b4271bd46206</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ecrire un composant COM en .NET est relativement simple, pour peu que l'on n'essaie
pas de faire des spécialités.<br />
Il y a néanmoins quelques petites choses à se remémorer si l'on veut éviter de perdre
un temps précieux, et une de celles-ci concerne les tableaux. Imaginons que nous voulions
écrire un composant COM en .NET, utilisable depuis le code VBA d'une feuille Excel.
Le code pourrait être :
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> mySub<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> myArray() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Double</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   ReDim</span> myArray(1 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">to</span> 10) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Double</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> comObject <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> myCOMObject<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   for</span> i <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">to</span> 10<br />
      myArray(i) <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> i<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   next</span> i<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Set</span> comObject <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> myCOMObject<br /><br />
   myCOMObject.MyMethod(myArray)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Set</span> comObject <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span></span>
        </p>
        <p>
Si vous exécutez ce code, une exception sera levée :<br /><em>System.IndexOutOfRangeException: Index was outside the bounds of the array</em>.
</p>
        <p>
Ce qu'il faut savoir, c'est que sauf sur mention explicite avec la clause <em>Option
Base</em>, les tableaux VBA sont indexés à partir de 0. Or, dans notre cas où l'on
veut redéfinir la taille du tableau myArray, il faut se veiller à ne pas indiquer
la borne inférieure, et ainsi la laisser à 0.<br />
Du côté du composant COM, les valeurs sont bien entendus disponible à partir de l'indice
1. Ne pas essayer de lire les valeurs à l'indice 0 :
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Double
[] myLocalArray <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Double[myReceivedArray.GetLength(0)];<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> i <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1;
i &lt;= 10; i++)<br />
{<br />
   myLocalArray[i] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> myReceivedArray[i];<br />
}</span>
        </p>
        <p>
          <em>Writing a .NET COM component is fairly simple. As far as we do not try to do specialties.
There are come little tricks to remember before spending lot of time. One of them
is the arrays. Let's write a .NET COM component that should be used from a VBA code
of an Excel sheet. The code could be :</em>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> mySub<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> myArray() <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Double</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   ReDim</span> myArray(1 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">to</span> 10) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">as</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Double</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Dim</span> comObject <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> myCOMObject<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   for</span> i <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1 <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">to</span> 10<br />
      myArray(i) <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> i<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   next</span> i<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Set</span> comObject <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> myCOMObject<br /><br />
   myCOMObject.MyMethod(myArray)<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   Set</span> comObject <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span></span>
        </p>
        <p>
          <em>If you run this code, an exception will raise :<br /><u>System.IndexOutOfRangeException: Index was outside the bounds of the array</u>.</em>
        </p>
        <p>
          <em>What is important to know about is that VB defines arrays using a 0-based indexes
unless you specify the Option Base clause. In that case, I redefined the myArray size,
but I had to not specify the lower-bound, letting that bound to 0.<br />
On the COM component side, values are available only from the second cell (index equal
to 1). Do not try to read the cell with index 0 :</em>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Double
[] myLocalArray <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> Double[myReceivedArray.GetLength(0)];<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">for</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> i <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 1;
i &lt;= 10; i++)<br />
{<br />
   myLocalArray[i] <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> myReceivedArray[i];<br />
}</span>
        </p>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=c5ae58c3-879c-4683-88c7-b4271bd46206" />
      </body>
      <title>Petite histoire d'interopérabilité. A Little Interoperability Story</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,c5ae58c3-879c-4683-88c7-b4271bd46206.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,c5ae58c3-879c-4683-88c7-b4271bd46206.aspx</link>
      <pubDate>Tue, 17 May 2005 15:39:25 GMT</pubDate>
      <description>&lt;p&gt;
Ecrire un composant COM en .NET est relativement simple, pour peu que l'on n'essaie
pas de faire des spécialités.&lt;br&gt;
Il y a néanmoins quelques petites choses à se remémorer si l'on veut éviter de perdre
un temps précieux, et une de celles-ci concerne les tableaux. Imaginons que nous voulions
écrire un composant COM en .NET, utilisable depuis le code VBA d'une feuille Excel.
Le code pourrait être :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; mySub&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; myArray() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Double&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ReDim&lt;/span&gt; myArray(1 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;to&lt;/span&gt; 10) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Double&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; comObject &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; myCOMObject&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&lt;/span&gt; i &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;to&lt;/span&gt; 10&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myArray(i) &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; i&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;next&lt;/span&gt; i&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/span&gt; comObject &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; myCOMObject&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;myCOMObject.MyMethod(myArray)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/span&gt; comObject &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Si vous exécutez ce code, une exception sera levée :&lt;br&gt;
&lt;em&gt;System.IndexOutOfRangeException: Index was outside the bounds of the array&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
Ce qu'il faut savoir, c'est que sauf sur mention explicite avec la clause &lt;em&gt;Option
Base&lt;/em&gt;, les tableaux VBA sont indexés à partir de 0. Or, dans notre cas où l'on
veut redéfinir la taille du tableau myArray, il faut se veiller à ne pas indiquer
la borne inférieure, et ainsi la laisser à 0.&lt;br&gt;
Du côté du composant COM, les valeurs sont bien entendus disponible à partir de l'indice
1. Ne pas essayer de lire les valeurs à l'indice 0 :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Double
[] myLocalArray &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Double[myReceivedArray.GetLength(0)];&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; i &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1;
i &amp;lt;= 10; i++)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;myLocalArray[i] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; myReceivedArray[i];&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Writing a .NET COM component is fairly simple. As far as we do not try to do specialties.
There are come little tricks to remember before spending lot of time. One of them
is the arrays. Let's write a .NET COM component that should be used from a VBA code
of an Excel sheet. The code could be :&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; mySub&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; myArray() &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Double&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;ReDim&lt;/span&gt; myArray(1 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;to&lt;/span&gt; 10) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;as&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Double&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim&lt;/span&gt; comObject &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; myCOMObject&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;for&lt;/span&gt; i &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1 &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;to&lt;/span&gt; 10&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;myArray(i) &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; i&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;next&lt;/span&gt; i&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/span&gt; comObject &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; myCOMObject&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;myCOMObject.MyMethod(myArray)&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;Set&lt;/span&gt; comObject &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;If you run this code, an exception will raise :&lt;br&gt;
&lt;u&gt;System.IndexOutOfRangeException: Index was outside the bounds of the array&lt;/u&gt;.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;What is important to know about is that VB defines arrays using a 0-based indexes
unless you specify the Option Base clause. In that case, I redefined the myArray size,
but I had to not specify the lower-bound, letting that bound to 0.&lt;br&gt;
On the COM component side, values are available only from the second cell (index equal
to 1). Do not try to read the cell with index 0 :&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Double
[] myLocalArray &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; Double[myReceivedArray.GetLength(0)];&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;for&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; i &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 1;
i &amp;lt;= 10; i++)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;myLocalArray[i] &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; myReceivedArray[i];&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=c5ae58c3-879c-4683-88c7-b4271bd46206" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,c5ae58c3-879c-4683-88c7-b4271bd46206.aspx</comments>
      <category>Programming</category>
      <category>Technical</category>
    </item>
    <item>
      <trackback:ping>http://www.peneveyre.com/blog/Trackback.aspx?guid=d2d313a7-8caa-4172-90ba-17a9bcd5d2a1</trackback:ping>
      <pingback:server>http://www.peneveyre.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.peneveyre.com/blog/PermaLink,guid,d2d313a7-8caa-4172-90ba-17a9bcd5d2a1.aspx</pingback:target>
      <dc:creator>Yves Peneveyre</dc:creator>
      <wfw:comment>http://www.peneveyre.com/blog/CommentView,guid,d2d313a7-8caa-4172-90ba-17a9bcd5d2a1.aspx</wfw:comment>
      <wfw:commentRss>http://www.peneveyre.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=d2d313a7-8caa-4172-90ba-17a9bcd5d2a1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Travaillant actuellement pour un client désirant utiliser un composant .NET depuis
Office 2000, il a donc fallu s'attaquer à COM Interop. Et, bien que la documentation
le dise, il est possible d'avoir quelques surprises lorsqu'il s'agit de gérer les
exceptions et les erreurs COM.
</p>
        <p>
Prenons donc le code suivant :
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[ComVisible(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> myMethod()<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// snip</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> myException(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Description"</span>,
2500);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// snip</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// Do something here</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
return</span> 0;<br />
}</span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
              <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> myException
: ApplicationException<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// COM Error base number is 0x80040000</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> kCOMErrorBaseNumber <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">unchecked</span>((<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span>)
0x80040000);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
public</span> myException() : <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">base</span>(){}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
public</span> myException(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> strMessage, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> ErrorCode)
: <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">base</span>(strMessage)<br />
  {<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   
// HResult = kCOMErrorBaseNumber + ErrorCode);</span><br />
    HResult <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ErrorCode);<br />
  }<br />
}</span>
          </p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" size="2">Du
côté client, par exemple sous Excel, en ajoutant la bonne référence sur notre composant
COM écrit en .NET, écrivons le code suivant :</font>
            </span>
          </p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> Test()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
On</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GoTo</span> err_handling<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
Dim</span> a <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> myDotNetComponent<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
Dim</span> b <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Long</span><br />
  b <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> a.myMethod()<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
' Do something</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
Exit</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br />
err_handling:<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
MsgBox</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Err</span>.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Number</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span></span>
            </p>
          </span>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" size="2">Le
seul moyen de fixer le numéro d'erreur qui sera retourné au client COM est de
le faire dans le constructeur de l'exception, comme on peut le voir dans le code du
composant COM. Si on exécute le code VB, aucune erreur ne sera retournée. Le code
situé sous l'étiquette err_handling n'est pas exécuté. Surprise, non ?</font>
            </span>
          </p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" size="2">L'explication
se trouve dans la <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/error_5g6r.asp">documentation
Microsoft</a>. On peut y lire qu'un code d'erreur HRESULT doit avoir son bit de poids
fort mis à 1 pour que ce soit considéré pour une erreur. Ainsi donc, même si une exception
est levée dans le composant COM .NET et qu'elle est propagée au-delà vers le code
client, si le code HRESULT affecté n'est pas correct, on risque de passer à côté d'un
tel problème. Il est possible de corriger cela en ajoutant la valeur 0x80000000 à
notre code d'erreur pour que cela fonctionne. Pour être plus sûr de ne pas entrer
en collision avec des code existants, j'ai ajouté la valeur 0x80040000.</font>
            </span>
          </p>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <font face="Verdana" size="2">
              </font>
            </span> 
</p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <p>
              <font face="Verdana" size="2">
                <em>Actually working for a customer which would like
to use a .NET component from an Office 2000 application, I had to work with COM Interop.
And, even the documentation understandable, it is possible to have some surprises
when managing and handling exceptions and COM errors.</em>
              </font>
            </p>
            <p>
              <font face="Verdana" size="2">
                <em>So, take the following code :</em>
              </font>
            </p>
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">[ComVisible(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>)]<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> myMethod()<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// snip</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> myException(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Description"</span>,
2500);<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// snip</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// Do something here</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
return</span> 0;<br />
}</span>
            </p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <p>
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span>
                  <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> myException
: ApplicationException<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
// COM Error base number is 0x80040000</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">const</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> kCOMErrorBaseNumber <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">unchecked</span>((<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span>)
0x80040000);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
public</span> myException() : <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">base</span>(){}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
public</span> myException(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> strMessage, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> ErrorCode)
: <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">base</span>(strMessage)<br />
  {<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">   
// HResult = kCOMErrorBaseNumber + ErrorCode);</span><br />
    HResult <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ErrorCode);<br />
  }<br />
}</span>
              </p>
              <p>
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <font face="Verdana" size="2">
                    <em>On
the client side, for exemple from Excel, adding the right reference to our .NET written
COM component, write the following code :</em>
                  </font>
                </span>
              </p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <p>
                  <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> Test()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
On</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Error</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">GoTo</span> err_handling<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
Dim</span> a <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> myDotNetComponent<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
Dim</span> b <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Long</span><br />
  b <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> a.myMethod()<br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
' Do something</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
Exit</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br />
err_handling:<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"> 
MsgBox</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Err</span>.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Number</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span></span>
                </p>
              </span>
              <p>
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <font face="Verdana" size="2">
                    <em>The
only way to set the error code that will be returned to the COM client is to do that
in the exception constructor as we can see it in the COM component code. If we run
the VB code, no error will be returned and the err_handling labelled code will not
be run. Surprising isn't it ?</em>
                  </font>
                </span>
              </p>
              <p>
                <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <font face="Verdana" size="2">
                    <em>The
explanation can be found in the </em>
                    <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/error_5g6r.asp">
                      <em>Microsoft
documentation</em>
                    </a>
                    <em>. We can read that an HRESULT error code must have its high-order
bit must be set to 1 to be considered as en error. So, even en exception is raised
in the .NET COM component and bubbled to the client code, if the HRESULT code
is not correctly set, we can miss an error. It is possible to change that adding a
0x80000000 value to our error code. But, to be sure that we are not colliding with
existing error codes, I added the value 0x80040000.</em>
                  </font>
                </span>
              </p>
            </span>
          </span>
        </span>
        <img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d2d313a7-8caa-4172-90ba-17a9bcd5d2a1" />
      </body>
      <title>Composant COM en .NET et HRESULT. .NET COM component and HRESULT</title>
      <guid isPermaLink="false">http://www.peneveyre.com/blog/PermaLink,guid,d2d313a7-8caa-4172-90ba-17a9bcd5d2a1.aspx</guid>
      <link>http://www.peneveyre.com/blog/PermaLink,guid,d2d313a7-8caa-4172-90ba-17a9bcd5d2a1.aspx</link>
      <pubDate>Thu, 31 Mar 2005 07:13:53 GMT</pubDate>
      <description>&lt;p&gt;
Travaillant actuellement pour un client désirant utiliser un composant .NET depuis
Office 2000, il a donc fallu s'attaquer à COM Interop. Et, bien que la documentation
le dise, il est possible d'avoir quelques surprises lorsqu'il s'agit de gérer les
exceptions et les erreurs COM.
&lt;/p&gt;
&lt;p&gt;
Prenons donc le code suivant :
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[ComVisible(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; myMethod()&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// snip&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; myException(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Description"&lt;/span&gt;,
2500);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// snip&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// Do something here&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
return&lt;/span&gt; 0;&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; myException
: ApplicationException&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// COM Error base number is 0x80040000&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; kCOMErrorBaseNumber &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;unchecked&lt;/span&gt;((&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt;)
0x80040000);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
public&lt;/span&gt; myException() : &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;base&lt;/span&gt;(){}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
public&lt;/span&gt; myException(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; strMessage, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; ErrorCode)
: &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;base&lt;/span&gt;(strMessage)&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
// HResult = kCOMErrorBaseNumber + ErrorCode);&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; HResult &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; ErrorCode);&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;Du
côté client, par exemple sous Excel, en ajoutant la bonne référence sur notre composant
COM écrit en .NET, écrivons le code suivant :&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; Test()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
On&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GoTo&lt;/span&gt; err_handling&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
Dim&lt;/span&gt; a &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; myDotNetComponent&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
Dim&lt;/span&gt; b &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Long&lt;/span&gt;
&lt;br&gt;
&amp;nbsp; b &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; a.myMethod()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
' Do something&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
Exit&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
err_handling:&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
MsgBox&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Err&lt;/span&gt;.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Number&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/span&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;Le
seul moyen de fixer le numéro d'erreur&amp;nbsp;qui sera retourné au client COM est de
le faire dans le constructeur de l'exception, comme on peut le voir dans le code du
composant COM. Si on exécute le code VB, aucune erreur ne sera retournée. Le code
situé sous l'étiquette err_handling n'est pas exécuté. Surprise, non ?&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;L'explication
se trouve dans la &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/error_5g6r.asp"&gt;documentation
Microsoft&lt;/a&gt;. On peut y lire qu'un code d'erreur HRESULT doit avoir son bit de poids
fort mis à 1 pour que ce soit considéré pour une erreur. Ainsi donc, même si une exception
est levée dans le composant COM .NET et qu'elle est propagée au-delà vers le code
client, si le code HRESULT affecté n'est pas correct, on risque de passer à côté d'un
tel problème. Il est possible de corriger cela en ajoutant la valeur 0x80000000 à
notre code d'erreur pour que cela fonctionne. Pour être plus sûr de ne pas entrer
en collision avec des code existants, j'ai ajouté la valeur 0x80040000.&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;&lt;/font&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;font face=Verdana size=2&gt;&lt;em&gt;Actually working for a customer which would like to
use a .NET component from an Office 2000 application, I had to work with COM Interop.
And, even the documentation understandable, it is possible to have some surprises
when managing and handling exceptions and COM errors.&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Verdana size=2&gt;&lt;em&gt;So, take the following code :&lt;/em&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;[ComVisible(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;)]&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; myMethod()&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// snip&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; myException(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Description"&lt;/span&gt;,
2500);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// snip&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// Do something here&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
return&lt;/span&gt; 0;&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; myException
: ApplicationException&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
// COM Error base number is 0x80040000&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;const&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; kCOMErrorBaseNumber &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;unchecked&lt;/span&gt;((&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt;)
0x80040000);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
public&lt;/span&gt; myException() : &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;base&lt;/span&gt;(){}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
public&lt;/span&gt; myException(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; strMessage, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; ErrorCode)
: &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;base&lt;/span&gt;(strMessage)&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
// HResult = kCOMErrorBaseNumber + ErrorCode);&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; HResult &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; ErrorCode);&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;&lt;em&gt;On
the client side, for exemple from Excel, adding the right reference to our .NET written
COM component, write the following code :&lt;/em&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; Test()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
On&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Error&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;GoTo&lt;/span&gt; err_handling&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
Dim&lt;/span&gt; a &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; myDotNetComponent&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
Dim&lt;/span&gt; b &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Long&lt;/span&gt;
&lt;br&gt;
&amp;nbsp; b &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; a.myMethod()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
' Do something&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
Exit&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
err_handling:&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;
MsgBox&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Err&lt;/span&gt;.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Number&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/span&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;&lt;em&gt;The
only way to set the error code that will be returned to the COM client is to do that
in the exception constructor as we can see it in the COM component code. If we run
the VB code, no error will be returned and the err_handling labelled code will not
be run. Surprising isn't it ?&lt;/em&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;&lt;em&gt;The
explanation can be found in the &lt;/em&gt;&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/htm/error_5g6r.asp"&gt;&lt;em&gt;Microsoft
documentation&lt;/em&gt;&lt;/a&gt;&lt;em&gt;. We can read that an HRESULT error code must have its high-order
bit must be set to 1 to be considered as en error. So, even en exception is raised
in the .NET COM component and bubbled&amp;nbsp;to the client code, if the HRESULT code
is not correctly set, we can miss an error. It is possible to change that adding a
0x80000000 value to our error code. But, to be sure that we are not colliding with
existing error codes, I added the value 0x80040000.&lt;/em&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/span&gt;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;img width="0" height="0" src="http://www.peneveyre.com/blog/aggbug.ashx?id=d2d313a7-8caa-4172-90ba-17a9bcd5d2a1" /&gt;</description>
      <comments>http://www.peneveyre.com/blog/CommentView,guid,d2d313a7-8caa-4172-90ba-17a9bcd5d2a1.aspx</comments>
      <category>Technical</category>
      <category>Programming</category>
    </item>
  </channel>
</rss>