.net

Autosize datagridview in usercontrol

Hi i am developing a custom panel for outlook. and i have a question, how can i autosize width and height the datagridview to the userControl? This is what append: Edit: Microsoft.Office.Tools.CustomTaskPane taskPane; Microsoft.Office.Interop.Outlook.Application applicationObject; Outlook.Explorer explorer; Ta...

Call native code specified at runtime

I'm developing an application that will allow users to call external code from both managed and native .dlls. The users will be able to specify what library/method/function to call at runtime (it will be stored in a configuration file). I know how to do this using pinvoke for native libraries if I know what dll/function I want to call ...

.NET Membership - Register, login etc. works. Password reset doesn't...

I'm trying to allow for reset password functionality to my site without utilizing question/answer functionality (this is deactivated in the membership entry in web.config). However when calling resetPassword (using the automatically generated controller/service/provider from the .NET MVC framework) an error is thrown (Input string was n...

Escaping quotes in json string

System.Web.Script.Serialization.JavaScriptSerializer s = new System.Web.Script.Serialization.JavaScriptSerializer(); result = s.Deserialize<Hashtable>(data); Error is thrown if data is "{a:\"\"test\" 123\",b:\"hello\" }" No error is thrown if data is "{a:\"test 123\",b:\"hello\" }" How do I adjust the data string so that no error is ...

Difference between dynamic and System.Object

What is the difference between a variable declared as dynamic and a variable declared as System.Object? Running the following function would seem to indicate that both variables get cast to the correct type dynamically: void ObjectTest() { System.Object MyTestVar = "test"; dynamic MyTestVar2 = "Testing 123"; Console.WriteLi...

Is it correct to catch each exception with Exception class ??? If not then what?

Is it correct to catch each exception with Exception class ??? If not then what should be the correct sequence to catch exception within try catch block? e.g try{ . . some code . } catch(Exception ex) { throw ex; } ...

Java: Converting from .NET Constructors

We're converting some .NET 3.5 code to Java (Android). This Java code gives the error: Syntax error on token "Chapters", VariableDeclaratorId expected after this token this.add (new Book() {Chapters=50, OneBasedBookID = 1, Long = "Bahai", Short = "ba", Color = c, BookType = b; }); The types are all correct. ...

Retrieving the number of physical core processors

I know I can use System.Environment.ProcessorCount to return the number of "processors" in a machine. What I am trying to do is find out if there is a way to determine the number of cores in the processor, not including hyperthreading as a "core". For example, on a dual core hyperthreading processor, System.Environment.ProcessorCount wil...

Are there any DLL files that an application written in Nemerle needs to include?

When I deploy an application written in Nemerle, are there any DLL files specific for Nemerle that needs to be installed? If there are such DLL files, which are they? ...

Replace string with regular expression

I have the below situation Case 1: Input : X(P)~AK,X(MV)~AK Replace with: AP Output: X(P)~AP,X(MV)~AP Case 2: Input: X(PH)~B$,X(PL)~B$,X(MV)~AP Replace with: USD$ Output: X(PH)~USD$,X(PL)~USD$,X(MV)~USD$ As can be make out that, always the ~<string> will be replaced. Is it possible to achieve the same through regular expressi...

Dynamically added controls causing static button event to only fire after second click

I have a custom user control that consists of a dynamic list of controls, along with a static button that is declared (along with the OnClick declaration) on the aspx page. The button shows or hides a panel containing the dynamic control list. I am finding a problem that I presume is related to the dynamically added controls, where the...

How to ensure background thread ends when application ends?

I have an asp.net application with a background thread. The thread starts when the application starts and it is gracefully stopped when the application ends. I am running the website on a shared host. Unfortunately sometimes the application does not trigger the Application_End event when it ends. I would think that the threads would be k...

ASP.NET Development Server - is the source available?

I remember several years back it was called Cassini and the source was available for download. Is this no longer the case? Either my Google skills are lacking or I can't seem to find the source code for it anywhere. ...

Looking for guidance on developing specialized a version control system

I work in the architecture and construction industry, but currently spend a lot of my time doing software development. After moving my software projects into Subversion repositories I've realized how much this industry really needs a similar system for design and construction documents. I've only been developing software for a year and h...

ASP.net Custom Multiple control validator javascript issue

I've used the code in this article before to create a custom validator to validate mupltiple controls on a page. Using the "inline method" to hook up the validators just beofre the closing form tag. This time I'm making a user control and want the control to handle the generatio/rendering of the javascript to hook up the validators. The...

what's the point of Dependency Injection Frameworks?

I am sure that I am somewhat lost in this area... my understanding is that Dependency Injection means initializing something that is required by a class..so for instance. If my controller is going to need a service and I want to be able to test it then I should define two Constructor methods for it... so, my question is... why do people ...

ASP.NET auto generate web services from stored procedures

Hey guys, I have looking for a code generation tool, that could auto generate web services based on feeding a tool the stored procedure that I would like. Is there something that could achieve this for me ? ...

If given the task to write hello world in C#... using reflection, what are some clever ways to use reflection?

I've been given a "for fun" challenge to write a "hello world" application. The only condition is that I use reflection, there is no specified way this condition must be met, but clever or elegant or "cool" uses are fun. Aside from injecting an external library or doing some sort of IHelloWorldMessageProvider composition container mojo...

How do I check if an NTAccount object represents a Group or a User?

When working with the access rules returned by GetAccessRules(True, True, GetType(System.Security.Principal.NTAccount)) how can I tell if the NTAccount object referenced in each rule is a user account or a group? Update: I was able to solve this as follows. Note, the intent of this code is to return True if the NTAccount is a grou...

How to get the index of element in the List<T> in c#

I have a list who have some element like A B C D. I want to get the index of B. How i can get it? I want to do this in C#. ...