|
Looks like it requires source code changes to work. I'm not inclined to do that.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Gendarme doesn't, it is pure assembly (MSIL) analysis, just like FXCop, but the difference is that gendarme is based on open-source Mono.Cecil library, whereas the Microsoft.Cci (which is actually very good by itself) is not redistributable apart from fxcop. At least it wasn't last time I checked (two or three months ago)
Regards,
Lev
|
|
|
|
|
Ah that thing drove me nuts :P
|
|
|
|
|
Hopefully in a good way... although (pea)nuts are good especially at Christmas time and with raisins
|
|
|
|
|
I have .NET 2.0 client code attempting to negotiate an SSL session with stunnel. stunnel is currently configured to allow SSL3 connections.
A call to AuthenticateAsClient , exclusively supplying SslProtocols.Ssl3 will succeed.
So far, all working as I'd expect
I want the .NET client to retrograde the SSL version when it connects to a server offering an older algorithm. The SslProtocols is a flag-attributed enumeration. I'd expect to pass multiple protocol versions like so:
sslstream.AuthenticateAsClient(Host, ClientCertificates, SslProtocols.Ssl2 | SslProtocols.Ssl3 | SslProtocols.Tls, true);
However, the above method call results in the following .NET exception & stunnel log trace:
Client-side Exception:
System.IO.IOException:
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
Server-side Log
2008.12.19 10:40:50 LOG7[5600:10944520]: pop3s accepted FD=10 from 192.168.20.6:3293
2008.12.19 10:40:50 LOG7[5600:11063160]: pop3s started
2008.12.19 10:40:50 LOG7[5600:11063160]: FD 10 in non-blocking mode
2008.12.19 10:40:50 LOG7[5600:11063160]: TCP_NODELAY option set on local socket
2008.12.19 10:40:50 LOG5[5600:11063160]: pop3s accepted connection from 192.168.20.6:3293
2008.12.19 10:40:50 LOG7[5600:11063160]: SSL state (accept): before/accept initialization
2008.12.19 10:40:50 LOG3[5600:11063160]: SSL_accept: 1408F10B: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
2008.12.19 10:40:50 LOG5[5600:11063160]: Connection reset: 0 bytes sent to SSL, 0 bytes sent to socket
2008.12.19 10:40:50 LOG7[5600:11063160]: pop3s finished (0 left)
When I omit SslProtocols.Ssl2 from the parameter value, it results in a different condition.
Client-side Exception:
System.Security.Authentication.AuthenticationException:
A call to SSPI failed, see inner exception.
---> System.ComponentModel.Win32Exception: The client and server cannot communicate, because they do not possess a common algorithm
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
So I guess my question is: Is it misconfiguration of my behalf, or do I need to manually crank code to manage the protocol retrogradation?
Many thanks, Ian.
|
|
|
|
|
I can get WindowsIdentity with this Function:
[DllImport("advapi32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool LogonUser(string lpszUsername,
string lpszDomain, string lpszPassword, int dwLogonType,
int dwLogonProvider, ref IntPtr phToken);
private static WindowsIdentity getWindowsIdentity(string userName, string Domain, string Password)
{
bool posix = ((int) Environment.OSVersion.Platform == 128);
WindowsIdentity user = null;
try
{
if (posix)
{
user = new WindowsIdentity(userName);
}
else
{
IntPtr token = IntPtr.Zero;
LogonUser(userName, Domain, Password, 2, 0, ref token);
if (token == IntPtr.Zero)
{
return null;
}
user = new WindowsIdentity(token);
}
}
catch (Exception ex)
{
return null;
}
return user;
}
But I want to get WindowIdentity with only Domain\UserName argument?
Thanks for any idea !
QuynhTD
|
|
|
|
|
Wow. That's alot of code to do this:
string userName = Environment.UserName;
string userDomain = Environment.UserDomainName;
|
|
|
|
|
No, I don't want those information. I want to get WindowsIdentity object from username.
I want to have a function that :
WindowsIdentity identity = GetWindowsIdentityFromUserName(string userName) ???
QuynhTD
|
|
|
|
|
OK, I misunderstood what you were after. .NET 2.0 and above has the System.Windows.Principle namespace, but that WindowsIdentity class can only return the currently logged on entity, unless your attached to a Windows 2003 domain.
What are you trying to do with this??
|
|
|
|
|
 In fact I want to get,set all permission (Read, write, ..in FileSystemRights) in Folder's ACL of one user on WinNT.
I solved it but I have to get WindowsIdentity object of user . Here is the code:
public void SetFolderPermission(string userName, string fullPath, AccessControlType accessControlType,
FileSystemRights fileAccessPermisson)
{
var dInfo = new DirectoryInfo(fullPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
dSecurity.AddAccessRule(new FileSystemAccessRule(userName, fileAccessPermisson,
InheritanceFlags.ContainerInherit |
InheritanceFlags.ObjectInherit, PropagationFlags.None,
accessControlType));
dInfo.SetAccessControl(dSecurity);
}
public void RemoveAllFolderPermission(string userName, string fullPath, string password, string domain)
{
WindowsIdentity _principal = getWindowsIdentity(userName, domain, password);
if (_principal == null)
{
throw new Exception("Invalid domain\\username or password");
return;
}
var dInfo = new DirectoryInfo(fullPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
AuthorizationRuleCollection acl = dSecurity.GetAccessRules
(true, true, typeof (SecurityIdentifier));
int count = acl.Count;
int i = 0;
while (i < count)
{
var rule =
(FileSystemAccessRule) acl[i];
if (_principal.User.Equals(rule.IdentityReference))
{
dSecurity.RemoveAccessRule(rule);
}
i++;
}
dInfo.SetAccessControl(dSecurity);
}
[DllImport("advapi32.dll", CallingConvention = CallingConvention.StdCall)]
public static extern bool LogonUser(string lpszUsername,
string lpszDomain, string lpszPassword, int dwLogonType,
int dwLogonProvider, ref IntPtr phToken);
private static WindowsIdentity getWindowsIdentity(string userName, string Domain, string Password)
{
bool posix = ((int) Environment.OSVersion.Platform == 128);
WindowsIdentity user = null;
try
{
if (posix)
{
user = new WindowsIdentity(userName);
}
else
{
IntPtr token = IntPtr.Zero;
LogonUser(userName, Domain, Password, 2, 0, ref token);
if (token == IntPtr.Zero)
{
return null;
}
user = new WindowsIdentity(token);
}
}
catch (Exception ex)
{
return null;
}
return user;
}
Maybe do that with out using WindowsIdentity ???
QuynhTD
modified on Friday, December 19, 2008 11:47 PM
|
|
|
|
|
The code for setting the folder permission is good, but since removing a permission is just about the same as setting it, you'd have to think that code would be about the same size. I hate to say that you solved the problem, but went way beyond what's required to get the job done.
Have a look at this example[^] discussion.
|
|
|
|
|
OK, your ideals are very helpful. Thank u very much!
Rdgs,
QuynhTD
|
|
|
|
|
how to add an image into a botton?? its like how to show a image of a printer rather than a "print"??
|
|
|
|
|
use the Image property in the property window or use Button1.Image to assign dynamically.
|
|
|
|
|
Hi... how to convert code in vb6.0 into vb.net
|
|
|
|
|
|
Be ready for some potential issues.
Tan Li
I Love KongFu~
|
|
|
|
|
Just wanted to be sure to let people know about this special program that is free for the asking from Microsoft.
If you're a software company developing your software application on Silverlight, Windows Presentation Foundation (WPF), Internet Explorer 8, or Windows Vista then a new Front Runner for Innovate On User Experience is for you. When you join, you’ll have technical coaches for Microsoft runtimes and design, support, and marketing benefits.
Front Runner for InnovateOn: User Experience is for independent software vendors (ISVs) and Value Added Partners (VAPs) has started in the United States. Particpants receive:
- Four hours of phone based tech support.
- Design capability consultation.
- Free training.
On the marketing side you'll receive public relations templates, can use of Front Runner Logo, profile your solution to be highlight on Microsoft sites, and discounted case studies.
To receive marketing benefits register a user experience solution that you intend to build or have built on one of the four Windows Client technologies.
Register at Front Runner
|
|
|
|
|
Hi,
I'm working on a calculation module which handles a lot of small calculations. A sqeuencial approach is not feasible due to the amount of calculations (the biggest batch is approximately 15 million calculations) and my initial run projected 83 days in the worst case scenario. This is too long.
Since the threadpool is described as a good solution for many short calculations, I decided to give it a try. My implementation works on a small scale (15k calculations) and performs acceptable given 40 threads (dual-core, so max ideal number is max 50 according to the msdn documentation, but then the system threads are starving and timers run out of sync and GC freezes).
My only problem is, when I feed my small jobs to the queue, it fills the first batch of empty threads and then continues queuing, but *not* executing the jobs which are queued for processing. At a certain point, on the small scale, it has completed queuing, and *then* it starts processing the requests very fast. This is not sustainable, since when filling the queue, the system slowly grinds to a halt queuing slower per job.
To get an idea of a run: one calculation costs 25-500ms to complete, around 15 calculations per context, and about 1 million contexts to be processed per run.
Anyone can help me find an answer why the threadpool continues to queue but not process the queued jobs until the queuing is complete? Thanks in advance.
The consumer isn't a moron; she is your wife.
|
|
|
|
|
Helfdane wrote: Anyone can help me find an answer why the threadpool continues to queue but not process the queued jobs until the queuing is complete? Thanks in advance.
Even if they can, you are chasing the wrong problem. With only two cores you are not gaining anything by trying to pool a million operations. There is a logical maximum benefit of running twice as fast by using both cores equally. However you cannot attain the maximum because there is overhead of managing the pool and context switching between threads and other resources being used by the system.
You might be better off just creating two threads and splitting your operations in half running half in each thread.
Since you did not mention it, I should ask if you know about distributed computing? This would be the most common solution using PC's to reduce a 83 day workload.
led mike
|
|
|
|
|
Thank you and Dave for your replies.
Distributed computing is not an option, since it's an application that is installed at the customer and has to run standalone (it's a critical application where most clients prefer to hook it off the network).
About the threads, I was only following the MSDN documentation where they mention that 25 threads per core is the max ideal number where the overhead would still be smaller than the improvement per thread.
I forgot to mention, each calculation *might* need some additional information from the DB, hence the threading.
My problem is not the load or the number of threads, they are parameters on an existing infrastructure. My question is, why the threads are not working (are they on hold/in wait?) while queuing the jobs (is this infrastructure the right one?). Since you and Dave Kreskowiak propose less threads which I can agree on, the queuing will still be there, thus my problem still exists as the queuing still takes time while the threads do nothing (cpu load during queuing is not above 40%, so the other 60% should be used to do the first calculations but it doesn't use the 60% unless queuing is completed).
The consumer isn't a moron; she is your wife.
|
|
|
|
|
Helfdane wrote: the MSDN documentation where they mention that 25 threads per core is the max ideal number where the overhead would still be smaller than the improvement per thread.
Yes but for what use model? Threading is mostly related to multi-user processing. You want to maximize threads in that use model to share the compute cycles across users so that they don't wait one at a time for a reply. This is not your use model.
Helfdane wrote: why the threads are not working (are they on hold/in wait?)
Debugging threaded code is difficult when you are there, we are not. We are mostly guessing at this based on the information you have provided. One thing we do not know is how many jobs you queued. You threw out some numbers like 15 million. That's a large number for a PC. Given your use model I would research using two threads and a design that allows each thread to process half the calculations.
Resources are another issue when you start talking numbers like 15 million. I would wonder how much resources each calculation requires, I mean if there is some source data used for each calculation and you load all 15 million calculation resources at once you probably start having a lot of paging which slows everything down, as opposed to getting the resources only when needed.
I don't know what your experience and background is but writing efficient code requires a lot of in depth knowledge and experience. You have to understand hardware as well as software. Most of that is beyond my expertise, but I do understand you can't just read a threading article to get up to speed.
led mike
|
|
|
|
|
You have valid points, thanks for your input.
We are talking a multi-user environment, that is, multiple users can do a request for a number of calculations (there is one dispatcher which processes the requests by transforming it into the format used by the calculation engine. This dispatcher will probably have a WCF component for the thin clients to talk to, this is not final yet. In addition, the dispatcher will have the possibility of throttling the requests if the queue becomes too big, but that is something I haven't worked out yet; it's still on the drawing board). The dispatcher is designed to also monitor the system resources, as on which it will base his throttling and batching strategy. This should lessen the preassure on the hardware as well.
The test-case I had was 15k calculations (1000 base calculations with 15 subcalculations each in testing data). This means that when the calculation starts, 15k calculations are in the queue. The thing which hints me that nothing is happening is, that when queuing the first action of a calculation, the calculation routine is sending a notification to the console that it is starting, but the starting message never gets there unless queuing is done and so is the load.
I am not sure if my current infrastructure will be sufficient, hence my research and these forum postings, as I am not sure if I want to use a component (the threadpool in this case) where I cannot predict exactly what will happen. I think I do need threading since missing parts required for a calculation need to be fetched from the DB and/or are dependant on other calculations.
My background is saas with an average load of 500+ simultanious connections for clients who operate globally. My background is not primarily with .net.
The consumer isn't a moron; she is your wife.
|
|
|
|
|
Helfdane wrote: performs acceptable given 40 threads
40 threads on a dual core? It can perform better if you use few threads. Under that load, you're spending an awful lot of time doing context switching going from thread to thread to thread.
|
|
|
|
|
Didn't I say that?
led mike
|
|
|
|
|