.net

Implications in calling a .Net exe's main() function

In .net, exes are assemblies and can be referenced just like dlls. This means that any of their types can be used from any other program given they're defined as public. What are the implications in calling another exe's Main function from your code? Obviously the thread that Main is called in would be blocked until the program termin...

How to design windows forms that have the same structure?

In web programming you have one or more master pages and some content pages that in which you add some content to the placeholders or access elements of the master. My question is how to handle windows forms that kinda have the same format, let's say header, content and footer. The footer is always the same, the header may slightly diffe...

Is it possible to prevent EF SaveChanges() from writing to DB?

I have service classes based on Entity Framework 4. I'd like to test them on a database filled with pre-generated sample data. The problem is: I would like the tests, whether passed or failed, to not actually touch the database, so that it may be re-used for other tests. Thus I'd like ObjectContext.SaveChanges to pretend that everything...

Source Code for Paint.NET

Many months or years ago, I think source code is available for Paint.NET , a good tool for edit images, code in C# .NET. But now, I cannot get the source code. I see that paint.net no longer provides source code. If anyone can find Paint.NET 3.36 or older's source. anyone has source code of Paint.NET or can I get the olders versions wi...

What is the difference between Entity Framework and LINQ to SQL by .NET 4.0?

I was checking 2nd edition of Professional ASP.NET MVC and realized EF replaced LINQ to SQL. I am familiar to LINQ to SQL from the first book but I know nothing about EF. Anyway while reading the code, it seems like nothing has changed except the name. Same old repository, same old functions. I did a little research. I know LINQ is not...

C# - Serialization and the Yield statement

Is it possible to serialize a method containing yield statements (or a class that contains such a method) such that when you rehydrate the class, the internal state of the generated iterator is retained? ...

Add Authentication to a Request to REST Web Service?

I am using WCF REST Startkit to create a test REST web service. To test it, I create a simple Console application with HTTPClient (provided by the kit) and HttpResponseMessage to make a request to the REST service. Here are some codes: HttpClient client = new HttpClient(argsParser.BaseAddress); HttpResponseMessage resp = client.Get(args...

Free SFTP client with dll to upload and download file in C#

Hi, I am looking for a SFTP Client which is free. Also it should have a free dll using which I can write code to upload and download file in C# (.NET framework). For example following code is not free, it has 30 days free evaluation, I want it for free, Chilkat.SFtp sftp = new Chilkat.SFtp(); bool success; success = sftp.UnlockCompo...

How can I change the entry point or perform a custom action first in a Windows Setup project?

I have a bit of a noob question about Windows Setup projects here. I've searched vigorously, but haven't yet found any answer. Basically, I'm building a Windows Setup project in Visual Studio 2008. As part of the project, I have custom actions for Install, BeforeInstall, etc. For this, I use a C# class library that contains a class that...

Containing hidden "objects" in ListviewItem, with inheritance?

Hello! I have a listview control, and it's data refreshing continously. I'd like to 'put' an XElement into a row, so I if e.g. double-click on the row, the double-click would call a method, with the 'hidden' xelement parameters. I hope I started to solve it, the debugger doesn't show any errors, but I don't know how to reach the XEleme...

Windows x64 C# x86 console application exe seems to work with "DLL any CPU" Any potential problem ?

My computer runs Windows 7 X64 Enterprise Edition. I need x86 mode for my executable as I use Visual Foxpro OLEDB driver. I thought it was required to compile library DLLs which are used by this exe as "X86". However, DLLs compiled with "Any CPU"seem to work which is quite convenient as they are used somewhere else and no need to main...

Streaming a file from SharpSSH

I'm trying to use SharpSSH to get a file from a remote SFTP server, and I want to read it out as a stream. I found: class Sftp, which has a Get method that saves it to a local file -- close class SshStream, which might do kind of what I want, but seems disjoint from Sftp so I might have to implement the SFTP part myself (??) class Cha...

Is this thread/background worker design for a C# WPF application OK?

Being new to using threads etc in UI's, can I ask is the following simple design seem OK. Refer to diagram image at link here In particular: a) use of backgroundworker & backgroundworker ProgressChanged to have the aggregator work on a separate thread. So I would need a custom class/type that had all the data I'd need to pass back fro...

Is the .NET JIT-compiled code cached? Where?

A .NET program is first compiled into MSIL code. When it is executed, the JIT compiler will compile it into native machine code. I am wondering: Where is these JIT-compiled machine code stored? Is it only stored in address space of the process? But since the second startup of the program is much faster than the first time, I think th...

Starting an uninstaller from code

I would like to add an "Uninstall" button to my program that will start the uninstaller to remove the program and then immediately quit. What's the best way to a) determine if there is an uninstaller present, and b) find the correct uninstaller and launch it? Can I use the registry in a reliable manner? I recall using the registry befor...

Weird error message when running my application

Guys I created a console application in Visual Studio 2010. It targets the .NET framework 2.0. When I run the application is Visual Studio, it works perfect. I then exited Visual Studio and copied the executable to my C:\Windows\System32 directory. When I open a command prompt window and try to execute my program, it comes up with a stan...

Draw horizontal divider in winforms

In the standard windows installer there is a divider between the control buttons on the bottom and the main part of the form. Does anyone know how this would be done in winforms/.net? I've tried fiddling around with the border settings on Panel controls etc, but haven't been able to get the same result... ...

Can an IOC Container AssemblyLoad Event / Static Injection?

I anticipate having various assemblies that each contain a static class, with a static property, that might need to be "set" the moment the assembly they are in is loaded. This other post has an example of a static class that could benefit from such a procedure, such as when integration or unit tests are applied. I wonder if there is an...

C#: How to get the size of available system memory?

Is it possible to get the size of system available memory in C#.NET? if yes how? ...

Creating a service for monitoring

As an exercise in both writing Windows Services and communicating with them, I've decided I want to try and write a service to monitor hardware performance on my machine, record it and report on it daily. I want to be able to query the service remotely and from researching this a little, I think I could embed a ServiceHost in there. Ho...