views:

193

answers:

3

There are a lot of posts on here about this, I'm using this code from another SO post and placing a delegate assignation in my Main() method. None of the other posts have directly answered my question.

I've got my third party assembly embedded as a resource but when I fire up the app:

  • I'm getting a TypeInitializationException with an inner of FileNotFoundException. It's trying to find the assembly on the file system and failing.
  • it's never getting to the Main method, where the event handler for AssemblyResolve is assigned

I have two assembly refs that are embedded in my Resources.resx, one is a third party tool (command line parser) and the other is a Library file where the meat of the application resides.

Maybe this isn't possible with a console app? Seems unlikely but I don't see a way around it.

Re: ILMerge etc: I'd like to get this done entirely in code without involving any tools. Reason: I don't want to have source code in the repository that requires other team members to install a tool that they probably don't have already. If that's not possible then ILMerge looks like the next best option.

+1  A: 

Consider using ILMerge to merge the assemlies into one rather than embedding as a resource. This is download site for ILMerge.

You would merge your third party assemblies into your console app.

btlog
Oops, beat me. I just added "I'd prefer not to use a 3rd party..."
jcollum
guess I should have read the link to the other SO question :)
btlog
Yeah, it looks like it should be possible with just a few lines of code, I just can't figure out how to get the event to fire at the right time in the app's lifecycle.
jcollum
A: 

You could also look at application virtualization tools like XenoCode. They can package multiple assemblies (including the .net framework itself) into a stand alone executable.

dkackman
A: 

If it is mixed mode assembly, it has to reside on the disk. Some limitation or something.

leppie