.net

System.ArgumentException illegal characters in path

I am using Path.Combine, and one of the strings contain a Unicode characters. I get {System.ArgumentException} exception; illegal characters in path. According to MSDN filepath/name can have unicode characters. Why do I get this exception? Edit: Here is the code: Path.Combine("C:\PDM\Silver","Amabel Bender QQQ") ...

CS.exe compiler (C#)

Hi Guys, We are currently building an application which needs to compile a C# code. Can we redistribute the CS.exe in our package. I thought that it comes with the .Net framework installation but from looking in Microsoft Web site i see that there is a difference between .Net framework and the .Net SDK What are my options? Thanks, Adi ...

Debug/Release difference

What's the difference between Debug and Release? ...

Can I embed a win32 DLL in a .NET assembly, and make calls into it using P/Invoke?

I'm writing a C# wrapper for a third-party native library, which we have as a DLL. I would like to be able to distribute a single DLL for the new assembly. Is it possible for me to embed the win32 DLL in my .NET DLL, and still make calls into it using P/Invoke? If so, how? ...

Finding an XmlNode by attribute in ASP.net

Hi, I'm trying to write some code to find a specific XmlNode object based on the URL in the XML sitemap but can't get it to find anything. The sitemap is the standard ASP.net sitemap and contains: <siteMapNode url="~/lev/index.aspx" title="Live-Eye-Views"> --- Child Items --- </siteMapNode> The code I'm using to search for the eleme...

Is there a way to prevent Reflector from being able to reflect my source code?

Hi Guys, Is there a way (reliable and preferably not commercial) to prevent from Reflector to reflect my source code??? Thanks, Adi ...

A simple eventbus for .net

Hello, I want to make a very simple event bus which will allow any client to subscribe to a particular type of event and when any publisher pushes an event on the bus using EventBus.PushEvent() method only the clients that subscribed to that particular event type will get the event. I am using c#.net 2.0 Any help/pointer would be grea...

Making a C#-based Excel add-in run out-of-proc with minimal pain.

Hi, I have developed a prototype C# Excel 2003 add-in in VS2005 that supports an object with some simple calls, plus a separate RTD class, all sitting atop a large existing in-house C# stack. It all works fine as-is, but... I'm told that in order to avoid potential conflicts with other Excel add-ins that might want a different .Net ru...

Can i restrict this c# extension method definition with a WHERE keyword?

Hi folks, i'm trying to do the following extension method -> converting an int to a enum, when you provide the enum :- public static T ToEnum<T>(this int value) { return (T)Enum.ToObject(typeof(T), value); } Now, i was hoping to make it so that you can only define the type T to be an enumeration. Is there any what i can restrict ...

How can this Linq2Sql create an enum in the select clause?

Hi folks, i've got the following linq2sql query, and i'm setting the result to a POCO. One of my POCO properties is an enumeration. public IQueryable<Models.Achievement> GetAchievements() { return from a in _sqlDatabase.Achievements select new Models.Achievement { // Note: ToEnum is an extension ...

How to do this in ADO.NET Entities Framework

I have a table called BlogPost which has a 1-to-many relationship with the Comment table. (In Comment, there's a foreign key BlogPostId.) Now I want to retrieve all posts as well as the latest comments of each post. I've tried with s/t like below but it doesn't work. from r in Db.BlogPost select new {Post = r, LatestComment = r.C...

When release dlls don't work but debug dlls do

After deploying our huge distributed system to one of our clients we experience an unexpected error. During the investigation we replace the assembly causing the error with one where we have added some diagnostic code. The dll we use is built in debug mode. And suddenly it all works! Replacing the debug dll with the release version (wit...

Best way of checking content of Generic List

I have to work on some code that's using generic lists to store a collection of custom objects. Then it does something like the following to check if a given object's in the collection and do something if so: List<CustomObject> customObjects; //fill up the list List<CustomObject> anotherListofCustomObjects; //fill it up //... foreach...

Email sent in english is displayed to the end user with picture alphabet (Chinese, japanese, etc) and random characters

I have code that sends HTML emails to users. To accommodate users who dont have/ want HTML email, the email contains 2 alternate views, View(0) is HTML, View(1) is Plain text. The HTML view has a header and footer graphics, but the style is done inline and not via css file. The text view is only the text; no tags, images, etc. The mess...

Comma "izing" a list of items

Given a list of strings, what is the best method for concatenating these strings into a comma separated list with no comma at the end. (VB.NET or C#) (Using either StringBuilder or String Concat.) Dim strResult As String = "" Dim lstItems As New List(Of String) lstItems.Add("Hello") lstItems.Add("World") For Each strItem As String In ls...

Can I detect errors while using a .Net WebBrowser control?

I have an .Net Froms application that displays web pages through a WebBrowser control. Is there anyway that I can detect if the control shows a 'Page not found' or 'Cannot display webpage' error? There doesn't seem to be any error event handlers. ...

Procedure expects parameter which was not supplied.

I'm getting the error when accessing a Stored Procedure in SQL Server Server Error in '/' Application. Procedure or function 'ColumnSeek' expects parameter '@template', which was not supplied. This is happening when I call a Stored Procedure with a parameter through .net's data connection to sql (System.data.SqlClient), even though I ...

Large applications using NHibernate

Hi guys do any of you working on a large enterprise or web application what uses Nhibernate as an ORM tool ,I interested to know about your experience ? Or maybe you have a link for such an example ? ...

Throwing ArgumentNullException

Suppose I have a method that takes an object of some kind as an argument. Now say that if this method is passed a null argument, it's a fatal error and an exception should be thrown. Is it worth it for me to code something like this (keeping in mind this is a trivial example): void someMethod(SomeClass x) { if (x == null){ ...

How to post a form with MVC controller?

How do I post a form to an external site using an ASP.NET MVC controller? EDIT: Ok... I have a view with some data on it. After the user completes the form I need to do a postback with a specified form format to an external site (like for paypal). After I posted the constructed form I need to redirect the action to a new view ...