.net

OO Pattern: Shared work between abstract base class and subclasses

I have an abstract base class T, from which classes A and B inherit. I now have an operation (on T) which requires a slightly different implementation in A and B, but most of the code is the same. Let me give you an example: There are two possibilities to implement something like a .Clone method: Public MustInherit Class T Protected...

Performance gains when compiling .NET 1.1 COM+ components code with .NET 3.5 compiler

Hi. I need to build a service in form of a COM+ component using Enterprise Services. The service is working right now. It gets a string does some spell-checking and returns a string. My question is: This component was compiled in .NET 1.1 but my environment is going to change to .NET 3.5 soon. So if I compile the code in .NET 3.5 (w...

how to burn the files selected from listview in a dvd using c#.net code ?

can any expert help me out to solve a problem of burning a dvd using c#.net as a front end?? i need to select files from the listview in winform and then on button click i need to burn those multiple files in the dvd.. the concept is to select the multiple files from listview then on button click it should make a folder in some desired d...

Specify the error URL for when ClickOnce deployment fails

ClickOnce security causes deployment of an application to fail if the new installation location is different from the previous one. Typically, this is the message one gets: You cannot start the application from this location because it is already installed from a different location. Click here to send this error to the ...

TextWriterTraceListener and trace filenames with GUIDs

I use TextWriterTraceListener (System.Diagnostics) in my application to trace several things like exceptions,... The application is running on a terminal server and if there are many users using it simultaneously the listener starts to create many tracefiles with random GUIDs in the filename. Are there possibilities or workarounds to ...

Export a .Net Panel Control to an Image

I'm developing an application in VB.Net (VS2008) which allows the creation of classroom layouts. The layout is a panel and has child panels (seat objects) the seats are then populated using drag and drop and show a preview of the person sitting there. I would like to export this panel to a printable format such as jpeg, pdf etc. I have...

Can't catch exception thrown by Invoke on a compiled expression

In the class: private Func<T, object> pony; In my function: object newValue; try { newValue = pony.Invoke(model as T); // This is the line where I get an exception! } catch (Exception exception) { // This code is never run, even though I get an exception two lines up! if(exception is DivideByZeroException) throw new DivideByZer...

.net: Is assigning an object reference atomic (i.e. thread-safe)?

Let's say I have some variable x (of type myClass), which is initially null and some assignment x = myObject occuring exactly once in some background thread. Is it guaranteed that x always contains either null or myObject when accessed from the main thread? Or is it possible that x contains some invalid data shortly? ...

Format decimal to string in correct culture info

Hi what is the best way to format a decimal amount to string for ui display in the correct culture info? Many Thanks ...

Can you do a RunCustomTool with EnvDTE as a pre-build event?

I am using T4MVC, and I can't use a pre-build event to run TextTransform.exe as it relies on EnvDTE, and must be run with Visual Studio as host. If I have run custom tool once, it works nicely because it marks itself dirty when its executed (AlwaysKeepTemplateDirty = true), but when you open the solution, it doesn't run on build, so I w...

Application.SetCompatibleTextRenderingDefault(false);

Application.SetCompatibleTextRenderingDefault(false); Error : Before the establishment of the first object IWin32Window in the annex to call SetCompatibleTextRenderingDefault. why error ? how to avoid ? and ... what SetCompatibleTextRenderingDefault actually makes :) ...

Why won't control update/refresh mid-process.

I have a windows form (C#.NET) with a statusLabel that I can not seem to get to update in the middle of a process in event handler methods. My code looks like this... void Process_Completed(object sender, EventArgs e) { string t = "Process is finished!"; this.Invoke(new StatusLabelUpdator(updateStatusLabel), new...

How to fix my crawler in C#?

Regex hrefs = new Regex("<a href.*?>"); Regex http = new Regex("http:.*?>"); StringBuilder sb = new StringBuilder(); WebClient client = new WebClient(); string source = client.DownloadString("http://google.com"); foreach (Match m in hrefs.Matches(source)){ sb.Append(http.Match(m.ToString())); Console.WriteLine(http.Match(m.ToString()))...

Visual Studio uses UserControlDesigner instead of CustomDesigner

Hi! I've got an ASP-UserControl QuestionWithAnswer (.ascx) : BaseQuestion : UserControl and a ControlDesigner QuestionDesigner : UserControlDesigner. Now i use the DesignerAttribute to associate control and designer: [Designer(typeof(QuestionDesigner))] public class BaseQuestion : UserControl all types are in the same assembly (WEB A...

Save new or update with LinqToSql, transactions?

I have a table with hit statistics for some items in another table. This table is defined like this ID (Primary key) ItemId (Foreign key) Date Hits Giving me have a record pr. item pr day. The database is used in a multithreaded environment, so two users might make the first hit at the same time causing two records to be created, w...

Alternative to xsd.exe in Visual Studio 2010

Looks like XSD.exe is not delivered as a part of Visual Studio 2010. what is the alternative being offered in VS2010? ...

Whats the best name for a wrapper that provides thread safe adding, removing, iterating over a collection to various objects?

This is a bit of weird scenario. I had a class that was quickly becoming a God class. It was doing WAY too much. Suddenly I had violated SRP. The class was responsible for X and Y and Z, oh and A, and B, don't forget C. So I decided to refactor it. The reason it got this big is because the class does a lot of work with a collection which...

How should the performance counter "# of Methods Jitted" be interpreted?

While trying to reproduce a reported problem with a managed nt-service, I've noticed that the performance counter "# of Methods Jitted" is constantly increasing (together with "# of IL Bytes Jitted"). The reported behavior consists of taking alot of memory (not necessarily everything available on the machine) and consuming 100% cpu. Requ...

Controls appear inactive when changing content

I'm using a ContentControl to display various ViewModels, which all use DataTemplates for view generation. Now the problem is, after i change the content (by clicking on a hyperlink for example), things such as hyperlinks appear inactive (i.e. grayed out), until i click on the UI again. Is there any way to avoid this behaviour without ha...

How to measure the total memory consumption of the current process programatically in .NET?

How to measure the total memory consumption of the current process programatically in .NET? ...