Home

AnyCPU

AnyCPU is a .NET platform target used for assemblies, indicating that the code is architecture-agnostic and can run on both x86 and x64 environments. When a program or library is built as AnyCPU, the runtime is responsible for loading it in a way that matches the host process architecture.

On Windows, an AnyCPU executable will run as a 32-bit process on 32-bit Windows. On 64-bit Windows,

The practical implication of AnyCPU depends on dependencies. If an application relies on native libraries that

In the modern .NET landscape, the relevance of AnyCPU varies by platform. .NET Framework projects commonly use

the
runtime
typically
starts
a
64-bit
process
by
default,
unless
an
application
manifest
specifies
otherwise.
This
behavior
can
be
controlled
by
a
manifest
flag
called
Prefer32Bit,
which,
when
set
to
true,
forces
the
executable
to
run
as
32-bit
on
64-bit
Windows.
Libraries
built
as
AnyCPU
do
not
independently
set
their
process
architecture;
they
adapt
to
the
host
process
where
they
are
loaded.
are
architecture-specific,
you
must
provide
matching
32-bit
and
64-bit
native
binaries
or
use
a
loading
strategy
that
selects
the
appropriate
one.
Otherwise,
loading
a
64-bit
native
library
into
a
32-bit
process
(or
vice
versa)
will
fail.
AnyCPU,
while
.NET
Core
and
later
versions
emphasize
runtime
identifiers
and
architecture-specific
publishing.
For
these
runtimes,
architecture
is
often
determined
by
the
published
target
(RID)
or
by
the
runtime,
rather
than
a
simple
assembly
target,
and
developers
may
publish
separate
builds
for
x86
and
x64
as
needed.