|
|
hi,
i want to develop a window application that will get a '.cs file' as input from a text box and create a class library(.dll file) for it.
this is the method i used to programmatically compile code and generate the executable, but i want to generate a dll.
private void Compile()
{
CSharpCodeProvider codeProvider = new CSharpCodeProvider();
ICodeCompiler icc = codeProvider.CreateCompiler();
string Output = "testAssembly.exe";
System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
parameters.GenerateExecutable = true;
parameters.OutputAssembly = Output;
CompilerResults results = icc.CompileAssemblyFromSource(parameters, txtOutput.Text.ToString());
//txtOutput is the text box where i give my code
if (results.Errors.Count > 0)
{
foreach (CompilerError CompErr in results.Errors)
{
MessageBox.Show( "Line number " + CompErr.Line +
", Error Number: " + CompErr.ErrorNumber +
", '" + CompErr.ErrorText + ";" +
Environment.NewLine + Environment.NewLine);
}
}
else
{
MessageBox.Show("Success");
}
}
this is the link i referred for programmatically compiling code using C# compiler that creates exe.
http://support.microsoft.com/kb/304655[^]
http://support.microsoft.com/kb/304655[^]
help plz,
thanx in advance.
|
|
|
|
|
Well - for a start, you have named your filename with an exe extension. More importantly though, you should set parameters.GenerateExecutable = false; to generate a DLL.
|
|
|
|
|
thanx for ur quick response, but i tried those, but it didnt work. actually it creates a dll (an exe that is renamed to a dll).. but i want a class library. for ur info i need to load the dll in NUnit, so if i create a dll as u said, i cant do that.
hope u can get me.
|
|
|
|
|
Why wouldn't you be able to load a DLL into NUnit??
|
|
|
|
|
this is the error that i get when i load the assembly in NUnit,
"System.IO,FileNotFoundException : Could not load file or assembly 'nunit.framework, Version=2.4.8.0, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77' or one of its dependecies. The system cannot find the file specified."
what is d cause of this error.! how to solve it.?
|
|
|
|
|
Sounds like your just missing a referenced .dll. You can either add the nunit assemblies to the GAC, or copy them to the same location as your dll, or one of the search paths for the nunit instance.
|
|
|
|
|
d chase begins wrote: thanx for ur quick response, but i tried those, but it didnt work.
Try again, or post the code for review. That's the right property to use to specify if an executable or a library will be created.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i'm new to this forum.. can u help me in posting the thread for review..?!
|
|
|
|
|
|
Most likely you set only the first element of the array to the parameter, but without seeing the code, it's quite hard to say more.
|
|
|
|
|
The byte array is declared "byte[] b = new byte[32];". I set the values with
cm.Parameters.AddWithValue( "@binTrack3", b );
and
cm.Parameters.Add( "@binTrack3", SqlDbType.Binary, b.Length ).Value = b;
Same results.
I should also add, I'm using ODBC connection to connect to Sybase and SQLClient connection to connect to SQL Server.
|
|
|
|
|
At a glance, that portion of the code seems fine. Just few questions.
Is the column defined fixed length? If it isn't, I think you should use SqlDbType.VarBinary.
You've used debugger to observe that length of b is 32 and that it has data on every element at the time when the value assignment is made? Also you could check using debugger that cm.Parameters["@binTrack3"] has the value you suspect just before calling the ExecuteNonQuery.
|
|
|
|
|
The column is defined as binary. Just for kicks, I tried VarBinary, but I still received the same results. I used the debugger right before ExecuteNonQuery both with SqlDbType.VarBinary and SqlDbType.Binary. It does show the 32-byte array in its entirety.
|
|
|
|
|
If the column is fixed size in the database, what's it's length in there?
|
|
|
|
|
I am using datagridview control in my application. The datagridview control consist of two textbox column and one combobox column,Where combobox is loaded with some set of data in database is working orrectly. But the issue is i want to select a default value in the combobox while loading. Please help us to solve the issue.
Syed
Zoniac Software P Ltd
Chennai
|
|
|
|
|
|
Hi all ,easy question for experts
If we don't use an explicit attribute [NonSerialized]
BinaryFormatter doesn't serialize
private members .
Is that right ?
if so , what about other .Net Framework serialization classes ? Soap , XmlSerializer
?
|
|
|
|
|
Is it possible to customize the formclosing event?
I want to change the FormClosingEventArgs to be a custom EventArgs class but I can't seem to figure out exactly how to accomplish this.
I have created an EventArgs class that inherits the FormClosingEventArgs class but when I connect to the event it will only let me us the FormClosingEventHandler which brings with it only FormClosingEventArgs which is where my problem is. I have succeeded in using the formclsoingeventargs to fire a custom event but I would liek to do it directly if possible
|
|
|
|
|
You can compare what the sender is and cast it to EventArgs if it is castable, be careful though, I highlight checking the sender so that you specifically don't cause a crash with an invalid cast.
|
|
|
|
|
Wow that is interesting. It would seem you have to
public new event FormClosedEventHandler FormClosing;
To custom fire the event. For whatever reason I cannot compile inside of the form when attempting my own
FormClosing(this, new FormClosedEventArgs(CloseReason.ApplicationExitCall));
without it.
This may not work because of the way the new keyword works.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
It seems that inheriting from a class removes your ability to directly call an event that is marked as public.
Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
If you don't ask questions the answers won't stand in your way.
Most of this sig is for Google, not ego.
|
|
|
|
|
you need to create a new FormClosing event with your custom args in the delegate derived from CancelEventArgs. I've given an example in the previous thread[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
yeah but this goes back to what I was saying before about doing it directly. Eliott's idea actually worked. Is it better to do it all through the event or to do it the way you originally suggested?
|
|
|
|
|
Personally, I think the OrderCreated is a seperate thing that just happens to occur when the form is closing, so I would write a seperate method that I would call from an overridden OnFormClosing after checking that cancel is false (after calling base.OnFormClosing).
In the new method I would create the order and raise an event passing the order in the args.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|