Friday, June 4, 2010

Migrating custom assemblies to SharePoint 2010

style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">Introduction


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Migrating
to SharePoint 2010 requires several operations, you have to upgrade your
existing SharePoint Farm at least with SharePoint SP2 if you attempt to perform
an attach database migration and maybe move your Farms to support 64-bit if
you have chosen an In place migration. Afterwards, you have to deal
with  redeploying customizations and solutions in SharePoint 2010.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Although
customizations for SharePoint come in many forms (Site templates , Site
definition, Feature, Workflows and server controls, Event handler, Web Parts,
Master pages and CSS files, etc.) I would like to focus now on the compiled
code.
There were many questions I have read on Forums and Blogs about "Do we
have to recompile or rewrite the code for a migration to SharePoint
2010 ?".


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">Architects,
Developers, System Administrators benefits (the "why" part of the post)


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">This
post will try to explain some important concepts to know when preparing to
migrate your SharePoint custom dll to SharePoint 2010. We will examine:


    style="MARGIN-TOP: 5px; FONT-FAMILY: arial; MARGIN-BOTTOM: 5px; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal">
  • The different platform available in Visual Studio
    build configuration and their impact on the migration
  • The x86 emulator WOW64 and its use with IIS 7 ie for both ASP .Net and
    SharePoint 2010
  • The tools you could use to facilitate the dll migration to SharePoint
    2010

style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">I
will illustrate all these points by testing the migration of a custom Web
Part to SharePoint 2010. 


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">1 -The different
target platforms available in Visual Studio build configuration


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">I
have prepared the Web Part component to migrate to SharePoint 2010 within Visual
Studio 2008 and before to focus on the code let us examine the different options
we have to compile it regarding the target platform.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">here
is the screenshot of Visual Studio 2008 showing three available options
regarding target platform after having configured Visual Studio with the
Configuration Manager, and the created corresponding debug folders. (I have
omited Itanium on purpose because it is just a variation for a 64-bit
platform).


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">You
notice that the present configuration offers three options:


    style="MARGIN-TOP: 5px; FONT-FAMILY: arial; MARGIN-BOTTOM: 5px; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal">
  1. X86: The package can be installed on any 32-bit platform; when installing
    to a 64-bit platform, files are installed to 32-bit folders.

  2. x64: The package is for machines supporting the AMD64 and EM64T
    instruction sets; when attempting to install to a 32-bit platform or any other
    64-bit platform, an error is raised and installation is halted.

  3. Any CPU: compiles your assembly to run on any platform. It is the default
    option

style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">sources
: TargetPlatform
Property
, href="http://msdn.microsoft.com/en-us/library/zekwfyz4(VS.80).aspx">Output
Platform


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Conclusion,
there is just ONE limitation : you cannot run a 64-bit package on a 32-bit
platform but in our case we could imagine to build our component for any target
platform and be allowed to deploy it for SharePoint 2010.
We will see later
that it is actually true for a standard ASP .Net Web Site, but that we can
use ONLY x64 and Any CPU option for SharePoint 2010, and I will clearly
demonstrate and explain why.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">But,
first of all, let us compile our component and examine the ways of knowing what
is its target platform afterward.


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">2
- How to know the target platform of an .Net assembly (managed code dll)

style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 26px; COLOR: #e9ab17; FONT-WEIGHT: normal; PADDING-TOP: 10px">Dll
deployed in the Global Assembly Cache 


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Assume
I have signed my assembly to deploy it in the Global Assembly Cache. If I open
the Global Assembly Cache repository, I notice that the deployed Web Part was
compiled for targeting 32-bit architecture, and that most of the other dll were
compiled using the "Any CPU" option because they have the attribute "MSIL".


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">But
what if the dll is not deployed in the GAC, and I want to know if it was
compiled using te x86,  x64 or Any CPU option?


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 26px; COLOR: #e9ab17; FONT-WEIGHT: normal; PADDING-TOP: 10px">Dll
deployed in the standard folders

style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">You
have two solutions:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">-
ILDASM utility


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">you
can run the ILDASM utility provided in the .NET Framework SDK and located
at:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">C:\Program
Files\Microsoft SDKs\Windows\v6.0A\Bin


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Run
the utility and open the dll file you want to check.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Then
you have to do 2 operations.
First double click the manifest and check
information after the "corflags" label.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Second
click the Header item in the View menu


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">And
in the headers locate the label PE Optional Header


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">

style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now,
if we map these two information to the target platform:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">For
a dll compiled with Any CPU you will have :


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">.corflags
0x00000009 // ILONLY
 ----- PE Optional Header (32-bit):


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">For
a dll compiled with x86 you will have :


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">.corflags
0x0000000b    //  ILONLY 32BITREQUIRED
 ----- PE
Optional Header (32-bit):


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">For
a dll compiled with x64 you will have :

