473,382 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

HOWTO Make a UserControl deploy an embedded resource.

ATS
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://MyTrustedWebSite/MyAssembly.dll#MyNameSpace.MyControl"
style="display: inline;"
VIEWASTEXT

</object>
<br>
OptiWebDeployer Test...
</body>
<script language=jscript>
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.Reflection.Assembly Assembly_This;
Assembly_This = System.Reflection.Assembly.GetExecutingAssembly();
System.IO.Stream Stream_OptiCenter;
Stream_OptiCenter = Assembly_This.GetManifestResourceStream
(
"MyControl.MyResource.exe"
);

FileStream FileStream_OptiCenter =
File.Create("c:\\Temp\\MyResource.exe");
long lLen = Stream_OptiCenter.Length;
byte[] byteOptiCenter = new byte[lLen];
Stream_OptiCenter.Read(byteOptiCenter, 0, (int) lLen);

FileStream_OptiCenter.Write(byteOptiCenter, 0, (int) lLen);
FileStream_OptiCenter.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.FileIOPermission,mscor lib, Version=1.0.5000.0,
Culture=neatral,PublicToken=b77a5c561934e089 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?
Nov 17 '05 #1
0 1615

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: yongwei | last post by:
I have a user control that used to work fine. But after I moved the project to another folder, one of the user control won't generate a .resouce file after rebuild, and the form contains the user...
1
by: Ola Theander | last post by:
Dear subscribers I'm currently creating a small application that will run at the end of a web installation to configure a SQL Server. For this task I have a SQL batch file in the same format...
1
by: james | last post by:
What class / method should I be using to get the full path to an embedded resource ? In my case I have an .xml file that my app uses, it is set as embedded resource, and I have a control that...
5
by: Drew | last post by:
Assembly asm = Assembly.GetExecutingAssembly(); me = new Bitmap(asm.GetManifestResourceStream("me.gif")); I have used this before without any problem, but now I get: An unhandled exception...
2
by: Jan | last post by:
Hi, What I want is to add a text file to my project which will be included/embedded in my exe file. So not a link to a text file in a folder but a text file physical in the exe. Is this...
4
by: ATS | last post by:
HOWTO: Add methods to C++ UserControl. Please help, I want to add a method to a C++ .NET UserControl that is based off the sample in the MSND article titled: How to automate Internet...
2
by: Alejandro Lapeyre | last post by:
I am using a ImageList with a bitmap that contains all the images. I am currently saving the bitmap in a PictureBox, and load into the ImageList when the form loads. How can I save the bitmap...
0
by: oliver | last post by:
QUESTION: How to access an object embedded in a UserControl through Javascript file? Another way to ask this question: How to execute script from a UserControl, accessing other objects in that...
4
by: Pascal | last post by:
Hi all, I'd tried to follow the instructions from msdn for adding icon image for a control. I've checked the name of bmp file is same as the control name and turn the bmp file to "Embedded...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.