Deploying unmanaged DLL.

K

Krzysztof Stoj

I have unmanaged DLL which needs to be distributed with the managed code
appplication.
There are two physical files for that DLL one for debug build ( x86 target )
and one for release builds ( ARM target ).
I would like to know if there is a way in .NET to automatically specify
which unmanaged DLL to include in the managed project based on the current
target.
For now I'm adding the existing object ( unmanaged DLL ) to my file list in
the managed project. Then based on the target I'm copying either my unmanage
x86 or ARM file. Can I automate this process and how?
 
A

Alex Yakhhnin [eMVP]

You can also take a look at the Pete's article on
undocumented unmanaged file deployment:

http://www.opennetcf.org/Articles/XSLNativeDeployment.asp

--
Alex Yakhnin, eMVP
IntelliProg, Inc.
http://www.intelliprog.com
-----Original Message-----
There is no way to force IDE to deploy different files for different targets

What I do (and of course this is by far not the only way) is deploy both ARM
and x86 versions of DLL renamed to <MyDLLName>.DLL.ARM and
<MyDLLName>.DLL.X86 and then in the application startup code copy the
approriate one into MyDLLName.DLL

public static void PatchCPUSpecificDLL(string dllName)
{
string csDLLName = dllName;
string cpuSuffix;
switch( GetCPUArchitecture() )
{
case CPU_ARCH.ARM:
cpuSuffix = "ARM";
break;
case CPU_ARCH.MIPS:
cpuSuffix = "MIPS";
break;
case CPU_ARCH.X86:
cpuSuffix = "X86";
break;
default:
return;

}
string localPath = Path.GetDirectoryName(
Assembly.GetExecutingAssembly().GetModules() [0].FullyQualifiedName );
FileInfo fi = new FileInfo(localPath + "\\" + dllName + "." + cpuSuffix);
fi.CopyTo(localPath + "\\" + dllName, true);
}

public static CPU_ARCH GetCPUArchitecture()
{
SYSTEM_INFO si = new SYSTEM_INFO();
GetSystemInfo(ref si);
switch(si.wProcessorArchitecture)
{
case PROCESSOR_ARCHITECTURE_ARM:
return CPU_ARCH.ARM;
case PROCESSOR_ARCHITECTURE_SHX:
return CPU_ARCH.SH3;
case PROCESSOR_ARCHITECTURE_INTEL:
return CPU_ARCH.X86;
default:
return CPU_ARCH.Unknown;
}
}


I have unmanaged DLL which needs to be distributed with the managed code
appplication.
There are two physical files for that DLL one for debug
build ( x86
target )
and one for release builds ( ARM target ).
I would like to know if there is a way in .NET to automatically specify
which unmanaged DLL to include in the managed project based on the current
target.
For now I'm adding the existing object ( unmanaged
DLL ) to my file list
in
the managed project. Then based on the target I'm
copying either my
unmanage
x86 or ARM file. Can I automate this process and how?


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top