473,800 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

run time Compiling

Hello all
I have a idea...and dont know if it is possible......
we have a pretty huge system at work and
we send EDI Special formatted Data to Several
Other Companies, via sFtp,dial up, vpn depending on these customers
requirements

one of the areas we are using a implimentation in vb6 (yuck) but
works...slow as well u know,

it implements msSqlServer Record set, has xml (config )instructions like
customer specific information then creates
a output Xml, then a text file via xlt.....

im Writing a completly new system using c#, and i had a idea, of a main
information dll, and c# source files for output on the server that we
program for each customer(partne r) that will create the output format based
on partner requirements, output can be NSF, Ansi ,hl7 csv, tab, and weird
output formats they want...

is there a way to compile and run the code at Run time
if any changes in the partner specif ic source has changed
the main dll, compiles and runs the specific partner file to generate the
output.....this would only take place if a programmer has made any changes
to the source file

I hope i explaned myself
thanks alot
MikeJ

Oct 13 '07 #1
13 2188
Analizer1 <an*******@yaho o.comwrote:

<snip>
is there a way to compile and run the code at Run time
if any changes in the partner specif ic source has changed
the main dll, compiles and runs the specific partner file to generate the
output.....this would only take place if a programmer has made any changes
to the source file
Yes, you *can* do that (CSharpCodeComp iler) but I think it would be a
much better idea for the programmer to make the change, compile it
themselves, and then put the compiled class library onto the server
after testing. You can then notice that the DLL has changed, reload the
assembly, and use that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 13 '07 #2
where can i find examples on how to accompish this...

personally i would want to manage the code then place it up on the server
after any changes...but the other programmers are lazy...they want
easy....lazy...
so without arguing with them..i want to write a run on the fly system for
this...then eventually manage it as you said i should do...

thanks alot
Mike

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
Analizer1 <an*******@yaho o.comwrote:

<snip>
>is there a way to compile and run the code at Run time
if any changes in the partner specif ic source has changed
the main dll, compiles and runs the specific partner file to generate the
output.....thi s would only take place if a programmer has made any
changes
to the source file

Yes, you *can* do that (CSharpCodeComp iler) but I think it would be a
much better idea for the programmer to make the change, compile it
themselves, and then put the compiled class library onto the server
after testing. You can then notice that the DLL has changed, reload the
assembly, and use that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 13 '07 #3
Analizer1 <an*******@yaho o.comwrote:
where can i find examples on how to accompish this...

personally i would want to manage the code then place it up on the server
after any changes...but the other programmers are lazy...they want
easy....lazy...
so without arguing with them..i want to write a run on the fly system for
this...then eventually manage it as you said i should do...
Are they really too lazy to even compile their code and test that it
works, even to a cursory extent? It's scary to think that the partners
trust them...

CSharpCodeProvi der is pretty easy to use - create one, then call
CompileAssembly FromFile (or one of the appropriate
CompileAssembly FromXXX methods) to generate an assembly.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 13 '07 #4
i got that working pretty well......
i want to unload the dll also
even if i were to manage these dll's (not dynamic)

i still need to load and unload them i could have lots of partner specific
dll's....

any help available is appriciated
Mike

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
Analizer1 <an*******@yaho o.comwrote:
>where can i find examples on how to accompish this...

personally i would want to manage the code then place it up on the server
after any changes...but the other programmers are lazy...they want
easy....lazy.. .
so without arguing with them..i want to write a run on the fly system for
this...then eventually manage it as you said i should do...

Are they really too lazy to even compile their code and test that it
works, even to a cursory extent? It's scary to think that the partners
trust them...

CSharpCodeProvi der is pretty easy to use - create one, then call
CompileAssembly FromFile (or one of the appropriate
CompileAssembly FromXXX methods) to generate an assembly.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 13 '07 #5
Analizer1 <an*******@yaho o.comwrote:
i got that working pretty well......
i want to unload the dll also
even if i were to manage these dll's (not dynamic)

i still need to load and unload them i could have lots of partner specific
dll's....

any help available is appriciated
You can't unload individual DLLs - you can only unload an AppDomain.
So, you may need to load each DLL in a separate AppDomain.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 13 '07 #6
I have a Dll....but each time i load and unload the appdomain...mem ory keeps
going up
the reason for loading and unloading
i could have hundreds of dll's that need to be loaded run the code and
unloaded