face=Arial>

style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">.corflags
0x00000009    //  ILONLY
 ----- PE Optional Header
(64-bit):


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">The
corflags is also a name for a Visual Sutdio tool that can give us all the
information in one place. This is our second solution to check the compilation
mode without dropping the dll in the GAC.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">-
corflags utility


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Open
the a Visual Studio command promt.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">then
call the corflags.exe and pass it the dll as a parameter. (tip: you can drag and
drop the dll in the command prompt windows)


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">





style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">So,
now check the following parameters: PE and 32BIT


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">For
a dll compiled with Any CPU you will have :


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">
PE : PE32


32BIT : 0


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">For
a dll compiled with x86 you will have :


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">
PE : PE32


32BIT : 1


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">For
a dll compiled with x64 you will have :


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">
PE : PE32+


32BIT : 0




style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 26px; COLOR: #e9ab17; FONT-WEIGHT: normal; PADDING-TOP: 10px">Getting
the information from the running dll!


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now,
maybe you are thinking, it would be great to execute the dll and that it gives
us this information. That way, I can have all my SharePoint webparts telling me
their target platform. And furthermore, if the Web Part could also tell me the
process used, I could migrate my webparts to a 64-bit platform or straight to
SharePoint 2010 step by step and know the migration status for each webpart at
each step of my migration.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">That
is exactly what we are doing now, and as you notice, I have named my Web Part
IsRunningon64-bit, and this Web part is aimed to give us this information and
its target platform. So here is the code.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Runtime.InteropServices;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Web.UI;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Web.UI.WebControls;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Web.UI.WebControls.WebParts;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Xml.Serialization;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
Microsoft.SharePoint;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
Microsoft.SharePoint.WebControls;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
Microsoft.SharePoint.WebPartPages;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Diagnostics;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.ComponentModel;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
System.Reflection;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">namespacestyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">
IsRunningOn64bit


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">    [style="COLOR: #2b91af">Guid(style="COLOR: #a31515">"5aa223b6-fd04-48c1-83e6-9531bf45ee08")]


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue">public class style="COLOR: #2b91af">GetInformation :
System.Web.UI.WebControls.WebParts.style="COLOR: #2b91af">WebPart


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">    {style="mso-spacerun: yes">     


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
string _message = style="COLOR: blue">string.Empty;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
//This will fail under Win2000 and WinXP SP1
and earlier.


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
//You need to check if the IsWow64Process()
function exists before you call it,


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
//because it was only introduced in XP SP2 and
Vista/Win7


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
[DllImport(style="COLOR: #a31515">"kernel32.dll", SetLastError = style="COLOR: blue">true, CallingConvention = style="COLOR: #2b91af">CallingConvention.Winapi)]


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
[return: style="COLOR: #2b91af">MarshalAs(style="COLOR: #2b91af">UnmanagedType.Bool)]


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
public style="COLOR: blue">static extern style="COLOR: blue">bool IsWow64Process([style="COLOR: #2b91af">In] IntPtr
hProcess, [Out] style="COLOR: blue">out bool
lpSystemInfo);


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
private style="COLOR: blue">string ProcessSize()


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
switch (style="COLOR: #2b91af">IntPtr.Size)


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
case 4:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"running on 32-bit";


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
case 8:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"running on 64-bit";


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
default:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"unknown";


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
private style="COLOR: blue">string Wow64Using()


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
bool retVal;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
IsWow64Process(style="COLOR: #2b91af">Process.GetCurrentProcess().Handle, style="COLOR: blue">out retVal);


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
if (retVal)


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
return style="COLOR: #a31515">"using WOW64";


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
else


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
return "NOT
using WOW64"
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
public style="COLOR: blue">string Message


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
get


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
System.Reflection.style="COLOR: #2b91af">PortableExecutableKinds
PeKinds;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
System.Reflection.ImageFileMachine
ImFileMach;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
Assembly myAssembly = style="COLOR: #2b91af">Assembly.GetExecutingAssembly();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
myAssembly.ManifestModule.GetPEKind(out
PeKinds, out ImFileMach);


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
string strPeKinds = style="COLOR: blue">string.Empty;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
string strImFileMach = style="COLOR: blue">string.Empty;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
switch (PeKinds)


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.ILOnly:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strPeKinds = PeKinds + ": The executable
contains only Microsoft intermediate language (MSIL), and is therefore neutral
with respect to 32-bit or 64-bit platforms. (compiled with Any CPU
option)"
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">    style="mso-spacerun: yes">                style="COLOR: blue">case style="COLOR: #2b91af">PortableExecutableKinds.NotAPortableExecutableImage:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strPeKinds = PeKinds + ": The file is not in
portable executable (PE) file format."
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.PE32Plus:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strPeKinds = PeKinds.ToString() + "The
executable requires a 64-bit platform. (compiled with x64
option)"
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.Required32Bit:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strPeKinds = PeKinds + "The executable can
be run on a 32-bit platform, or in the 32-bit Windows on Windows (WOW)
environment on a 64-bit platform."
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.Unmanaged32Bit:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strPeKinds = PeKinds + "The executable
contains pure unmanaged code."
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
default:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strPeKinds = PeKinds.ToString();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
switch
(ImFileMach)


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">ImageFileMachine.AMD64:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strImFileMach = ImFileMach + ": Targets a
64-bit AMD processor."
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">        
style="mso-spacerun: yes">           style="COLOR: blue">case style="COLOR: #2b91af">ImageFileMachine.I386:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strImFileMach = ImFileMach + ": Targets a
32-bit Intel processor."
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">ImageFileMachine.IA64:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strImFileMach = ImFileMach + ": Targets a
64-bit Intel processor."
;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                   
default:


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
strImFileMach = ImFileMach.ToString();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">                       
break;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
_message += "<br>" +
myAssembly.FullName;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
_message += "<br>" +
strPeKinds;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
_message += "<br>" +
strImFileMach;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
_message += "<br>" +
ProcessSize();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
_message += "<br>" +
Wow64Using();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">               
return _message;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
protected style="COLOR: blue">override void
CreateChildControls()


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
{


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
style="COLOR: blue">base.CreateChildControls();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
Label label = style="COLOR: blue">new style="COLOR: #2b91af">Label();


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
string message = style="COLOR: #a31515">"";


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
SPWeb myWeb = style="COLOR: #2b91af">SPContext.Current.Web;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
message += "Web Site Title: " +
myWeb.Title;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
message += style="COLOR: blue">this.Message;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
label.Text = message;


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">           
style="COLOR: blue">this.Controls.Add(label);


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">       
}


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> 


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">style="mso-spacerun: yes">    }


