.net

Ignoring white space for a Regex match

I need to match 8 or more digits, the sequence of which can include spaces. for example, all of the below would be valid matches. 12345678 1 2345678 12 3 45678 1234 5678 12 34567 8 1 2 3 4 5 6 7 8 At the moment I have \d{8,} but this will only capture a solid block of 8 or more digits. [\d\s]{8,} will not work as I don't want white s...

How to send the tracing output to a file in the file system ?

I have added the following code to my web.config file: <system.diagnostics> <trace autoflush="false" indentsize="4" > <listeners> <add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="d:\debugging.txt" /> <remove name="Default"></remove> </listeners> ...

How to get user name and password from url in ASP.NET?

How can get in ASP.NET user name and password from URL? https://myUser:myPassword@myServer/ HttpContext.Current.Request.Url is returning https://myServer/. ...

How to parse PDF streams in .Net

I have some free C# code to parse PDF files, which I downloaded. I have written code using these classes to extract information about the form fields, and generate a new PDF with the form fields populated. Now I've discovered that it doesn't work with new PDF's, because new PDF's have streams where the old formats had plain text. I do...

Exception on ConvertTimeToUtc

Hello I have an exception when converting local time to UTC. I run my application on Windows where "Russian Standard Time" is set. public Convert() { DateTime dt = DateTime.Now; DateTime dt1 = DateTime.Now; // this converstion works TimeZoneInfo.ConvertTimeToUtc(dt, TimeZoneInfo.Local); ...

Handling Exceptions in a .NET 4.0 Task Parallel Library Task

I'm working on a Web Hook in .NET 4.0 that will run a lambda asynchronously and then post the result to a given URI when it is finished. I've got that to work, but now I want the Task to handle any exceptions that are thrown, and am finding it difficult to stop them from reaching the parent. Here's part of my code: private readonly Fu...

What happens to Cache when Application Pool recycles?

I have web application on IIS6 Win2003. This application connected to w3wp.exe process which reaches 50-70% of CPU after 3-4 minutes it was recycled ( forced one ). I have few places with Cache in this project so my questions concern the case if i set AppPool recycle limits and the process will recycle every few minutes to avoid high CPU...

How To Refresh State of CollapsiblePanelExtender Without Reloading Page

Hi, I'm working on a specific part of a website that displays a blog and allows users to comment on the blog. Currently, the page starts with a bar with the title of the blog post, who posted it, and the amount of comments on the blog. When you click on the title it expands downwards and displays the blog. Below this, there is a bar sta...

File.Create is appending to the file rather than overwriting it.

Sorry all, but there was some other problem. The code is now working correct. Thanks all. I have the following code for creating a file if it does not exist and overwriting it if it already exists: FileStream fsExe = File.Create(DestExePath, 4096); BinaryWriter bw = new BinaryWriter(fsExe); What ever I write to the BinaryWriter, i...

How to detect an anonymous object with .NET Reflection?

Possible Duplicates: How To Test if a Type is Anonymous? Anonymous Types - Are there any distingushing characteristics? Is there a way to detect if a Type object refers to an anonymous object? var obj = new { A = "Hello" }; Type x = obj.GetType(); // is there something equivalent to x.IsAnonymous? Assert.IsTrue(x.IsAnonymou...

How to make the ActiveDirectoryMembershipProvider accept an empty password?

We are developing a web application that uses forms authentication and the ActiveDirectoryMembershipProvider to authenticate users against the Active Directory. We soon found out that the provider does not allow a blank/empty password to be specified, even though this is perfectly legal in the Active Directory (provided a preventative pa...

Using nested Parallel.For

Consider this example: var x = 0; for (var i = 0; i < 100; i++ ) { for (var a = i+1; a < 100; a++) x += 1; } When printing x we always get 4950. What about if I want to parallelise this? This is what I come up with Parallel.For(0, 100, i => Parallel.For(i + 1, 100, a => { x += 1; })); However this does Not print 4950 ...

Silverlight toolkit. Treeview drag and drop functionality

Why drag and drop doesnot work with my code: <toolkitDrag:TreeViewDragDropTarget AllowDrop="true" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" BindingValidationError="TreeViewDragDropTarget_BindingValidationError" ItemDroppedOnSource="TreeViewDragDropTarget_ItemDroppedOnSource" ItemDroppedOnTarget="TreeVi...

Share code between website/web application project and Script#/ScriptSharp

I added a Script# project to my website project and created a small sample library with two classes. Now I want to use these classes from the website code. In this case, I created a simple object tree and serialized it to JSON (which would then get fetched by the client-side code). I tried adding a reference to the Script# project. It ...

I think there is an issue with IDisposable example.

Possible Duplicate: Am I implementing IDisposable correctly? Hi, I am referring this post to check the use of IDisposable. I see an issue in Dispose method here. In the code "disposed" is used only in the private void Dispose(bool disposing) method. I believe it should be used before calling the "Dipose" method and co...

Persistence problem with a Stream variable

Hi, I have a workflow service which receives a stream through a ReceiveRequest activity. The workflow works well, but if I try to persist it I have an exception (Cannot access a closed stream) which I think is related to the stream object. The object received is similar to this: public class MessageContext { public Stream Content{get...

Type.InvokeMember and reference types

I'm trying to use Type.InvokeMember(String, BindingFlags, Binder, Object, array[]) with the default binder. one of the arguments to the target method in the object array is a reference type set to null. I want the method I'm invoking to instantiate the reference type so that I can continue using it. For example: using System; namespac...

How do i draw my "user control UI" faster and more efficient

Hi, Actually I made a user control that its interface is like "glass windows" in windows vista and seven. My pattern was this url: extremestudio.ro/blog/?p=99 using "Photoshop" and draw every layer with C# and .Net drawing classes, I finally draw it. In first step, i create a bitmap class and then each layer will be drawn on it using gr...

Get timestamp from Authenticode Signed files in .NET

We need to verify that binary files are signed properly with digital signature (Authenticode). This can be achieved with signtool.exe pretty easily. However, we need an automatic way that also verifies signer name and timestamp. This is doable in native C++ with CryptQueryObject() API as shown in this wonderful sample: How To Get Informa...

Data persistance in class library between one class methods

I am creating a class library for AutoCAD with .NET. The problem is that the methods are called one after another from AutoCAD and first one reads input file and creates List of data in memory. However when the new one is called the list is empty. I need to find a solution how to keep that data. The List contains data in my created s...