Click here to Skip to main content
15,889,403 members
Home / Discussions / C#
   

C#

 
GeneralRe: Take the "real" time an application has been used Pin
Braulio Dez20-Oct-03 2:21
Braulio Dez20-Oct-03 2:21 
GeneralRe: Take the "real" time an application has been used Pin
Andrew Torrance22-Oct-03 22:33
Andrew Torrance22-Oct-03 22:33 
GeneralTables in a DataSet Pin
Mazdak19-Oct-03 22:44
Mazdak19-Oct-03 22:44 
GeneralRe: Tables in a DataSet Pin
Heath Stewart20-Oct-03 5:29
protectorHeath Stewart20-Oct-03 5:29 
Generalgui behavior Pin
Roger Alsing19-Oct-03 22:30
Roger Alsing19-Oct-03 22:30 
GeneralRe: gui behavior Pin
Heath Stewart20-Oct-03 5:32
protectorHeath Stewart20-Oct-03 5:32 
GeneralRe: gui behavior Pin
DesertLarry21-Oct-03 5:04
DesertLarry21-Oct-03 5:04 
GeneralDll free problem Pin
andyniyong19-Oct-03 22:22
andyniyong19-Oct-03 22:22 
Here is button click event code:
private void btnCompile_Click(object sender, System.EventArgs e)
{
string srcFile = @"D:\Temp\WindowsApplication6\Form2.cs";
string destFile = @"D:\Temp\WindowsApplication6\Form2.dll";
try
{
CompileCode(srcFile, destFile);
System.Reflection.Assembly a =
Assembly.LoadFile(destFile);
if(a != null)
MessageBox.Show("Ok");

System.Type type = a.GetType("Form2");
object obj = Activator.CreateInstance(type);
Form form = obj as Form;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
}

In the above code, function CompileCode(string srcFile, string destFile) is defined by me to compile the srcFile(.cs file) into the destFile(.dll file).
No doublt to say, every time execute this function, application will write the .dll file. The problem is when the code is executed for the second time
,there will be a exception which say that access collision,another application is accessing the .dll file.
Yes, I think that when the code execute for the second time, the dll has loaded into the current application domain, so cannot write into it. I have ever try to load the dll into another application domain in order that unload
the application domain after I have used the assembly. But some document say that when return assembly object of an appdomain into another appdomain, the later appdomain will also load the assembly. The problem also cannot be solved.
So I'd like to ask how can I realize the functionality of above btnCompile_Click()function?


Waiting for your answer.
Thank you!



GeneralRe: Dll free problem Pin
leppie20-Oct-03 7:12
leppie20-Oct-03 7:12 
GeneralRe: Dll free problem Pin
andyniyong21-Oct-03 16:04
andyniyong21-Oct-03 16:04 
Questionneed help... Listview drag drop algorithm? Pin
azusakt19-Oct-03 22:04
azusakt19-Oct-03 22:04 
AnswerRe: need help... Listview drag drop algorithm? Pin
Heath Stewart20-Oct-03 5:38
protectorHeath Stewart20-Oct-03 5:38 
GeneralRe: need help... Listview drag drop algorithm? Pin
azusakt21-Oct-03 18:22
azusakt21-Oct-03 18:22 
GeneralRe: need help... Listview drag drop algorithm? Pin
Heath Stewart21-Oct-03 18:36
protectorHeath Stewart21-Oct-03 18:36 
GeneralRe: need help... Listview drag drop algorithm? Pin
azusakt21-Oct-03 22:20
azusakt21-Oct-03 22:20 
GeneralRe: need help... Listview drag drop algorithm? Pin
Heath Stewart22-Oct-03 2:45
protectorHeath Stewart22-Oct-03 2:45 
QuestionCan it be done? Pin
kbilly19-Oct-03 21:06
kbilly19-Oct-03 21:06 
AnswerRe: Can it be done? Pin
Daniel Turini19-Oct-03 21:25
Daniel Turini19-Oct-03 21:25 
GeneralRe: Can it be done? Pin
kbilly19-Oct-03 21:30
kbilly19-Oct-03 21:30 
GeneralRe: Can it be done? Pin
Nick Parker20-Oct-03 5:47
protectorNick Parker20-Oct-03 5:47 
Generalflabberghasted by events Pin
allancto19-Oct-03 18:45
allancto19-Oct-03 18:45 
GeneralRe: flabberghasted by events Pin
Heath Stewart20-Oct-03 5:50
protectorHeath Stewart20-Oct-03 5:50 
QuestionHow can I repait the Caption area? Pin
wangier19-Oct-03 17:26
wangier19-Oct-03 17:26 
AnswerRe: How can I repait the Caption area? Pin
J. Dunlap19-Oct-03 17:29
J. Dunlap19-Oct-03 17:29 
GeneralMessage Removed Pin
19-Oct-03 17:18
Konstantin Gross19-Oct-03 17:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.