help with this

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
Analizer1 <an*******@yaho o.comwrote:
>i got that working pretty well......
i want to unload the dll also
even if i were to manage these dll's (not dynamic)

i still need to load and unload them i could have lots of partner
specific
dll's....

any help available is appriciated

You can't unload individual DLLs - you can only unload an AppDomain.
So, you may need to load each DLL in a separate AppDomain.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 14 '07 #7
Analizer1 <an*******@yaho o.comwrote:
I have a Dll....but each time i load and unload the appdomain...mem ory keeps
going up
the reason for loading and unloading
i could have hundreds of dll's that need to be loaded run the code and
unloaded

help with this
Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 14 '07 #8
here is some running code ...
the dll im loading is a simple c# code file static main
Prints "hello world"
Sample of the myasm.dll at end of this file
Im new At this...so lots of learning going on here......i wanna make sure
there is no
memory leaks and i can load, execute and unload dlls at run time

all you knowledge is very welcome
thanks
Mike

Example:
using System;
using System.Collecti ons.Generic;
using System.Text;
using System.IO;
using System.CodeDom. Compiler;
using System.Windows. Forms;
using System.Reflecti on;
using Microsoft.CShar p;
using System.Threadin g;
namespace Compiler1
{
class Program
{
static void Main(string[] args)
{
CompileAndRun.C ompile();
CompileAndRun.R unRemote();
}
}
public static class CompileAndRun
{
public static void Run()
{

CompilerResults Result = CompileAndRun.C ompile();
//Execute the class

Console.WriteLi ne(Result.Compi ledAssembly.Loc ation);
Console.WriteLi ne(Result.Compi ledAssembly.Ful lName);

// Assembly MyAsm =
NewDomainName.L oad(Result.Comp iledAssembly.Lo cation); //"myasm.dll" );
//Result.Compiled Assembly.Locati on);
Assembly MyAsm = Result.Compiled Assembly;

if (MyAsm == null)
{
Console.WriteLi ne("dll not loaded");
}

object myobj = MyAsm.CreateIns tance("mynamesp ace.MyClass");
if (myobj == null)
{
MessageBox.Show ("Couldn't load class.");
return;
}
object ret = myobj.GetType() .InvokeMember(" Test",
BindingFlags.In vokeMethod, null, myobj, null);

Console.WriteLi ne("back");
System.Threadin g.Thread.Sleep( 10000);

}
public static CompilerResults Compile()
{
CodeDomProvider Provider =
CodeDomProvider .CreateProvider ("CSharp");
CompilerParamet ers cp = new CompilerParamet ers();
cp.ReferencedAs semblies.Add("S ystem.DLL");
//cp.ReferencedAs semblies.Add("S ystem.IO.dll");
cp.ReferencedAs semblies.Add("S ystem.Windows.F orms.dll");
cp.GenerateInMe mory = false;
cp.OutputAssemb ly = "d:\\cstest\\my asm.dll";
CompilerResults Result = Provider.Compil eAssemblyFromFi le(cp,
"d:\\cstest\\cl ass1.cs");
Console.WriteLi ne(Result.Error s.Count);
if (Result.Errors. HasErrors)
{
string eMsg = "";
eMsg = Result.Errors.C ount.ToString() + " Errors ";
for (int x = 0; x < Result.Errors.C ount; x++)
{
eMsg = eMsg + "\r\n " +
Result.Errors[x].Line.ToString( ) + " - " +
Result.Errors[x].ErrorText;
}
MessageBox.Show (eMsg);
}
return Result;
}
public static void printall(AppDom ain ad)
{
Assembly[] LoadedAssemblie s =ad.GetAssembli es();
foreach( Assembly a in LoadedAssemblie s)
{
Console.WriteLi ne(a.GetName(). Name);
}
Console.ReadKey ();
}
public static void RunRemote()
{
//CSScriptLibrary .CSScript.Load( "d:\\cstest\\cl ass1.cs");
for (int x = 0; x < 1000; x++)
{

AppDomain ad = AppDomain.Creat eDomain("NewDom ain");
// Assembly as
Assembly MyAsm = ad.Load("myasm" );
object myobj = MyAsm.CreateIns tance("mynamesp ace.MyClass");
object ret = myobj.GetType() .InvokeMember(" Main",
BindingFlags.In vokeMethod, null, myobj, null);
AppDomain.Unloa d(ad);

Thread.Sleep(10 00);

}
}
}
}

