.net

NHibernate DetachedCriteria.SetFirstResult?

I found an example of implementing the repository pattern in NHibernate on the web, and one of the methods uses this code to get the first result of a query: public IEnumerable<T> FindAll(DetachedCriteria criteria, int firstResult, int numberOfResults, params Order[] orders) { criteria.SetFirstResult(firstResult).SetMaxResults(numb...

Set same icon for all my Forms

Hi!, Is there any way to set the same icon to all my forms without having to change one by one? Something like when you setup GlobalAssemblyInfo for all your projects inside your solution. Thanks for your time. ...

How does one use FileStream to append to a file without an exclusive lock?

What I'm trying to do with FileStream in C#/.NET is to open two streams: one appending to a file and the other reading those writes asynchronously (for unit testing some network connection handling code). I can't figure out how to get the writer stream to open the file in non-exlusive locking mode and thus the code always throws an exce...

What is IL Weaving?

I just saw Ayende's post today about PostSharp. I downloaded the code and tried it out, and I thought it was the coolest, most easy to use way to handle AOP that I've seen. In his post, Ayende says that PostSharp accomplishes it's magic via IL Weaving. Now, at some abstract level I can deduce what that means, but I wanted to see if the...

Best Method for reading a YAML response in .NET?

Hey all, Weve recently been trying to work on an application that uses pandastream to encode our videos, we are sending the videos successfully, and the response that we get back is in YAML, however the only tool that we can find (YAML for .NET) is not parsing the file. Has anyone else ran into this, or have any insight on the best pra...

Error Message: "Access to the path c:\windows\microsoft.net\framework\(version)\Temporary ASP.NET Files\(blah) is denied." - what causes this?

Every so often when I'm debugging, I get this message in nice brown text on an ASP.NET error page: Access to the path "c:\windows\microsoft.net\framework\(version)\Temporary ASP.NET Files\(blah)" is denied. I've never been able to figure out what causes it, what really fixes it, and why it happens. Often times the pat...

What does "Directory.Delete( "path", false )" do?

According to the doucmentation for "Directory.Delete( "path", true )", it remove directories, subdirectories, and files in the path. What does Directory.Delete( "path", false ) do? According to the doucmentation it does "otherwise". I mean how can you delete a directory without removing the directory, subdirectories, and files? ...

.NET TransactionScope class and T-SQL TRAN COMMIT and ROLLBACK

I am current writing an application that will require multiple inserts, updates and deletes for my business entity. I am using the TransactionScope class to guarantee all the stored procedures can commit or roll back as a single unit of work. My question is, I am required to also use COMMIT TRAN and ROLLBACK TRAN is each of my stored p...

Should the Visual Studio GUI editor be used?

Coming from a background, I'm familiar with GUI editors that do a poor job of producing code. However, I've never written a GUI using .NET. Does the GUI editor in Visual Studio have the same problem(s)? Are both the source files and output GUI good? ...

Factory Class - Should i populate my object with data here?

Hello, im creating a Factory class that will contruct and return an object. I normally would do all of the data stuff at the Data Access Layer, but i dont think i could reach my objective and still do so. What i want to do is use a SQLDataReader to quickly read the data information and populate the object to be returned from the factor...

Can a .NET app be complied to native.

Hi all, Just wondering if a .NET app can be compiled down to native machine code ahead of time? I'm not planning on doing so if you can, I'm just curious. Thanks ...

Any good distributed agent/service models for .NET?

I'm looking for tools that implement the distributed agent/service model ... I guess we could also call this grid or cloud computing, but I'm not sure the term is exactly analagous. A distributed agent model would be one where developers build agents that are dispatched to a framework and the framework executes the agent somewhere in th...

NHibernate Order By question

Ok, so I have an nHibernate ICriteria that returns an object. I want to order by a single property but NOT asc or desc I want certain values of the property to come to the top of the repeater based on the selection. Like if I choose "video" I want all records with videos to come to the top. Now, can I do this in the query? or the repea...

How to detect whether serial port is in use or not in .net

We have industrial automation application developed in .NET 3.5 framework. I have to list out the available serial ports in the computer for our user. As part this, if any of the serial port is already opened, I have to show "In Use" status. I tried google but no luck. Can someone help me please? Regards, Krishgy ...

Why isn't my .net-calculated MD5 hash equivalent to the hash calculated on a web site?

I am trying to generate equivalent MD5 hashes in both JavaScript and .Net. Not having done either, I decided to use against a third party calculation - this web site for the word "password". I will add in salts later, but at the moment, I can't get the .net version to match up with the web site's hash: 5f4dcc3b5aa765d61d8327deb882cf99...

How do I make a thread dump in .NET ? (a la JVM thread dumps)

I have found no way of dumping the stack on all threads in .NET. Neither a signal to be send to the process nor programatic access to all the threads. I can only get access to the current thread via Thread.CurrentThread. Any tricks ? ...

Searching byte[]

Searching for a string within a string is extremely well supported in .NET but what do you do when the data you need to search isn't a string? I have binary data arriving in regular chunks via a NetworkStream. Packets are binary but they all start with a signature sequence of bytes. I accumulate the chunks into a larger buffer and look ...

How do you effectively model inheritance in a database?

What are the best practices for modeling inheritance in databases? What are the trade-offs (e.g. queriability)? (I'm most interested in SQL Server and .NET, but I also want to understand how other platforms address this issue.) ...

How to determine the file size from an attachment to a POP3 message

I'm writing a program to read from a POP3 mailbox and upload the email message into my ticketing system. I would like to then take the attachments and upload them as well. I've got all the information I need except the file size. Is there a way to determine the file size from the mail message? I am taking the attachment, decoding the...

How do I get the stream of header/footer in a WordprocessingDocument

Hi, I need to know how I get the stream of the headers and footers of a WordprocessingDocument. I get the MainDocument by the MainDocumentPart of a WordprocessingDocument. Do you know how I get the header? I tried to use the method GetPartsOfType but it returned null. Greets Sebastian ...