class=MsoNormal align=left>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}


face=Calibri> 


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">And
here is the result:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">As
you notice, the Web Part is telling us that it is running on a 32-bit process
and that it was targeting for a 32-bit architecture. But what is WOW64 and how
to know if the server where the Web part is running has a 32-bit or 64-bit
architecture? That is we will explain now before migrating to a 64-bit server.


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">3
- The x86 emulator WOW64


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">As
we found in Microsoft documentation, href="http://msdn.microsoft.com/en-us/library/aa384249(VS.85).aspx">WOW64 is
the x86 emulator that allows 32-bit Windows-based applications to run seamlessly
on 64-bit Windows. WOW64 is provided with the operating system and does not have
to be explicitly enabled. For more information, see href="http://msdn.microsoft.com/en-us/library/aa384274(v=VS.85).aspx">color=#1364c4>WOW64 Implementation Details.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">That
is to mean, WOW64 is a part of the 64-bit OS that allows dll targeted to 32-bit
platform to run "as if" they were on a 32-bit OS.  WOW64 for "Windows on
Windows 64" or we could say "Windows 32-bit on Windows 64-bit". Thus, if a dll
targeted to a 32-bit platform  is running on a 64-bit machine and that we
check the process it will be indicate 32-bit!
So, how to know the real
architecture of the machine while looking at the running 32-bit assembly?


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">The
other good point is that we are allowed to use managed code to ask WOW64 if it
is in use for the running process. This is the way to know if you are on a 64
bit system when running a 32-bit dll. If this dll is using the WOW64, that means
it is running on a 64-bit machine. So in the previous screen shot, we were on a
32-bit machine.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now,
I would like to come back to the previous excerpt of the Microsoft documentation
and focus to the following sentence : "...does not have to be explicitly
enabled..."  Hum, it is not totally exact as we are going to see with IIS
7.


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">4
- WOW64 and IIS7


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 26px; COLOR: #e9ab17; FONT-WEIGHT: normal; PADDING-TOP: 10px">4.1
mounting a test solution and using WOW64


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">OK,
now, we are going to leave the previous 32-bit machine where I took the previous
screen shot, and going to a brand new Windows server 2008  R2 64-bit
wiht IIS 7 activated on it.
We are not going to run the Web Part in
SharePoint 2010 now, but I would like to take the code of this Web Part and
place it in a standard class component (not a control server for ASP .Net) but
will use it in an ASP .Net web site.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">So,
assume we call the component CustomCode and the class RunSomething. We are going
to create a solution in Visual Studio 2010 and add a C# Class library
project for the Custom Code Component and a Web Site to test it.
Then, we
will add an .aspx page in the web site to test our component, let us call it:
testComponent.aspx 
Here is the Visual Studio 2010 explorer view of the
solution where you can see:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">1-
The CustomCode component dll
2- The testComponent.aspx page that will load
it
3- The RunSomthing Class
4- The folders created by the Configuration
manager of Visual Studio corresponding to the target platforms.
5- The
Configuration Manager Dialog with the configuration  corresponding to the
target platforms.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px"> Here
is the code of the class:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Collections.Generic;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Linq;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Text;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Runtime.InteropServices;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Diagnostics;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.ComponentModel;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Reflection;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">usingstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">
System.Security;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Security.Policy;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>using
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> System.Security.Permissions;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>//using System.Runtime.ExceptionServices;
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>namespace
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> CustomCode


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>    style="COLOR: blue">public class style="COLOR: #2b91af">RunSomething


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>   
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
string _message = style="COLOR: blue">string.Empty;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
//This will fail under Win2000 and WinXP SP1
and earlier.


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>      
 style="COLOR: green">//You need to check if the IsWow64Process() function exists
