.net

How do I run processes synchronously, targetting the same output?

I have a .Net application that needs to run several executables. I'm using the Process class, but Process.Start doesn't block. I need the first process to finish before the second runs. How can I do this? Also, I'd like all of the processes to all output to the same console window. As it is, they seem to open their own windows. I'm sure...

Help with Windows PowerShell

I'm trying to access a method of text file, I use this first: Get-Item file.txt | get-member Then I would like to use the GetType() method, but it says it doesn't recognize file.txt as the name of a cmdlet,function,script file or operable problem. I need to access that or any other method :D ...

Service Layer: 1 Instance Per Application or Per View Model? (Or: giving each view model its own data context)

Hello, I'm building C#/.Net 3.5 app using three layers: UI (view/view models), service, and data access/persistence. Service Layer: Each service layer instance is associated with a unique persistence instance. The service layer references the persistence layer via an interface. Persistence Layer: Right now, the persistence layer in...

Why does the DataContractSerializer bypass initializers?

Why does the DataContractSerializer bypass initializers? Background: The serialization formatter gets uninitialized instances of classes during deserialization. That is, instances where all fields are set to their default values. For reference types this will be null. That is why "authors" in this case causes a null reference except...

Which is faster: Working from memory or lots of queries?

You need to pull a large amount of data (thousands of entries) from a local SQL server to be used in generating a report. You have two options: 1) Use a single query to get the data from the server, load it into a .NET data table and use a series of loops to get the information you need 2) Perform an SQL query each time you need a rec...

How do you pass user credentials from one process to another for Impersonation in .NET 1.1?

I have a Windows Service (written in .NET 1.1) running under a specific user account and instances of the service running on several servers. I would like to pass user credentials (username, password, domain) to the service from a WinForms application and have the service read/write files in the server's local file system impersonating...

What good .NET/COM book are out there?

I've been working as .NET developer for a few years now and have no other windows development experience worth noting. Now I'm in a position where I have to use and maintain .NET code that uses older VB6 code. Other people are maintaining and replacing this code but for the next couple years I'll have to live with it. As far as I can t...

Learning new Microsoft .net technologies

Dear StackOverflow, :-) For the past eight months or so, I have been banging my head on my keyboard out of frustration because I can't make Windows Identity Foundation do the things that I want it to do. Even more frustratingly, WIF doesn't seem to enjoy the widespread adoption of many other MS .net technologies. I often cannot find w...

Regular expression. Begins with and not equal to

I have a string that needs to be validated. The first two characters must be made up A-G, or Z, but cannot be the following combination: GB or ZZ. How do I express that in a regular expression? ...

How to programatically set menu shortcut keys in .NET?

In my application, I have a "recent files" drop down menu. It will contain anywhere between 0 and 9 files to load. I want to set shortcut keys on these menu items such that Ctrl+1 loads the first file, Ctrl+2 loads the second, etc... I understand that I need to set the ShortcutKeys property of the ToolStripMenuItem but I am looking for ...

Cannot find MS.Internal.Media namespace in assembly

I've been working on a WPF application. Since I design the UI in Expression Blend 4 and work on the code-behind part in Visual Studio 2010, I constantly switch from one tool to another. I added some Image controls to an existing Grid and assigned some images to them. In Blend, I built the project and ran it. Worked just fine. When I swi...

Best method for serializing objects in .NET (as of v4.0)

I have an simple custom object called MyObject (a couple of basic properties and a List(of MyObject), so it's recursive) that I need to serialize for storage. I'm not sure if I'll serialize to XML or Binary yet, but I want to make sure I'm using the most up-to-date methods for doing it, as there are a few different namespaces involved an...

.NET - Storing An App.config With A Class Library

This seems to be asked a lot on the internet, but so far my research hasn't produced a solution. (And, at least for now, I haven't accepted "it can't be done" as a solution.) At its simplest description, what I'm trying to do is have a config file in a .NET class library project that is available to that class library in any applicatio...

Resharper custom search pattern to warn IDisposable objects

Since resharper still doesn't give out any warning regarding objects implementing IDisposable, I'd like to create some custom search patterns available in resharper 5.0. So far I have this: (And don't mind my replace comments in the patterns, I don't really care about it, I just want a clear warning in the code when dealing with dispos...

Is it possible to access a .Net Web Service using HttpClient/HttpPost?

Dumb question, but I just can't seem to get it to work. I'm passing in parameters and returning string values, but all I receive is: org.apache.http.conn.EofSensorInputStream. Do I need to do something special in my web service to access the parameters being passed? ...

How to determine if the type of a DataColumn is numeric, string, or datetime?

I need to format output according to the type of the DataColumns in a DataTable. Specifically, I need to map the built-in primitive types (int, string, decimal, DateTime, etc) to: SomeEnum.Numeric SomeEnum.Bool SomeEnum.DateTime SomeEnum.String SomeEnum.Unknown SomeEnum.Null How could I do this? ...

How to sniff a caught exception in .NET on production machine?

Is there a way to find what exception was caught by .NET code from the outside of the application? I found that 3d party API throws an exception and suppresses it (I see the perf counter going up). But it doesnt shows it in trace (I tried sysinternals dbgView). What tool can show a caught exception? ...

Problems with Asp.net Mvc 2.0 Web.config.debug/release....System.UnauthorizedAccessException was unhandled by user code

Hi I am trying to use the debug and release versions of the webconfig but it never works. I am trying to do this for a 3rd party library that I am using called combres. http://combres.codeplex.com/ So I first put all the needed web.config code in the web.config. Now I have 2 different .xml files(thats where you put your javascript and...

Attribute constraint on a generic type in .net?

in .net, if I have a generic class SomeClass<T>, is it possible to use the where keyword to require that T is a class with a certain attribute? something like: [SomeAttribute] class MyClass { ... } class AnotherClass<T> where T : Attribute(SomeAttribute) { ... } ...

Can you send a file larger that the SendBufferSize throuh a TcpClient?

I am experimenting with the Tcp connections in .NET and I would like to send some data that is larger than the SendBufferSize proporty of the TcpClient object. Is it possible to send the data by simply writing to the network stream or do I need to cut it in pices and send those and at the other end create it again? ...