Search code examples
c#dllwindows-cecab

Why will my application not load DLLs on first launch, but fine there after?


I have created an application for Windows CE for a mobile device. When I debug the application from VS the application loads and runs fine. However when I build a CAB file for the installation it does not. The first time I launch the application after installing it, it throws an "TypeLoadException". However when I try again it works fine.

It throws the error the first time I try to access a DLL from the application.

I would like to post as much code as you guys need, however I'm a bit unsure on what's relevant. Here is the INF file I used to make the CAB file with CABWIZ.exe:

[Version]
Signature="$Windows NT$"
Provider="Y"
CESignature="$Windows CE$"

[CEStrings]
AppName="ShoePDA"
InstallDir="\Backup\XClient"

[Strings]
Manufacturer="Y"

[CEDevice]
VersionMin=4.0
VersionMax=6.99
BuildMax=0xE0000000

[DefaultInstall]
CEShortcuts=Shortcuts
AddReg=RegKeys
CopyFiles=Files.Common1,Files.Common2,Files.Common3,Files.Common4,Files.Common5,Files.Common6,Files.Common7

[SourceDisksNames]
1=,"Common1",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\Lib\"
2=,"Common2",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\Lib\"
3=,"Common3",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\Lib\"
4=,"Common4",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\Lib\"
5=,"Common5",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\Lib\"
6=,"Common6",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\Lib\"
7=,"Common7",,"C:\Users\akj\Documents\Udvikling\SVN\X\Trunk\ShoePDA2\obj\Release\"

[SourceDisksFiles]
"OpenNETCF.Net.dll"=1
"OpenNETCF.Windows.Forms.dll"=2
"OpenNETCF.WindowsCE.dll"=3
"OpenNETCF.dll"=4
"datalogic.device2008.dll"=5
"datalogic.wireless2008.dll"=6
"X.exe"=7

[DestinationDirs]
Shortcuts=0,%CE2%\Start Menu
Files.Common1=0,"Backup\XClient"
Files.Common2=0,"Backup\XClient"
Files.Common3=0,"Backup\XClient"
Files.Common4=0,"Backup\XClient"
Files.Common5=0,"Backup\XClient"
Files.Common6=0,"Backup\XClient"
Files.Common7=0,"Backup\XClient"

[Files.Common1]
"OpenNETCF.Net.dll","OpenNETCF.Net.dll",,0

[Files.Common2]
"OpenNETCF.Windows.Forms.dll","OpenNETCF.Windows.Forms.dll",,0

[Files.Common3]
"OpenNETCF.WindowsCE.dll","OpenNETCF.WindowsCE.dll",,0

[Files.Common4]
"OpenNETCF.dll","OpenNETCF.dll",,0

[Files.Common5]
"datalogic.device2008.dll","datalogic.device2008.dll",,0

[Files.Common6]
"datalogic.wireless2008.dll","datalogic.wireless2008.dll",,0

[Files.Common7]
"X.exe","X.exe",,0


[Shortcuts]

[RegKeys]

Thank you very much in advance for your help!


Solution

  • This was a very weird error. I solved it by updating the API DLL I was using the the device. Very werid when the error did not happen when debugging.. Oh well, guess it is solved.