.net

What is the best way to get the value of what user is logged in?

I have a Windows form application that users can log into. The application is alone and doesn't connect with anything or anyone. Besides creating a global variable, how could I have an easily accesible variable to check the current users permissions? A not so kosher way of doing things is just pass the ID of the userType in the Form co...

Performance of anonymous types in c#

Is it bad to use anonymous types in c#? ...

Using the "clear" method vs. New Object

Hi, In the .NET framework, many of the System.Collection classes have Clear methods on them. Is there a clear advantage on using this versus replacing the reference with a new object? Thanks. ...

Should I have a catch, that catches Exception?

Hi I know it is not good to just put a try catch with Exception on it since that could lead to burying problems and other things. I however still don't know if I should do it in my case. My site is heavy ajax so I send json responses back. So right now I have identified some possible exceptions that could be raised like a null referen...

The future of .NET Development: ASP.NET or WPF/Silverlight/Winforms?

Forgive me for asking a subjective question but I'd really like to know where is the .NET development headed in the near future? Are we going to see more ASP.NET developers or will there be more demand for Silverlight/WPF && WinForms developers? ...

Build With ILMerge Error

Has anyone had this error with IlMerge? I am trying to merge a few assemblies for a .NET project using the 4.0 Framework. ILMerge /log /lib:..\Libraries /targetplatform:v4 /internalize:..\SolutionFiles\CJCommon.exclude /ndebug /out:bin\Release\Common.dll obj\Release\Common.dll C:\Development\CJCommon\Libraries\FluentNHibernate.dll C:\D...

Are C# Strings (and other .NET API's) limited to 2GB in size?

Today I noticed that C#'s String class returns the length of a string as an Int. Since an Int is always 32-bits, no matter what the architecture, does this mean that a string can only be 2GB or less in length? A 2GB string would be very unusual, and present many problems along with it. However, most .NET api's seem to use 'int' to con...

Does the license on the .NET framework allow distribution of derivative forms of it's code?

I'd like to mimic a .NET class signature (and possibly some major pieces of implementation) in a C++ application. I plan on releasing said application under the Boost Software License. Specifically, I'd like to use the TimeSpan and DateTime interfaces, as well as some implementation I found using the handy dandy Reflector tool. Would us...

WPF: Replace the XAML of a page or usercontrol (both is ok) at runtime?

I know that it is possible to parse an XAML - file at runtime and create an UIElement which I can insert into my pages grid, no problem there. But what I really want is to replace the whole XAML of my page or usercontrol, is that possible, too? Reasoning: I want to give the users of my application the opportunity to have the applicati...

Creating a wrapper for TreeView.Node

Lets say I have the following code: public class Base { // Some stuff here public int var } public class UsingBase { // Some more stuff here public Base B = new Base(); } Now let's say the actual code of these classes is huge and I would like UsingBase to do some extra stuff. So I'm thinking about subclassing it. Now ...

Adding two path names in VC++

String^ Source = System::IO::Directory::GetCurrentDirectory()+ "\\DeleteFolder.exe\"" ; String^ Destination = "C:\\Windows\\DeleteFolder.exe"; pin_ptr<const wchar_t> WSource = PtrToStringChars(Source); pin_ptr<const wchar_t> WDestination = PtrToStringChars(Destination); Is there any problem with the code above, i am unable to get the s...

How to call a web method on a web service using HTTPWebRequest?

When using an HTTPWebRequest object to call a web service, and supply the wsdl parameter, I get the description page ok. Dim req As Net.HttpWebRequest Dim resp As Net.HttpWebResponse Dim sr As IO.StreamReader Dim text As String req = Net.WebRequest.Create("http://www.mysite.com/DS.asmx?wsdl") ' works ' resp = req.GetResponse sr = New I...

Is MSDN website sufficient for C# self-learning?

I know there are plenty of books on C#, but I'd rather learn by reading articles/guides and watching video tutorials. Would Microsoft's MSDN website be enough to teach myself C# in depth? Thank you. *Update:* @Jon Skeet: Thanks for your honest answer. I might just do that then, - I'll get Table of Contents from a C# .NET book and then...

VB.NET question. Linq Support?

Does VB.NET have LINQ support? I was discussing VB vs C# tonight and I was told that VB is different because it does not handle web services as well as C# and that it does not support linq. Is this true? ...

Getting 401 unauthorized error while accessing webDav folder from my C# application?

Hi, I have set up WebDAv server on my Debian linux and this is working fine as I am able to connect it by using FireFox and IE. But while I am trying to connect it by the following code, it returns: "The remote server returned and error:(401) Unauthorized error" try { // Build the SQL query. strQuery...

Aborting a .NET thread

I am creating a thread A and in that thread creating a new thread B. So how is the thread hierarchy? Thread B is child of Thread A? Or the threads are created as peers? I want to abort the parent thread A which in turn kills/aborts its child threads. How is that possible in C#? ...

Long Delay when acces to Network Printer.

I have some Delay to access My remote printer, a RICOH offimatic point. I think this delay become from domain autentification. When I call PrintDialog, this delay is about 3 to 5 seconds. I use some .Net programs. Then when I print a report, delay becomes 4x the PrintDialog Delay (15-20 seconds). Standard Programs (c++) get a 1x del...

Disabling conversion of binary data to character representation when SQL_NO_BACKSLASHES is enabled

When I try inserting binary data into a blob column of a MySQL database using MySql.data.dll , the following exception is thrown- error in syntax near '\b\0\0\b\0\0��\0\0'. Following is my code snippet: byte[] arrayData = memoryStreamFromFile.ToArray( ); cmd.CommandText = "insert into `attachmentdata` (`data`,`blobid` ) values ...

Is it a correct way to use auto-implemented properties in C#

I want to assign some default value to a property or want to replace some character like given below. Is it a correct syntax or should i do this by creating a variable. public string Login_Name { get { return this.Login_Name; } set { this.Login_Name = value.Replace("'", "''"); } ...

.NET Remoting slows down when internet connection starts up

I have been using .net remoting with client and server on my dev machine, and everything was fine. And then I've located the server on the other machine, connected with my through a 100-Mbit LAN. It has a VPN connection, allowing it to connect to the internet. Whenever a VPN connection is started, .NET remoting gives out huge lag for ev...