|
yep that is why i'm using it, to speed up the time of loading. But i'm just testing it out, now i saw it makes almost no difference.
I also read by using NGEN, u can precompile your assemblies to use, does that help the speed of loading the application?
I'm using an installer for install my project on client pc. So then i have to add a function to execute NGEN in a custom action in my installer?
|
|
|
|
|
Timothy_1982 wrote: to speed up the time of loading. But i'm just testing it out, now i saw it makes almost no difference.
Yeah, it doesn't take that long to calculate a new load address...unless you've got LOTS of .DLL's being loaded.
Timothy_1982 wrote: by using NGEN, u can precompile your assemblies to use, does that help the speed of loading the application?
Yes it does. Probably not as much as you're hoping though. Alot of the overhead you see launching a .NET application is the startup of the Framework itself. There's just about nothing you can do about that.
Timothy_1982 wrote: I'm using an installer for install my project on client pc. So then i have to add a function to execute NGEN in a custom action in my installer?
That's typically how it's done. Since NGEN produces binaries that are VERY processor specific, you can't just NGEN yourself a precompiled app and distribute that to everyone. Best practice is to include the NGEN step in the customer install and NGEN the application assemblies as the last step in your installation, using a custom action.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thx for all the answers, clear and usefull.
|
|
|
|
|
I'm trying to read a text file that just happens to be a log file for a service, and getting the following error.
"System.IO.IOException: The process cannot access the file 'D:\SomeFolder\Logs\Funsv.log' because it is being used by another process."
The exception makes it very clear what the problem is, but I can't find any options in StreamReader that allow me read-only access to a file, even when it's being used by another process. Does anyone know how this can be done?
-- modified at 8:02 Friday 18th August, 2006
|
|
|
|
|
If the process that has the file open for write is using DenyShareRead or DennyShareAll to open it, then you can't open it for reading at all until the service closes the file.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ouch. In that scenario, would it be possible to read the file using WinAPI?
|
|
|
|
|
Matt Casto wrote: would it be possible to read the file using WinAPI?
No, because it's the Win API that is underlying the Stream classes.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I solved this problem by using a FileStream instead of a StreamReader. The constructor of the FileStream allows you to set FileAccess and FileShare which avoids the access problems. The FileStream doesn't allow you to read line-by-line nicely, but I happen to have a class that I re-use often which acts like a TextReader but uses a FileStream in the background.
|
|
|
|
|
You can wrap the FileStream in a StreamReader object like this:
FileStream fs = New FileStream("filepath", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader sr = New StreamReader(fs);
You'll then have all the advantages of the StreamReader, with the access flexibility of the FileStream.
-- modified at 17:47 Friday 18th August, 2006
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I write a client server network program, the client part
using HttpWebRequest to access the server. The server part uses
threading and sockets list to listen the client request.
The program worked fine in .NET1.0 and after I upgraded to VS2005 (NET2.0)
the program didn't work, with the error in client side as "unable to write data to the transport connection, connection closed by program in host".
The strange part is that the error come out in the second access from the
client to the server. The first access to server is OK, but the second access can't connect to the server and generated the error.
I suspect that this may be due to NET2.0 upgrade, but don't know the exact problem. Anyone can help ?
Part of the client code is as below,
try
{
WebRequest request = HttpWebRequest.Create(remoteClientSession.URL);
string contentType = "multipart/form-data;";
request.ContentLength = message.Length;
request.Method = "POST";
request.Timeout = timeoutTime;
Stream requestStream = request.GetRequestStream();
requestStream.Write(message, 0, message.Length); ** error start to throw here
requestStream.Close();
}
catch (WebException webEx)
{
}
catch (IOException ex)
{
** the error throw in here "Unable to write data to the transport connection"
}
WebResponse response = request.GetResponse();
.....
Thanks
|
|
|
|
|
Hi,
i am facing a problem plz if someone can help me.
in visual basic i normally used to do
con.begintrans
any no. of execute commands
con.committrans
on error i can do
con.rollbacktrans
is there something in .net which relates to this technique.
thanks.
Nitin...
|
|
|
|
|
|
Spooky. It's the second time today that I post the exact same answer at the same time as someone else.
---
b { font-weight: normal; }
|
|
|
|
|
Here is an example from MSDN:
using (SqlConnection connection = new SqlConnection(connectString))
{
connection.Open();
SqlTransaction sqlTran = connection.BeginTransaction();
SqlCommand command = connection.CreateCommand();
command.Transaction = sqlTran;
try
{
command.CommandText =
"INSERT INTO Production.ScrapReason(Name) VALUES('Wrong size')";
command.ExecuteNonQuery();
command.CommandText =
"INSERT INTO Production.ScrapReason(Name) VALUES('Wrong color')";
command.ExecuteNonQuery();
sqlTran.Commit();
Console.WriteLine("Both records were written to database.");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Neither record was written to database.");
sqlTran.Rollback();
}
}
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa!
thanks for reply.
its very usefull.
thank You.
Nitin...
|
|
|
|
|
The link and code provided in earlier responses do work well, but they are old ways of performing transactions. .Net 2.0 has a thing called TransactionScope in the System.Transactions namespace.
using (TransactionScope scope = new TransactionScope())
{
using (SqlConnection connection = new SqlConnection(connectString))
{
connection.Open();
SqlCommand command = connection.CreateCommand();
try
{
command.CommandText =
"INSERT INTO Production.ScrapReason(Name) VALUES('Wrong size')";
command.ExecuteNonQuery();
command.CommandText =
"INSERT INTO Production.ScrapReason(Name) VALUES('Wrong color')";
command.ExecuteNonQuery();
scope.Complete();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine("Neither record was written to database.");
}
}
}
TransactionScope has the ability to nest transactions and will also automatically upgrade a transaction into a distributed transaction if you start talking to two or more different databases. And when .Net 3 and WCF come along, WCF services will also be able to participate in the transaction.
Logifusion[^]
If not entertaining, write your Congressman.
|
|
|
|
|
Hi Dustin Metzgar ,
thanks for better way.
thanq you very much.
Regards.
Nitin...
|
|
|
|
|
how can i get the name of a parameter as string.
sample:
-------------------------------------
class abc()
{
public int parametername = 0;
public string parametername2 = String.Empty;
}
class ReadParameterName()
{
// here i want to read the name of any parameter in abc
// i want select the parameter like:
// abc.parametername
}
-------------------------------------
|
|
|
|
|
Reflection is how you do this.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi,
Describe the problem completely.
do you want the list of members from class abc in to the class ReadParametername?
and if u want to pass name of the parameters as string variable then why do u want to do it?
thanks.
|
|
|
|
|
ok, i read an article about reflection!
and found out som new:
-------------------------------------
class abc()
{
public int parametername = 0;
public string parametername2 = String.Empty;
}
class ReadParameterName()
{
Type TypeToReflect = typeof(abc);
System.Reflection.MemberInfo[] Members = TypeToReflect.GetMembers();
// now i get an array with the members of the object 'abc'
// can i get an enum of the membernames in realtime?
???
// so that i can select any membername from the enum like:
string anyMemberName = enumAbcMembers.parametername.ToString();
}
-------------------------------------
|
|
|
|
|
Hi
Here is another way to do the same thing.
If I'm right it's one of the refactoring practices.
Use an object instead of a struct(int,string,...)
You can have a parameter class:
-------------
Parameter
-------------
+Name:string
+Value:object
-------------
-------------
Then one may write
<br />
Parameter param1=new Parameter("abc",0);<br />
Parameter param2=new Parameter("anotherParam",1);<br />
and later:
<br />
string paramName=param1.Name;<br />
I prefer this method because my intention is implied(Everyone can look at the class interface and see what's going on)
Regards
|
|
|
|
|
i want to delete a node in Binary Search Tree, what would i do?
Please guide me. Thanks a lot.
|
|
|
|
|
Hello zoro,
What is the problem?
Can u give structure or class defination of node?
regards,
Divyang Mithaiwala
System Engineer & Software Developer
|
|
|
|
|
i'll send to you my class that define node
public class Node
{
private Node leftNode;
private int data;
private Node rightNode;
//This is propety
public Node RightNode
{........}
public Node LeftNode
{........}
public int Data
{........}
And I don't know how to delete node in binary search tree.
}
please guide to me!
thanks!
|
|
|
|