473,769 Members | 6,034 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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://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?
Nov 17 '05 #1
0 1637

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

Similar topics

0
1435
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 control won't work, I get a run time exception: Could not find any resources appropriate for the specified culture (or the neutral culture) in the given assembly. make sure "UserControl.resources" was correctly embedded or linked into assembly...
1
1792
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 as SQL Query Analyzer uses. I would prefer not to merge the content of this file into the source code of configuration application but instead keep the SQL commands in a text file included in the executable, pretty much like resource data, for...
1
24179
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 needs to load it, but I do not want to hard code the path since that may change for different installs. i.e. GetPathForResourceOfName ( myResourceFileName ) thanks, JIM
5
8230
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 of type 'System.ArgumentException' occurred in system.drawing.dll Additional information: 'null' is not a valid value for 'stream'.
2
4986
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 possible..? How can I access the content of the file..? Jan
4
1321
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 Explorer in a contained UserControl control by using Visual C++ .NET 2003
2
8750
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 into a Resource and load it from there later? Thanks. Alejandro Lapeyre
0
2096
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 UserControl? (Script attached to, and executed by, a UserControl embedded server control can ‘see’ the UserControl through the root document architecture. How to get the script to execute and ‘see’ other server controls in the...
4
4187
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 Resource". After building the project again, the icon of my user control is the same as default. I'm not sure it's related to my VB.Net version is an express edition or not? Anyone know what's wrong ? I did this : Created a 16 x 16 pixd (256 colors)
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.