views:

29

answers:

1

I have an embedded file - xsd.exe - in my .NET library.

How can I, without rebuilding the embedded file from its byte[], use it?

The exe runs on the command line so I need to be able to make calls like: xsd /o:.. or whatever.

I have read something about ManifestResourceStream but I can't seem to find it in the framework and I have no idea how to use it.

Any ideas?

+3  A: 

If you can write it to a temp file (File.WriteAllBytes), you can create a new AppDomain, and use yourAppDomain.ExecuteAssembly(...); however, to do this manually from a byte[], I expect you would need to load it manually with Assembly.Load(byte[],...), look at the loadedAssembly.EntryPoint, and use reflection to invoke it. The ExecuteAssembly approach is far easier...

Of course, if you can write it to a file, you could also just use Process.Start which is even more easy ;p

You might also want to double-check redist/deployment rights re xsd.exe.

Marc Gravell
I didn't even think of deployment rights - where can I find that info? Would it be OK to copy the file with my library rather than embedding it? I don't want to have to guess the location of xsd on each user's machine...
rmx
And if the exe you want to call isn't pure .net code you are pretty much forced to write it out, unless you want to go for **really** ugly hacks.
CodeInChaos
@rmx - I've done some digging, but it really isn't obvious either way! I'm looking in SDK 7, and there isn't much to go on...
Marc Gravell
It says "The contents included in the Windows SDK are licensed to you, the end user. Your use of the SDK is subject to the terms of an End User License Agreement (EULA) accompanying the SDK and located in the \License subdirectory. You must read and accept the terms of the EULA before you access or use the SDK. If you do not agree to the terms of the EULA, you are not authorized to use the SDK.", but I can't find that directory..
Marc Gravell
Thanks for your help, I think I have to do it the hard way though.
rmx