// Sample class1.cs using to compile and load in new appdomain

using System;
using System.IO;
using System.Windows. Forms;
namespace mynamespace
{
public class MyClass:Marshal ByRefObject
{
public static void Main()
{

Console.WriteLi ne("Hello World # 9million 38");
//MessageBox.Show ("hello World");
}
}
}

Oct 14 '07 #9
im also having problems loading a dll from a Different path, other then the
Application Path....
Thanks again for all you help it is really appriciated
Mike

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:MP******** *************@m snews.microsoft .com...
Analizer1 <an*******@yaho o.comwrote:
>I have a Dll....but each time i load and unload the appdomain...mem ory
keeps
going up
the reason for loading and unloading
i could have hundreds of dll's that need to be loaded run the code and
unloaded

help with this

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 14 '07 #10

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

Similar topics

6
2179
by: Rick | last post by:
Hello all. I have an index.php file that has a lot of functions that I wrote. Let's say for the sake of argument that there are 1000 functions of 100 lines each. The index.php file is invoked with a "state" a la "index.php?state=L1-2L3C4-47". Different functions are called according to what the state is, and then user actions can cause index.php to be invoked again with a different state. For instance, you can click an "erase this...
0
2074
by: Martin Bless | last post by:
I need to access a MSSQL database (MS-Sql, not MySQL!)and would very much like to use mssql-0.09.tar.gz which is available from http://www.object-craft.com.au/projects/mssql/download.html Unfortunately the binary for Python-2.4 isn't available yet and I'd hate to step back to a previous version. I'm glad I managed to set up my XP machine to being able to compile extensions using the VC++ toolkit which freely availbale from MS. See
17
3134
by: newbiecpp | last post by:
I have hard time to understand run-time environment. Let assume that I have a program that has a simple variable alpha. When this variable is statically allocated, the compiler can use the absolute address of alpha to access to it. What confuses me is that when the variable is dynamically allocated, how does the compiler implement it? We know the address of the variable until run-time. During the compilation, how can we access to the...
9
1785
by: MLH | last post by:
Trouble is, it doesn't happen every time. Yesterday, for example, it happened only once and not again afterward. Some days ago, a similar situation. Today, well - I tried 7 times straight to open the report and each time, A97 shuts down. The seemingly hit 'n miss nature of the error is intriguing. All I've been able to determine is that if I allow the report to be opened from within code using this line... DoCmd.OpenReport...
2
1483
by: julien | last post by:
Hello, I try to understand was is statically compiled, and what is loaded at tun time. I have 3 binary file: Program.exe, Plugin.dll, and Share.dll Share.dll contains objects used by both Plugin.dll and Program.exe. I compile these 2 program with Share.dll Do the 2 binary have an embedded version of Share.dll (compilation
4
1910
by: Jm | last post by:
Hi all I know this might sound a little stupid but i thought id better ask anyway in case there are some things i havent already tried that everybody else knows. Basically i am wondering if there is any way to speed up the time it takes for my app to display its first form. There is very little code before the form loads, pretty much just a line or two to load the images on it but it still can take quite a while on some machines to start...
2
1961
by: Justin Naidl | last post by:
A group of friends and I are doing a RPG (role-playing game) maker for a school project. It occured to us, however, that if you want the user to be able to have almost complete control over the contents of his/her game, that you would end up with a tiny executable and a huge datafile. We wanted to keep clear of this as disk accesses take a lot of time to do and there would be a huge load of them to do this part. We could very easily...
18
1671
by: Franky | last post by:
I don't know how to ask this so that someone will not misread it but here goes. At run time I want to be able to evaluate functions from the Math library, but at design time I do not know what functions will be needed. I know I can do If Userinput = "SINE" Then zz = Sin(whatever)
130
3363
by: Gianni Mariani | last post by:
Attached example CPP files makes it easier to post code and extract code from posts. It's unimaginable at this time where virtually any news reader is capable of dealing with attachments to stick with such old antiquated rules. It's time for a change. I reccomend that the faq-5.4 bullet be changed: http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.4 from:
0
10505
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...
1
10253
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9085
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
7576
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
6811
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
5471
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2945
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.