This works for me; in Product.wxs:
<Binary
Id="WixMyCustomActions"
SourceFile="..\WixMyCustomActions\bin\WixMyCustomActions.CA.dll" />
<CustomAction
Id="MyMethod"
BinaryKey="WixMyCustomActions"
DllEntry="MyMethod"
Execute="immediate"
Return="check" />
WixMyCustomActions.CA.dll is a C# class library in the same solution as the Wix project. In the WixMyCustomActions.CA.dll project properties, Build Events, I have a post build event to copy the WixMyCustomActions.CA.dll and WixMyCustomActions.CA.pdb from bin\Debug or bin\Release to bin:
copy "$(TargetDir)*.dll" "$(ProjectDir)bin" /Y
copy "$(TargetDir)*.pdb" "$(ProjectDir)bin" /Y
By copying the dll, my Product.wxs will reference whichever configuration (Debug or Release) was built last.
Edit: to get a file relative to your CA dll, use this to find the directory of the CA assembly:
using System.IO;
using System.Reflection;
// etc
string assemblyDirectory =
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
You can now find files relative to this directory.