HOWTO Make a UserControl deploy an embedded resource.
Please help,
I need to embed an EXE into a C# UserControl that is run from script in an
HTML web page as such:
<html>
<object
id=objTest
classid="http://MyTrustedWebSit e/MyAssembly.dll# MyNameSpace.MyC ontrol"
style="display: inline;"
VIEWASTEXT
</object>
<br>
OptiWebDeployer Test...
</body>
<script language=jscrip t>
var objTest;
objTest.Deploy( );
</script>
</html>
So far, I've embedded the EXE I need to run as an embedded resource, and can
see from the size of my UserControl that it is getting embedded. But I'm not
sure on how to make the C# code extract it, write it to file, and then
execute the EXE. My Attempt on the Deploy method so far is as such:
public string Deploy()
{
System.Reflecti on.Assembly Assembly_This;
Assembly_This = System.Reflecti on.Assembly.Get ExecutingAssemb ly();
System.IO.Strea m Stream_OptiCent er;
Stream_OptiCent er = Assembly_This.G etManifestResou rceStream
(
"MyControl.MyRe source.exe"
);
FileStream FileStream_Opti Center =
File.Create("c: \\Temp\\MyResou rce.exe");
long lLen = Stream_OptiCent er.Length;
byte[] byteOptiCenter = new byte[lLen];
Stream_OptiCent er.Read(byteOpt iCenter, 0, (int) lLen);
FileStream_Opti Center.Write(by teOptiCenter, 0, (int) lLen);
FileStream_Opti Center.Close();
return "EXE was successfully deployed...";
}
When I try this, I get a run time error as such:
=============== =============== =========
Error: Request for the permission of type
System.Security .Permissions.Fi leIOPermission, mscorlib, Version=1.0.500 0.0,
Culture=neatral ,PublicToken=b7 7a5c561934e089 failed.
=============== =============== =========
So I have questions.
1) Is that C# code correct to deplot the EXE from an embedded resource?
2) Why did I get that security error? I trusted the site from IE, and I
added "http://MySite/*" to the security of my .NET 1.1 config as a URL for
the entire enterprise.
3) How do we actually launch the EXE?