|
|
typical story, new to c# and got a, probably stupid, question!
I am trying to compile the code at http://www.codeproject.com/dotnet/pinvokeaddshare.asp
Its intended to create a file share.
When I run the code it throws a System.Security.SecurityException.
I put the responcible line in a try | catch block, just in case it was a problem with the code and checked exceptions.
I examined the code and the return from the method called in the erroring line returns a status code which says that the share was created but it was not.
I am an admin of the locel machine, which is where I am creating the share.
What I am thinking now is that Visual Studio executes code in a sandbox kind of arrangement and a security level has to be specified for executing code!!! does this feature exsits?
Any ideas!
|
|
|
|
|
Hi
if I read command line args I get results of @"line\nline2"
how can I convert this into "line1\nline2"?
In other words: how to remove the '@'?
Ariadne
|
|
|
|
|
|
leppie wrote:
They are the same thing, the @ only defines different escaping routines.
ok, but how can I change the escaping routine.
if I do: sPrompt=args[i] and args[i] contains a '\' the real string of sPrompt is something like: @"...\...", but I want show this prompt in MessagBox without this '@' escape function. ie. I want show more than one line, if I get in args[i] a '\n'
thanks!
Ariadne
|
|
|
|
|
|
The escaping routine is for the compiler, and not for the string itself.
If you do Console.WriteLine("line1\\nline2") or Console.WriteLine(@"line1\nline2") , you'll get the same output:
line1\nline2 In the first case, to insert a backslash in the string, you need to double it (otherwise it will be interpreted as a special character: eg. \n as newline). In the second example, the @ means that a different escaping will be performed (most special characters won't be escaped) so \n produces exactly that, \n .
The @ makes a difference when specifying paths in code:
string path1 = "C:\\Program Files\\Microsoft";
string path2 = @"C:\Program Files\Microsoft"; In memory, both path1 and path2 will contain exactly the same.
If you read the string from anywhere typed by the user, you don't have to worry about escape characters. If he types one backslash, you'll get it. Escaping is only when specifying strings in code.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
Luis Alonso Ramos wrote:
The escaping routine is for the compiler, and not for the string itself.
no, I think not, because I get the '@'-problem at runtime.
but I'm happy leppie solved the problem with
sPrompt=sPrompt.Replace(@"\n","\n");
It works!
Thanks leppie
Ariadne
|
|
|
|
|
What that particular line of code is doing is replacing the characters \n (backslash followed by an n ) with an actual newline character. It is the exact equivalent of: sPrompt = sPrompt.Replace("\\n", "\n") .
Somehow you read the sPrompt string from somewhere that doesn't support escaping of characters (a resource maybe?) so you ended up with the characters '\' and 'n' in memory, instead of the actual newline (char 13) character.
But the escaping only works when specifying strings by code, and it's performed by the compiler.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
|
|
|
|
|
I have a .net windows client application that queries a .net web service. After the client has called the web service if netstat is run from the command line the results will show 10 sockets still open. Below is the code from my client app. My questions are
1. Why does the client app need 10 sockets?
2. What can I do to force the closing of the sockets since the GC.Collect() & GC.WaitForPendingFinalizers() methods don't seem to be doing it?
3. Does it really matter if the sockets are not immediately closed?
Private Sub LogIn()<br />
If IsUserOffLine() Then Exit Sub<br />
Dim wsEmpInfo As EmpInfoWS.EmployeeInformation = BF.SetUpWS()<br />
Try<br />
wsEmpInfo.SetEmployeeCheckIn(BF.GetUserName, txtLogInComments.Text)<br />
Catch Ex As Exception<br />
Call IsUserOffLine()<br />
Finally<br />
wsEmpInfo.Dispose()<br />
End Try<br />
Dim tRefreshForm As New Thread(New ThreadStart(AddressOf RefreshForm))<br />
Try<br />
tRefreshForm.Start()<br />
Catch ex As Exception<br />
tRefreshForm = Nothing<br />
End Try<br />
End Sub<br />
<br />
Private Sub RefreshForm()<br />
Try<br />
Call PopulateForm()<br />
Call HandleNotify()<br />
Call ShowScrollingNote()<br />
Call CleanUp()<br />
Catch<br />
End Try<br />
End Sub<br />
<br />
Private Sub CleanUp()<br />
Try<br />
GC.Collect()<br />
GC.WaitForPendingFinalizers()<br />
Catch<br />
End Try<br />
End Sub
I appreciate any suggesting you have, thank you.
Jason W.
|
|
|
|
|
It would be very useful to provide the code where you actually call the web service.
www.troschuetz.de
|
|
|
|
|
Not sure if this helps but it's worth a try.
<br />
Public Function SetUpWS() As EmpInfoWS.EmployeeInformation<br />
Dim wsEmpInfo As New EmpInfoWS.EmployeeInformation<br />
wsEmpInfo.Url = GetEmpInfoWSURL()<br />
wsEmpInfo.Credentials = System.Net.CredentialCache.DefaultCredentials<br />
Return wsEmpInfo<br />
End Function<br />
Jason W.
|
|
|
|
|
|
Here is what netstat is showing.
<br />
TCP COMPUTERNAME:4483 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4484 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4485 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4486 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4487 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4488 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4489 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4490 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4491 111.111.111.111:https TIME_WAIT<br />
TCP COMPUTERNAME:4492 111.111.111.111:https TIME_WAIT<br />
Jason W.
|
|
|
|
|
|
Cool, is there a site that tells about the socket status options. I need to point my manager to it so he will get off my back. Thank you for the help.
Jason W.
|
|
|
|
|
|
Trust me I would love to tell him that, at this point I can't however.
Jason W.
|
|
|
|
|
|
|
|
|
|
If it isn't a problem I would like to pick your brain a little more. I found an article that says 'The side shutting down the connection gets the TIME_WAIT.' is this true. If it is then I don't need to worry about causing a denial of service on the server. Thoughts?
Jason W.
|
|
|
|
|
I need to create a program that can simultaneously turn on up to 4 timers that do not control events, but simply record time down to at least a hundredth of a second. This timer must be visibly updated every hundredth of a second on a form to inform the user of the duration of the processes the program is performing. Is there a way to do this in C#? I looked into the Timer control, but can't figure out how to make it work for this purpose.
|
|
|
|
|