|
|
|
thanx a lot!
But I'm writing my own blog engine, so I need colourizer like some independent class.
|
|
|
|
|
i have made a small application that can load programs compiled into dll files, i managed to get the application to load my dll files correctly but now i am having issues with how to unload the dll files correctly. inside the dll program, when i go to close the program i can not use the normal means to close as it would cause the whole program including the loader to close. so if someone could please give some advice on how to properly unload a dll after its loaded, it would be very much appreciated.
|
|
|
|
|
If you load your dlls dynamically, you can unload them. If they are referenced by your project at build time, they will be loaded for the lifetime of your app instance.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Your question is not clear. Are you saying you want to unload a DLL or are you saying calling Environment.Exit() from a dynamically loaded DLL doesn't work? If it's the former, feel free to browse Google[^]
If it's the latter, there's little anybody can do without your code. FYI, I loaded an assembly using Assembly.Load , instantiated a type and called a method on it which called Environment.Exit() and the app was cleanly shut down. Again, you may want to post a code snapshot.
Cheers,
Vıkram.
Be yourself, no matter what they say.
- Sting, Englishman in New York.
|
|
|
|
|
Hi,
I am trying to convert a Big Endian data file to something readable on most Windows PCs. I do ok with integer data but I cannot convert the floating points (32-bit IEEE).
1) Is it possible for a BinaryReader to account for Big Endian, such that .ReadSingle() would return the correct value?
2) If I have to read the bytes one at a time and reverse them, is there a way to type cast it to a float?
I pursued #2 for a while, but C# type-casting seems to convert the actual value and not the binary that represents it. So the result is something like 1.12E9 instead of 89.9.
I really don't know how to make it work correctly. I would be grateful for any help.
Regards,
Piote
|
|
|
|
|
Hi,
AFAIK there is no direct .NET support for big-endian data.
You need to swap all bytes in each larger data item, whether integer or float.
The BitConverter class will help you interpreting bytes once you have put them
in the right order. See ToSingle() method.
You could construct your own BinaryReader derivative that hides the endianness
conversion, (only if BitConverter.IsLittleEndian returns true).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks for help. I'll try to use that.
Regards,
Piote
|
|
|
|
|
Hi got this code that is a potential solution to my Database login problem.It was originally in VB but I ran a converter on it. Now I have a OleDbDataReader method called Item(String) that was there when the code was in VB but now does not exist on the OleDbDataReader class in C#(dont know if that possible). Here is the full code. I need help to find the equivalent of this Item method in C#. The code connects to a access database and compares a textbox password entry to one in the database under the same user name given on another textbox...
private void btnLogin_Click(object sender, System.EventArgs e)
{
//The connection string is used to describe the type of database, the security information and the location to the database.
string ConString = "Provider=Microsoft.Jet.OLEDB.4.0;Password=\"\";User ID=Admin;Data Source=\"databasename.mdb\";";
//Create a new connection object and assign the ConString Connection String above
OleDbConnection DBCon = new OleDbConnection(ConString);
// g_login is a global variable defined in a Module that captures the login name and passes it from form to form. To create this, just create a Module, say Module1.vb and in it put "Public g_login as String" {g meaning global and login to represent the global login}
GlobalVariables.g_login = this.textBox1.Text;
string strPassword = this.textBox2.Text;
if (GlobalVariables.g_login == "" || strPassword == "")
{
MessageBox.Show("You are missing information. Please make sure that both the username and password fields are filled out.", "Missing Info");
this.textBox1.Focus();
return;
}
// The database has two fields in the Users table. A UserID field, which is the primary key and declared as a text. The other field is Password, which is a text as well.
string strsql = "SELECT [UserID], [Password] FROM Users WHERE [UserID]='" + GlobalVariables.g_login + "' ";
OleDbCommand cm = new OleDbCommand(strsql, DBCon);
OleDbDataReader dr;
bool valid = false;
bool HasRows = false;
try {
DBCon.Open();
dr = cm.ExecuteReader();
if (dr.HasRows) {
while (dr.Read()) {
if (strPassword == dr.Item("Password")) {
valid = true;
}
}
HasRows = true;
}
dr.Close();
}
catch (OleDbException exO) {
MessageBox.Show(exO.Message);
}
catch (Exception ex) {
MessageBox.Show(ex.Message);
}
finally {
if (DBCon.State == ConnectionState.Open) {
DBCon.Close();
}
cm = null;
dr = null;
DBCon.Dispose();
GC.Collect();
}
iCount = iCount + 1;
if (valid == true) {
Form n = new Form4();
n.Show();
this.Hide();
}
else if (iCount == 3) {
MessageBox.Show("Contact Developers!", "Invalid Info");
this.Close();
}
else if (HasRows == false) {
MessageBox.Show("Invalid user name, try again!", "Invalid Info");
this.textBox1.Focus();
this.textBox1.Text = "";
this.textBox2.Text = "";
}
else {
MessageBox.Show("Invalid password, try again!", "Invalid Info");
this.textBox2.Focus();
this.textBox2.Text = "";
}
}
Thanks in Advance.
Is this chair taken
|
|
|
|
|
Hi
It seems like you are looking for the indexer operator under the VB.
In order to read the field values use one of the following methods:
1.indexer operator - dr["Password"] or dr[index]
2.GetValue - dr.GetValue(index)
3.GetValues - int count = dr.GetValues(object[] results)
|
|
|
|
|
I require a drill-down feature in one of my application (exactly similar to Data Tips in Visual Studio .NET 2005).
Here's a brief on what I have:
1. I receive the final output through several steps (say 5 steps) and I need to display the output at each step.
2. Each sub-output has different number of parameters (or you can say No. of Columns)
Considering this, I think something like Data Tips would be the best option for presenting this data to the user.
Problem is that I don't know how to re-create or derive this existing Visual Studio's feature. I am a beginner in C#. I searched everywhere, but all I got was DebuggerVisualizer (which works only in debug mode of Visual Studio and they are not about creating Data Tips).
I want Data Tips to work outside of Visual Studio, in my own application.;)
|
|
|
|
|
i want to make a schedule for distributing employees over a month ,using genetic algorithm & C#
can anyone tell me plz how to proceed ?
|
|
|
|
|
I would say that to proceed, you should do the following:
- 1. Understand genetic algorithms
- You can do that by reading the Wikipedia entry[^] or a good tutorial[^].
- 2. Figure out an acceptable encoding
- The hardest part of genetic computing comes from creating an encoding that represents the appropriate information on which the algorithm can act.
- 3. Write some code
- You can always use Google to find example code.
Unfortunately, this may be all that you get. This sounds suspicious like a homework assignment; we don't do homework for people.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
Hi, This provides usefull methods to get tempfiles, unuque name, and temp directory paths, i m wondering if i can show my files let say in folder "PDF", which is not publicaly viewable, in that temp file, which is unique for each user session.
Problem: I have pdf files in PDF folder on which each asp.net user have different rights, some can view the same files and some can not, so i planned to make it restricted for all user, and will get rights from the dataabse, and finally i want to copy these file to uniquly created temp file, and want to redirect to that file, so user can see the file in browser. i hope you understand my question.
many thanks
adnan
-- modified at 10:39 Sunday 26th August, 2007
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
Hi Adnan,
You might find copying the files around will give poor performance, its probably not the best solution to your problem.
It seems the root cause of your problem is that ASP.Net permissions don't apply to passive content like PDFs, am I correct?
If so you might want to read up on how to stream a file using a handler (ashx). You could then have a URL like "http://mysite/viewPDF.ashx?somefile.pdf". If you want a normal looking URL to hide what you are doing you will have to read about URL remapping.
Have a search on this site, theres lots of articles about those topics.
Cheers,
|
|
|
|
|
Thanks for reply. But now i am confused to go for a reliable solution regarding file security.
Its right that asp.net location tag didnot work for like it did work for common aspx pages.
I read articles which advocates different solutions, like implementing basic authentication with SSL, to secure the files, and use httpwebrequest type classes to get login on the server and give access to the logined user without prompting a login diaglue.
Some advocate NTLM security, which is new even i heard first time.
You told me to write handelers, i read a little about it, to map IIS extensions with asp.net extension to restrict file access in browser.
But my real problem is i will be having thousands of files, and with hunderd of users having different writes on them, I am looking to having a reliable solution which should also be good in performance.
Can you please put little more light regarding my context explained above.
I will be very thankful to you.
Many Thanks & Best Regards,
adnan
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
Hi Adnan,
A handler can be made that will serve out many different files. I'm not going to write one for you, but I can give you some code snippets to give you an idea. (I'm also typing straight into the reply window, so they might be a little wrong).
Firstly you would need some way of identifying what file the user wants, and mapping that to a real file. Lets just assume they are all pdf files in one directory, and the user will ask for them by filename in the querystring (http://yoursite/getFile.ashx?SomeFileName).
So in our handler we can get the file the user wants with the Request.QueryString. Then we can check whether the user has permission to access the file (how you do this is up to you). Then we can send the file to the client.
We want to set the context.Response.ContentType = "text/pdf" (or whatever is appropriate).
We need to find the physical filename of the file, say string filename= "c:\\somedirectory\\" + filename + ".pdf". Then we can use context.Response.WriteFile(filename) to send the file to the client.
Note that you probably want to check the user's input more carefully than I have.
|
|
|
|
|
Thanks Mark, handler works greate for me. regards adnan
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
can anyone walk me through how to do this or point me to a resource? My friend google couldn't find me anything about how this is done. I don't mean having another application interact with the service by attaching it to the service process. I would like to step through the code within the service itself.
TIA!
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
Sure, I do that all the time (but not on remote systems, I only know how to do local services).
In Visual Studio, under Debug, there is a menu item to Attach to Process...
use that to attach to the service process while it's running.
As a further help to me, in my OnStart I put
# if DEBUG
System.Threading.Thread.Sleep ( 60000 ) ;
# endif
so the service sleeps for a minute before starting, giving me time to attach the debugger.
|
|
|
|
|
Thanks for the reply.
Just a couple more question...When you say attach to the server process, what do I attach? Do you mean to attach another application that will communicate to the service? Or do you mean the service application itself? The former I can do but when I run in debug the currently opened service solution I get an error saying I can't run the service that way and it has to be installed or run using the server explorer or net start.
It would be really great if I can step through the code of the running service.
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
Write the service.
Make a debug build.
Install the service.
Start the service.
Attach the debugger -- Visual Studio -- to the process that is the service. That service has to already be installed and running (or at least asleep in its OnStart method).
|
|
|
|
|
Use the diagnostics namespace:
#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif
This will launch and attach a debugger to the process. Theres a bunch of other useful methods on that class as well.
|
|
|
|
|
hi
i have a main form, when i click on button, the datails form show via showdialog() method, in DetailsForm_Load event, i use delegate to loading data from another thread, here is my code :
myDelegate delInctance = new myDelegate(this.gu2.Show_WaitingForm);<br />
delInctance.BeginInvoke("در حال بارگذاري اطلاعات ...", null, null);<br />
if (this.isNewMode)<br />
{<br />
this.LoadLookUp_TypeResource();<br />
this.LoadLookUp_Group(); <br />
<br />
this.bar_btn_edit.Enabled = false;<br />
this.bar_btn_delete.Enabled = false;<br />
<br />
this.barStaticItem1.Caption = "آماده";<br />
}<br />
else if (this.isEditeMode)<br />
{<br />
this.LoadLookUp_TypeResource();<br />
this.LoadLookUp_Group();<br />
this.InitData();<br />
this.dataNavigator1.Position = this.currentRowIndex;<br />
this.barStaticItem1.Caption = "آماده";<br />
}<br />
this.gu2.Hide_WaitingForm();
but when i load event, finish operation, my form and my app get lost focus window, how to solve my problem and keep focus on my DetailsForm ?
thanks
|
|
|
|
|