.net

Perls Of Wisdom For a .Net Programmer

Hi Guys, I like to think that recently I have moved from complete beginner to beginner. It has been a hard road and one on which I took many wrong turns. Very rarely in any profession is there a place where so many rock stars gather, this is something I would like to take advantage of. What I would like to ask is what are your perls of...

what is it mean and it's output?

Can any one please let me know what is it mean and it's output? it is a .Net script. private static readonly byte[] Key = { 0xda, 0x3c, 0x35, 0x6f, 0xbd, 0xd, 0x87, 0xf0, 0x9a, 0x7, 0x6d, 0xab, 0x7e, 0x82, 0x36, 0xa, ...

The cost of finalize in .Net

(1) I've read a lot of questions about IDisposable where the answers recommend not using Finalize unless you really need to because of the process time involved. What I haven't seen is how much this cost is and how often it's paid. Every millisecond? second? hour, day etc. (2) Also, it seems to me that Finalize is handy when its not alw...

Linq to Entities : Many-to-Many join a Table and a View

I have several tables and a view : Tables : - aspnet_Roles (with RoleId & other columns) - Status (with StatusId & other columns) - RoleStatus (with RoleId and StatusId and relationships) When I create the Linq To Entities EDMX file, it creates 2 entities with a Status List property in aspnet_Roles and a aspnet_Roles list in Status. ...

Invoke target throwing invalid cross-thread operate exception

MethodInfo mi = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic); mi.Invoke(notify, null); This throws the following exception: {"Exception has been thrown by the target of an invocation."} With the following inner exception: "Cross-thread operation not valid: Control '' accessed from a t...

How can solve "Cross-thread operation not valid"?

i try to start multi Thread but i can not it returns to me error: Cross-thread operation not valid: 'listBox1' thread was created to control outside access from another thread was. MyCodes: public DataTable dTable; public DataTable dtRowsCount; Thread t1; ThreadStart ts1; void ExcelToSql() { ...

How to debug SqlDataSource

I'm testing my site against SQL injection attacks and I would like to trace SqlDataSource messages sent to SQL server. How can I do that or at least get as close as I can. ...

Adding buttons to spreadsheets in .NET (VSTO)

Using VSTO or some related technology, is it possible to programmatically embed a button in a cell of an Excel worksheet, and configure it to call a C# function when it is clicked? How? Thanks. ...

IIS7 or .Net 301 Redirects from 1 domain to another

I have 2 domains. For the question, I will call them www.old.com and www.new.com. Both urls are pointing to the same IIS7 Site instance. I need to it up so that when someone goes to www.old.com they get a 301 redirect to www.new.com. The tricky part is I am using URL rewrites for pages within the site. So www.old.com/About.aspx redi...

How do I save data without using sessions for postback in MVC?

I have 2 texboxes and 1 needs validation. I have this setup with Html.ValidationSummary display. I would like to keep the data that has been entered on the validation post. Instead the page is refreshed and the data is lost which makes the user enter the data again. How do I prevent that without using sessions? ...

C# What would happen to GC if I run process with priority = RealTime?

I have a C# app which runs with priority RealTime. It was all fine until I made few hectic changes in past 2 days. Now it runs out of memory in few hours. I am trying to find whether it is a memory leak I created of this is because I consume lot more objects than before and GC simply cant collect them because it runs with same priority....

How can i call resource file from xml document

how can i call varible from my resource file from a xml document like <items> <item rating="R"> <title>The Matrix</title> <format>"$resources:Format,Dvd"</format> </item> </items> ...

Web service recieves null parameters from application using ksoap method

I've seen topics discussing this but no one has seemed to post a solution. At the moment, I'm testing passing parameters to my .Net web service. When the parameters reach the web service it adds it with an additional string then returns it too my application; but all I'm returning is the string message, not the parameter I passed. Is the...

How can I remove the current cell focus from A Windows Forms datagridview ?

How can I remove the current cell focus from a Windows Forms datagridview ? I have a dialog with some datagridforms and initially I don't want to have a cell selection. Actually in every gridview the cell [1,1] is selected I have already searched in some forums, but the provided solutions doesn't work. For example often it is recommende...

Is EAX crypto mode supported in the .NET framework?

Does anyone know if EAX mode is supported or how to use it? Here is an overview: http://en.wikipedia.org/wiki/EAX_mode ...

VS Setup Project DefaultLocation for Application Folder

I am creating a Setup Project in VS 2008. The application needs to be supported on Windows 7 running UAC. I have to install the app in the User's area of the machine. What do I set the DefaultLocation property of the Application Folder to in the Setup Project? It can't be set to ProgramFilesFolder. ...

How to draw a single point with .Net?

Hello, this should be pretty simple but I don't get it. How can I draw a single point in .Net? If I use g.DrawLine(Black,0,0,0,0) nothing is drawn and if I use g.DrawLine(Black,0,0,1,0) a line with 2 dots is used. The same happens with g.DrawRectangle. This has me intrigued. Thanks in advance. EDIT: A box of 1x1 is a box of 4 pixels a...

Hosting .Net 4 website as child of .Net 3.5 website

I am trying to add a Silverlight application running on the .Net 4 Application Pool as a child application of a ASP.Net application running on the Classic .Net Application Pool. I receive several configuration errors due to the Silverlight application inheriting configuration elements from the parent application. Does anyone know of an...

Byte to Integer in c#

I am reading a row from a SQL Server table. One of the columns is of type tinyint. I want to get the value into an int or int32 variable. rdr.GetByte(j) (byte) rdr.GetValue(j) ...seems to be the only way to retrieve the value. But I can't figure out how to get the result into an int var. ...

Why is Dictionary.First() so slow?

Not a real question because I already found out the answer, but still interesting thing. I always thought that hash table is the fastest associative container if you hash properly. However, the following code is terribly slow. It executes only about 1 million iterations and takes more than 2 minutes of time on a Core 2 CPU. The code ...