473,327 Members | 1,919 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,327 software developers and data experts.

Create an .exe at runtime with .NET 2.0

Hi

It is possible to create an .exe file at runtime with .NET 2.0? I would like
to create a .exe that should include:

- an encrypted file
- a simple winform to decrypt the included encrypted file (already compiled
as .exe)
When the user opens the created exe file, the simple winform should be
started so the user can decrypt the included file.

Thanks and Regards,
andersch
Feb 12 '07 #1
7 1704
Hi Andersch,

Based on my understanding, you'd like to create an executable file at
runtime with .NET 2.0, which in turn lauches an existing simple winform
application to decrypt an encrypted file. If I'm off base, please feel
free to let me know.

The .NET Framework includes a mechanism called the Code Document Object
Model (CodeDOM) that enables developers of programs that emit source code
to generate source code in multiple programming languages at run time,
based on a single model that represents the code to render.

The System.CodeDom namespace defines types that can represent the logical
structure of source code, independent of a specific programming language.
The System.CodeDom.Compiler namespace defines types for generating source
code from CodeDOM graphs and managing the compilation of source code in
supported languages.

FYI, The .NET Framework includes code generators and code compilers for C#,
JScript, and Visual Basic.

For more information on CodeDOM and how to use it, you may visit the
following link.
'Dynamic Source Code Generation and Compilation'
http://msdn2.microsoft.com/en-us/library/650ax5cx.aspx

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 13 '07 #2
Hi Linda

Thank you for your answer.

Can you show me a simple code example please? I've searched without sucess
for an example how I can compile a new executable with the encrypted file
(resource file) and the already compiled winform (.exe).

Thanks and Regards,
andersch
"Linda Liu [MSFT]" wrote:
Hi Andersch,

Based on my understanding, you'd like to create an executable file at
runtime with .NET 2.0, which in turn lauches an existing simple winform
application to decrypt an encrypted file. If I'm off base, please feel
free to let me know.

The .NET Framework includes a mechanism called the Code Document Object
Model (CodeDOM) that enables developers of programs that emit source code
to generate source code in multiple programming languages at run time,
based on a single model that represents the code to render.

The System.CodeDom namespace defines types that can represent the logical
structure of source code, independent of a specific programming language.
The System.CodeDom.Compiler namespace defines types for generating source
code from CodeDOM graphs and managing the compilation of source code in
supported languages.

FYI, The .NET Framework includes code generators and code compilers for C#,
JScript, and Visual Basic.

For more information on CodeDOM and how to use it, you may visit the
following link.
'Dynamic Source Code Generation and Compilation'
http://msdn2.microsoft.com/en-us/library/650ax5cx.aspx

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 13 '07 #3
Hi Andersch,

Sorry for my delayed reply.

Firstly, creating an executable file at runtime means you should create a
program first, which creates the executable file when it runs.

In your practice, since you already have a WinForm application to decrypt
the encrypted file, you could just write a program A to lanuch the existing
WinForm application and decypt the encrypted file. You needn't create
another executable file B which in turn lauches the existing WinForm
applicaion, when you run program A.

If you do need to do like that, a simple way is to write the code of the
program B first in VS, and then translate the code into CodeDOM, following
the MSDN sample I suggest to you in my first reply. It should not be a
difficult thing.

In additon, I don't think you need to embed the encrypted file into the
resources of the program B. The encrypted file can be a separate file.

Hope this helps.

If you have any question, please feel free to let us know.

BTW, I will be on a long vacation from the next Monday to Friday. During my
leave, my team mates will follow up with you and it may not in time. Sorry
for the inconvenience it may bring to you!

Sincerely,
Linda Liu
Microsoft Online Community Support

Feb 16 '07 #4
Hi Michael,

Since my colleague Linda is on vacation this week, I will continue to work
with you.

How about this issue now? Does Linda's reply make sense to you? If you
still need any help, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 20 '07 #5
Hi Jeffry

Sorry for the delay. I was very busy this week!

So, in the meantime I've found out how I can add the precompiled winform
(*.exe) and the encrypted file as a ressource.

CSharpCodeProvider provider = new CSharpCodeProvider();
CompilerParameters cp = new CompilerParameters();

if (provider.Supports(GeneratorSupport.Resources))
{
// Set the embedded resource file of the assembly.
cp.EmbeddedResources.Add("DecryptForm.exe");
cp.EmbeddedResources.Add("encryptedFile.enc");
}
But how can I access the resource 'DecryptForm.exe'? I would like to start
the form in the memory (not saving on the disk), so that the user can
decrypt the resource 'encryptedFile.enc'. Do you have a code example?
Thanks,
Dominik
""Jeffrey Tan[MSFT]"" wrote:
Hi Michael,

Since my colleague Linda is on vacation this week, I will continue to work
with you.

How about this issue now? Does Linda's reply make sense to you? If you
still need any help, please feel free to feedback, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 25 '07 #6
Hi Dominik,

I am back from my vocation.

To access an embedded resource, we could use
Assembly.GetManifestResourceStream method.

If you'd like the executable that is created at runtime to access the
embedded resource, you should translate the code to CodeDOM.

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Feb 27 '07 #7
Hi Dominik,

How about the problem?

If you have any question, please feel free to let me know.

Thank you for using our MSDN Managed Newsgroup Service!

Sincerely,
Linda Liu
Microsoft Online Community Support

Mar 2 '07 #8

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

Similar topics

7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
3
by: cql90 | last post by:
Hi all PRO, I don't know how to create the MSAccess database in the runtime with C#, Are there any body know how to do this? I am pretty sure that all of you know how to do it, except me :( ....
15
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
1
by: Luc | last post by:
Hi, I have a TabControl and, at runtime, I need to add some tabpages. The problem is that each tabpage is similar to the others and contains several controls. If I do...
7
by: MarkoH | last post by:
Wsdl.exe /server creates abstract class derived from WebService. Is there a way to create this class at runtime based on some WSDL file given at runtime ? What would be even better - creating...
6
by: shapper | last post by:
Hello, How to create a CSS StyleSheet at runtime and added it an Asp:Label? I am using Asp.Net 2.0. Thanks, Miguel
0
by: Husey | last post by:
Hi, I am trying to create a very simple EJB project which requires me to create a new jboss configuration in Eclipse. I keep getting the error message "An error has occurred. See error log for...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
1
by: henrymania | last post by:
Am writing a code for database backup....by backupservlet is as given below i get the following exception
0
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello Gurus, I need to create a Microsoft Visual Studio 2005 report at runtime. I wrote a C# window application, that holds a DataSet and several DataGridView controls. Each of the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.