before you call it,


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
//because it was only introduced in XP SP2 and
Vista/Win7


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
[DllImport(style="COLOR: #a31515">"kernel32.dll", SetLastError = style="COLOR: blue">true, CallingConvention = style="COLOR: #2b91af">CallingConvention.Winapi)]


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>     style="mso-spacerun: yes">   [style="COLOR: blue">return: style="COLOR: #2b91af">MarshalAs(style="COLOR: #2b91af">UnmanagedType.Bool)]


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
public style="COLOR: blue">static extern style="COLOR: blue">bool IsWow64Process([style="COLOR: #2b91af">In] IntPtr
hProcess, [Out] style="COLOR: blue">out bool
lpSystemInfo);


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
private style="COLOR: blue">string ProcessSize()


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
switch (style="COLOR: #2b91af">IntPtr.Size)


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
case style="COLOR: brown">4:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"running on 32-bit";


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
case style="COLOR: brown">8:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"running on 64-bit";


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
default:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"unknown";


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
private style="COLOR: blue">string Wow64Using()


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>    style="mso-spacerun: yes">    {


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
bool retVal;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
IsWow64Process(style="COLOR: #2b91af">Process.GetCurrentProcess().Handle, style="COLOR: blue">out retVal);


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
if (retVal)


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
return style="COLOR: #a31515">"using WOW64";


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
else


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
return "NOT
using WOW64"
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
public style="COLOR: blue">string Message


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
get


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">           
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
System.Reflection.style="COLOR: #2b91af">PortableExecutableKinds
PeKinds;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
System.Reflection.ImageFileMachine
ImFileMach;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
Assembly myAssembly = style="COLOR: #2b91af">Assembly.GetExecutingAssembly();


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
myAssembly.ManifestModule.GetPEKind(out
PeKinds, out ImFileMach);


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
string strPeKinds = style="COLOR: blue">string.Empty;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
string strImFileMach = style="COLOR: blue">string.Empty;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">            
   
style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">switchstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">
(PeKinds)


class=MsoNormal>style="mso-spacerun: yes">               
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.ILOnly:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strPeKinds = PeKinds + ": The executable
contains only Microsoft intermediate language (MSIL), and is therefore neutral
with respect to 32-bit or 64-bit platforms. (compiled with Any CPU
option)"
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.NotAPortableExecutableImage:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strPeKinds = PeKinds + ": The file is not in
portable executable (PE) file format."
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.PE32Plus:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strPeKinds = PeKinds.ToString() + "The
executable requires a 64-bit platform. (compiled with x64
option)"
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">            
style="mso-spacerun: yes">           style="COLOR: blue">break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.Required32Bit:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strPeKinds = PeKinds + "The executable can
be run on a 32-bit platform, or in the 32-bit Windows on Windows (WOW)
environment on a 64-bit platform."
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">PortableExecutableKinds.Unmanaged32Bit:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strPeKinds = PeKinds + "The executable
contains pure unmanaged code."
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
default:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strPeKinds = PeKinds.ToString();


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
switch
(ImFileMach)


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">ImageFileMachine.AMD64:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strImFileMach = ImFileMach + ": Targets a
64-bit AMD processor."
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">ImageFileMachine.I386:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strImFileMach = ImFileMach + ": Targets a
32-bit Intel processor."
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
case style="COLOR: #2b91af">ImageFileMachine.IA64:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strImFileMach = ImFileMach + ": Targets a
64-bit Intel processor."
;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                   
default:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
strImFileMach = ImFileMach.ToString();


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">                       
break;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
_message += "<br>" +
myAssembly.FullName;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
_message += "<br>" +
strPeKinds;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
_message += "<br>" +
strImFileMach;


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
_message += "<br>" +
ProcessSize();


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
_message += "<br>" +
Wow64Using();


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">               
style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">returnstyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">
_message;


class=MsoNormal>style="mso-spacerun: yes">           
}


class=MsoNormal>style="mso-spacerun: yes">       
}


class=MsoNormal>style="mso-spacerun: yes">    }


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> 


face=Calibri> 


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px"> and
here is the code of the testComponent.aspx page:


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; FONT-SIZE: 9pt; mso-highlight: yellow"><%style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">@style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> style="COLOR: maroon">Page Languagestyle="COLOR: blue">="C#" style="BACKGROUND: yellow; mso-highlight: yellow">%>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; FONT-SIZE: 9pt; mso-highlight: yellow"><%style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">@style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> style="COLOR: maroon">Import style="COLOR: red">Namespacestyle="COLOR: blue">="CustomCode" style="BACKGROUND: yellow; mso-highlight: yellow">%>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt"><!style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt">doctypestyle="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt"> style="COLOR: red">html public style="COLOR: blue">"-//w3c//dtd xhtml 1.0 transitional//en" style="COLOR: blue">"http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US><
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>script
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> runatstyle="COLOR: blue">="server">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US></
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>script
style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>>
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US><
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>html
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> xmlnsstyle="COLOR: blue">="http://www.w3.org/1999/xhtml">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US><
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>head
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> runatstyle="COLOR: blue">="server">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>    style="COLOR: blue"><titlestyle="COLOR: blue">>Testing a Componentstyle="COLOR: blue"></titlestyle="COLOR: blue">>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US></
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>head
style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>>
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US><
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>body
style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>>
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US><
style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>script
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> runatstyle="COLOR: blue">="server">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US> 


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>    style="COLOR: blue">public void
Page_load(object sender, style="COLOR: #2b91af">EventArgs e)


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>   
{


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
RunSomething myProcess = style="COLOR: blue">new style="COLOR: #2b91af">RunSomething();


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>style="mso-spacerun: yes">       
Response.Write("<br>testing the
following: "
+ myProcess.Message);


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-ansi-language: EN-US"
lang=EN-US>   
style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">}


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt"></style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt">scriptstyle="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt"></style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt">bodystyle="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">>style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt">


class=MsoNormal>style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt"></style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 9pt">htmlstyle="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt">>


face=Calibri> 


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px"> And
now, if we compile the component so that it is targeted to 32-bit architecture,
then, call the page from Visual Studio we obtain this:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px"> Now,
as we are on a 64-bit machine, and we are calling a component compiled for
targeting a 32-bit system the WOW64 emulator is called.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">But,
if we recompile it for both architecture now, using Any CPU option we will
obtain this screen:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">





style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Well,
but you might wondering, as we compiled for both architecture and we are on a 64
bit system, why it is still running using 32-bit within WOW64?
This is
because there is at the present no 64-bit version of Visual Studio.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">The
proof of it? Compile now for a 64-bit target platform an try to call the .aspx
page:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">You
get the


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Could
not load file or assembly xxxxxxxxx or one of its dependencies. An attempt was
made to load a program with an incorrect format.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Exception
associated with a BadImageFormatException that means a 32-bit process tried
to load a 64-bit component (our case) or vice versa.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">
OK,
but what if we want to test it using 64-bit?
We have to deploy the solution
in a real IIS 7 web site. That is what we are going to do now.


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 26px; COLOR: #e9ab17; FONT-WEIGHT: normal; PADDING-TOP: 10px">4.2
Testing in a real IIS 7 web site


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">OK,
let us mount a IIS 7 web site for this solution and deploy it. Here is the IIS
7 MMC view after having done it:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">You
can see:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">1-
the IIS Site (I made the mistake to create a sub apllication)
2- its
application pool



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now
try to call a dll compiled for targeting a 32-bit plaform. (you have to compile
the component in Visual Studio with x86 configuration and paste the
dll in the IIS 7 web site BIN folder)


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Then
you obtain the same BadImageFormatException, but this time, it is because a 64
bit process try to load a 32-bit assembly.
Hum, but where is WOW64 in this
case?
That is the point : WOW64 in IIS 7 NEEDS to be activated.
Let
us summarize. WOW64 allows 32-bit components to run on 64-bit system,
but not a 64-bit process to load a 32 bit component in its process.
When you are using WOW64 all must be running on 32-bit.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">By
default IIS 7 uses a 64-bit process on the 64-bit machine and if you want to use
WOW64 to emulate a 32-bit internet site on a 64-bit computer, you have to change
a configuration in the IIS 7 application pool advanced settings. So let us do
it now.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Display
the IIS 7 Application Pools and click on "Advanced Settings" on the right menu.

On the opening dialog set "Enable 32-bit Applications" to true.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now
the previous page will display properly and show that our IIS 7 web site is
using a 32-bit process emulated on a 64-bit machine by WOW64 and that the page
has loaded a component targeted to 32-bit plaform only.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now,
let the WOW64 activated and this time try a component compiled with any CPU
option.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">As
in Visual Studio before, it is running on a 32-bit process using WOW64.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">But,
if we change the IIS 7 configuration for a 64-bit process...


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">The
same page and the same component are now running on a 64-bit process and of
course, WOW64 is not used anymore.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Last,
let us show the same page with a component targeted for a 64-bit platform.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 26px; COLOR: #e9ab17; FONT-WEIGHT: normal; PADDING-TOP: 10px">4.3
To Sumarize


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">The
question is: when to use WOW64 within IIS 7 and when not to use?


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">As
the default option of IIS 7 in the matter is to not to use it, you can take
benefit of the 64-bit while letting your components compiled with the Any CPU
option so that they can be used within all the servers of your company
without worrying about the servers system architecture.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">However,
I would like to point out a major concern not discussed at all until now:


A major migration issue concerns 32-bit software components which cannot be migrated, perhaps because the source code is lost or one of the dependencies cannot be migrated.



Although a 64-bit process cannot load a 32-bit module into its process space there is a way of
accessing 32-bit DLLs from 64-bit code , but it is not easy.

Thus, if you have a web application to deploy on a 64-bit machine and
it uses or is planed to use that kind of 32-bit code that cannot be migrated, consider setting "Enable 32-bit
Applications" to true.






Anyway, that option is only available for standard ASP .Net web sites, for SharePoint 2010, as we are going to see now, you have not the choice...


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">5
- Migrating assemblies to SharePoint 2010


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Well,
we can now go back to the main topic of the post, the migration of custom
dll to SharePoint 2010.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">First
off all, never forget: "you CANNOT enable 32-bit applications within a SharePoint 2010 Web
Application". When you try to do it by changing this configuration in the
advanced settings of a SharePoint 2010 Application Pool the
Application Pool service just STOPS.

Why?

Because SharePoint 2010 MUST run
on 64-bit, since a part of the new features of the product are targeted to
a 64-bit platform. And as we have seen before, if at least one dll of an
application is targeted to 64-bit the all application needs to run using 64
bit.




That is the reason why, when building code for SharePoint 2010, we can ONLY use x64 and Any CPU option.


That is the other reason why, you can only deploy SharePoint 2010 on a 64-bit computer.




If we want to check which are the SharePoint 2010 components
targeted to 64-bit, we can look in the Global Assembly Cache.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">





style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">So,
it seems to have only the Sandbox, the whole Search and the part linked to
Office involved...maybe the part requiring the most memory space.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Now
is the time to compile the previous Web Part with the only two allowed options and to test it in SharePoint 2010.


For the Any CPU version


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">and
the x64 version


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">By
the way, I tried to compile the Web Part using x64 configuration on my 32-bit
machine and could not deploy it in SharePoint 2010. I had for succeeding to
build it on my 64-bit machine.
I had another weird behaviour for another Web
Part.
It was built using Any CPU option on my 32-bit machine and ran perfectly
well on SharePoint 2010. When I tried to recompile it with Visual Studio 2010 to
check if there was obsolete classes used within the code, the Web Part stopped
working because there was a call to the SPWeb object inside the Web Part
Constructor.
However the same code with the call inside the constructor is
working perfectly in SharePoint 2010 with the version built on my 32-bit MOSS
2007 machine.
I will try to update this post with warnings about the
migration of custom code to SharePoint 2010 if I encounter another issues.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">This
is a good transition to conclude and give some direction about migrating the
custom assemblies to SharePoint 2010.


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">6 -
Conclusion


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">I
would like to refer to 2 Microsoft documentation posts that give the "philosophy" to
have in mind when approaching the concern of the custom code migration to
SharePoint 2010.



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">href="http://technet.microsoft.com/en-ca/library/dd622865(office.12).aspx">Migrate
an existing server farm to a 64-bit environment (Office SharePoint Server
2007)


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">[...


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">You
must recompile existing 32-bit applications and custom assemblies (for example,
Web Parts and event receivers) to run on the 64-bit architecture because the
64-bit edition of SharePoint cannot load a 32-bit assembly. Before you recompile
existing applications or custom assemblies, verify that they are compiled to run
on both architectures. If this is the case, do not compile them for a single
architecture. (In Microsoft Visual Studio this build option is AnyCPU.)


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">If
the existing applications are third-party applications, check with the
third-party vendor regarding 64-bit versions and compatibility. In the case of
custom contracted solutions for which you do not have the source, verify the
solutions in a test 64-bit environment to ensure compatibility.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">...]



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">href="http://technet.microsoft.com/en-us/library/ee662217.aspx">Redeploying
Customizations and Solutions in SharePoint Foundation 2010 and SharePoint Server
2010


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Because
the changes to the API in the upgrades are backward compatible, you should not
have to make any changes to your Windows SharePoint Services 3.0 or Office
SharePoint Server 2007 custom solutions before you redeploy them in either
SharePoint Foundation 2010 or SharePoint Server 2010. Some classes and
namespaces are obsolete, but they will continue to work as expected. If you want
to start upgrading your applications so that they use the most current classes
and methods, recompile your code. The compiler warnings will tell you which
elements of the object model are obsolete, and which newer alternatives you
should use. Figure 3 shows an example compiler warning and the corresponding
mouse-over warning in Visual Studio 2010.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Reading
that, the philosophy may be:


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">you
can migrate a dll compiled for SharePoint 2007 using "Any CPU" option on a
SharePoint 2010 server and it will work, but you should try to
recompile it with the new object model to optimize your code.
You
must recompile the dll compiled with the x86 option.


style="PADDING-BOTTOM: 10px; MARGIN: 1px 0px; PADDING-LEFT: 13px; PADDING-RIGHT: 0px; COLOR: #e9ab17; FONT-WEIGHT: bold; PADDING-TOP: 10px">7
- Aknowledgements and useful links


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Thanks
to Paul A. Jungwirth
for his post Sorting Out
the Confusion: 32- vs. 64-Bit, CLR vs. Native, C# vs. C++
 


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Thanks
to Chris Crowe for his post href="http://blog.crowe.co.nz/archive/2007/11/05/Could-not-load-file-or-assembly-name-or-one-of.aspx">Could
not load file or assembly 'Name' or one of its dependencies. An attempt was made
to load a program with an incorrect format.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 31px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">Thanks
to all people having participated to this forum thread: href="http://stackoverflow.com/questions/336633/how-to-detect-windows-64-bit-platform-with-net">How
to detect Windows 64-bit platform with .net?


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">to
go further...


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">href="http://msdn.microsoft.com/en-us/library/ms973190.aspx">Migrating 32-bit
Managed Code to 64-bit



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">href="http://www.dnjonline.com/article.aspx?ID=jun07_access3264"> Accessing 32-bit DLLs from 64-bit code



style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">href="http://jameskovacs.com/2008/04/25/keyboard-jedi-on-vista-x64/">
Use ILDASM.exe to force an application compiled to MSIL (Any CPU) to run on the 32-bit CLR of a 64-bit machine




style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">By the way, regarding unmanaged code, here is a SharePoint 2007 application page that allows to check the target platform of an unmanaged dll.


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Page Languagestyle="COLOR: blue">="C#" style="COLOR: red">AutoEventWireupstyle="COLOR: blue">="true" style="BACKGROUND: yellow; mso-highlight: yellow">%>o ns = "urn:schemas-microsoft-com:office:office" />


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Register style="COLOR: red">TagPrefixstyle="COLOR: blue">="SharePoint" style="COLOR: red">Namespacestyle="COLOR: blue">="Microsoft.SharePoint.WebControls"


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: red">Assemblystyle="COLOR: blue">="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c"
style="BACKGROUND: yellow; mso-highlight: yellow">%>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Register style="COLOR: red">TagPrefix="Utilities"
Namespacestyle="COLOR: blue">="Microsoft.SharePoint.Utilities" style="COLOR: red">Assemblystyle="COLOR: blue">="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c"
style="BACKGROUND: yellow; mso-highlight: yellow">%>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Import style="COLOR: red">Namespacestyle="COLOR: blue">="Microsoft.SharePoint" style="BACKGROUND: yellow; mso-highlight: yellow">%>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Import style="COLOR: red">Namespacestyle="COLOR: blue">="Microsoft.SharePoint.ApplicationPages" style="BACKGROUND: yellow; mso-highlight: yellow">%>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Import style="COLOR: red">Namespacestyle="COLOR: blue">="System.Data" style="BACKGROUND: yellow; mso-highlight: yellow">%>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; BACKGROUND: yellow; FONT-FAMILY: 'Courier New'; mso-highlight: yellow; mso-no-proof: yes"><%style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">@style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: #a31515">Import style="COLOR: red">Namespace="System.IO"
style="BACKGROUND: yellow; mso-highlight: yellow">%>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">htmlstyle="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> style="COLOR: red">xmlnsstyle="COLOR: blue">="http://www.w3.org/1999/xhtml">


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">headstyle="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><titlestyle="COLOR: blue">></style="COLOR: #a31515">titlestyle="COLOR: blue">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"></style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">headstyle="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"><style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">bodystyle="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><script style="COLOR: red">runatstyle="COLOR: blue">="server">


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
public style="COLOR: blue">enum MachineType
: ushort


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
{


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_UNKNOWN = 0x0,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_AM33 = 0x1d3,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_AMD64 = 0x8664,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_ARM = 0x1c0,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_EBC = 0xebc,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_I386 = 0x14c,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_IA64 = 0x200,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_M32R = 0x9041,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_MIPS16 = 0x266,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_MIPSFPU = 0x366,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_POWERPC = 0x1f0,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_POWERPCFP = 0x1f1,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_R4000 = 0x166,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_SH3 = 0x1a2,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_SH3DSP = 0x1a3,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_SH4 = 0x1a6,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_SH5 = 0x1a8,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_THUMB = 0x1c2,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169,


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
}


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
void CheckConfig(style="COLOR: blue">object sender, style="COLOR: #2b91af">EventArgs e)


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
{


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
lblresult.Text = "dll config is: " +
UnmanagedDllIs64Bit(txtFilePath.Text);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
}


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
public style="COLOR: #2b91af">MachineType GetDllMachineType(style="COLOR: blue">string dllPath)


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
{


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
//see
http://download.microsoft.com/download/9/c/5/


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
//style="mso-spacerun: yes">            
9c5b2167-8017-4bae-9fde-d599bac8184a/pecoff_v8.doc


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
//offset to PE header is always at 0x3C


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
//PE header starts with "PE\0\0" =style="mso-spacerun: yes">  0x50 0x45 0x00 0x00


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
//followed by 2-byte machine type field (see
document above for enum)


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
FileStream fs = style="COLOR: blue">new style="COLOR: #2b91af">FileStream(dllPath, style="COLOR: #2b91af">FileMode.Open);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
BinaryReader br = style="COLOR: blue">new style="COLOR: #2b91af">BinaryReader(fs);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
fs.Seek(0x3c, style="COLOR: #2b91af">SeekOrigin.Begin);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
Int32 peOffset =
br.ReadInt32();


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
fs.Seek(peOffset, style="COLOR: #2b91af">SeekOrigin.Begin);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
UInt32 peHead =
br.ReadUInt32();


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
if (peHead != 0x00004550) style="COLOR: green">// "PE\0\0", little-endian


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">               
throw style="COLOR: blue">new style="COLOR: #2b91af">Exception("Can't find
PE header"
);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
MachineType machineType = (style="COLOR: #2b91af">MachineType)br.ReadUInt16();


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
br.Close();


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
fs.Close();


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
return
machineType;


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
}


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
// returns true if the dll is 64-bit, false if
32-bit, and null if unknown


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
public style="COLOR: blue">string UnmanagedDllIs64Bit(style="COLOR: blue">string dllPath)


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">       
{


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
MachineType machineType =
GetDllMachineType(dllPath);


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
switch
(machineType)


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
{


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">               
case style="COLOR: #2b91af">MachineType.IMAGE_FILE_MACHINE_AMD64:


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">               
case style="COLOR: #2b91af">MachineType.IMAGE_FILE_MACHINE_IA64:


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"x64";


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">               
case style="COLOR: #2b91af">MachineType.IMAGE_FILE_MACHINE_I386:


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">                   
return style="COLOR: #a31515">"x86";


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">               
default:


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">                   
return
machineType.ToString();


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">           
}


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">        }


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"> 


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"></scriptstyle="COLOR: blue">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><form style="COLOR: red">runatstyle="COLOR: blue">="server">


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><aspstyle="COLOR: blue">:TextBox style="COLOR: red">runat="server" style="COLOR: red">ID="txtFilePath"
Columnsstyle="COLOR: blue">="120"></style="COLOR: #a31515">asp:style="COLOR: #a31515">TextBoxstyle="COLOR: blue">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><br style="COLOR: blue">/>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><aspstyle="COLOR: blue">:LinkButton style="COLOR: red">ID="lbProcess" style="COLOR: red">runat="server" style="COLOR: red">Text="Check Config"
OnClickstyle="COLOR: blue">="CheckConfig"></style="COLOR: #a31515">asp:style="COLOR: #a31515">LinkButtonstyle="COLOR: blue">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><br style="COLOR: blue">/>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><br style="COLOR: blue">/>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><aspstyle="COLOR: blue">:Label style="COLOR: red">ID="lblresult" style="COLOR: red">runatstyle="COLOR: blue">="server"></style="COLOR: #a31515">asp:style="COLOR: #a31515">Labelstyle="COLOR: blue">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"><br style="COLOR: blue">/>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">style="mso-spacerun: yes">    style="COLOR: blue"></formstyle="COLOR: blue">>


style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-layout-grid-align: none"
align=left>style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"></style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">bodystyle="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">>


style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"></style="FONT-SIZE: 10pt; COLOR: #a31515; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">htmlstyle="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">>


style="TEXT-ALIGN: justify; PADDING-BOTTOM: 18px; MARGIN: 1px 0px; PADDING-LEFT: 18px; PADDING-RIGHT: 5px; FONT-FAMILY: arial; COLOR: gray; FONT-SIZE: 10pt; FONT-WEIGHT: normal; PADDING-TOP: 5px">
Source: How can I programmatically tell in C# if an unmanaged dll is x86 or x64?

No comments:

Post a Comment