.net

Is there a pattern that allows a constructor to be called only from a specific factory and from nowhere else?

We have a class, say LegacyUserSettingsService. LegacyUserSettingsService implements an interface, IUserSettingsService. You can get an instance of the IUserSettingsService by calling our ApplicationServicesFactory. The factory uses Spring.NET to construct the concrete LegacyUserSettingsService. The trouble is that new developers some...

WANT TO host Visual Studio Form Designer in my own application..

Hi, I'm writing an application that lets the end use design a Form just the way Visual Studio lets you design a windows forms. I looked into visual studio forms designer articles in msdn and also studied open-source SharpDevelop editor. Both the examples host visual studio's windows forms designer to provide form-design service in their...

How to tell an application to run on a specific .net runtime

In my development computer I have .net 3.0 and 3.5 installed. I'm developing with vs2005 on .net FW3.0 How can I tell the application to use the 3.0 assembleis insted of the 3.5? ...

how to check whether the item in the combo box is selected or not in c#?

im having a combo box in which i have to display dates from database...user have to select a date from the combo box to proceed further...but im not able to make the user aware of selecting the item from the combo box first to proceed further...what is the process so that a user can get a message if he has not selected the date from the ...

Adding Custom dialogs in Visual Studio Setup projects

Hello All I need to develop a Visual Studio Setup Project for my application. As far as i see, i can use only a handful of preconfigured dialogs which i can use. Is there any way possible to use any custom dialogs in Visual Studio SetUp Project ? For ex: Whenever i start my setup, a dialog should be shown to the user prompting him to ...

Mark assembly App_licenses.dll with AssemblyVersion (FxCop CA1016 rule)

Hello everyone, I'm trying to fulfil FxCop's rules in my web site. Since I use some Infragistics controls I have a licenses.licx file that turns into a "app_licenses.dll" assembly after publication. The problem is that this app_licenses.dll assembly does not comply with rule CA1016 (MarkAssembliesWithAssemblyVersion), and I should add a...

What is Microsoft.csharp.dll in .NET 4.0

This dll is added by default in Visual Studio 2010 projects. What is this new project used for. It does not seem to contain much after looking at it using Reflector and Google does not seem to have much to say about it either. ...

Encrypting the connection string in web.config file in C#

I have written the name of my database, username and password in my web.config file as connection string. I want to encrypt this data. How can I do it? <connectionStrings> <add name="ISP_ConnectionString" connectionString="Data Source=JIGAR; Initial Catalog=ISP;Integrated Security=True; User ID=jigar;Passwor...

Should we start using FxCop and/or StyleCop in a mature project?

We have 3 years old solution (.sln) with about 20 projects (.csproj). It is reasonable to start using FxCop and/or StyleCop? Maybe we should use it for several small projects first but not for whole solution? It would be good to see some experienced answers. Thanks. EDIT: We are using TeamCity for continuous integration. And we have n...

Microsoft.Build.Engine Error (default targets): Target GetFrameworkPaths: Could not locate the .NET Framework SDK.

I am writing a webservice, that when called should build a C# project. I'm using the framework 2 reference, Microsoft.Buld.Engine and Microsoft.Build.Framework. If you look under the '<Import>' section .csproj file, by default it has: <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> which I then changed to: <Import P...

Windows user control hosted in IE is not working.

Hi i have hosted a windows user control in IE. Every thing is working fine, if i open the application in the same machine where the Web application is hosted. if i access the same appication from a remote client IE, A blank box is coming with a small image in the corner. I have added the site as trusted site in the IE and made all ...

How to compress the responses to reduce page weight in .net

Hi Can anyone suggest the ways we can choose to reduce the size of the rendered html or response to reduce page weight in .net so that the client can experience a faster loading of the UI i've heard of JSON and GZip but don't have much idea about how to use it or even better ways are there ...

Catching Exceptions in a .NET Thread

How could you find out that an Exception occurred in a Thread in a MultiThreaded Application ? and consecutively clean the resources ? Because otherwise the Thread can be still remaining in memory and running. ...

How to make a class serializable without Serializable attibute in .net

Hello All: I have one debugger visualizer for seeing list of class object in the form of data table. But the limitation for the code is that the class should be serializable i.e. should be marked as [Serializable] and if the class is not marked Serializable then the debugger crashes. So, can anybody tell me how to make a class Serializa...

How to make a floating (tooltip) control in Windows.Forms?

The Scene: A (smallish) Form hosting a UserControl. The Plot: Whenever UserControl raises a hover event, display some (graphical) information in a tool tip fashion. When the user moves the mouse, fade them away again. Notes: I'd like to display more than one "tooltip", with each tooltip being a UserControl displaying information in a g...

What's the difference between using ProtocolType.IP and ProtocolType.Tcp

I've just answered problem with sockets in c# where in my example code I initializing my socket using ProtocolType.IP as this is what I've always used in my own code, and it has never caused me problems. But I see many examples specifying ProtocolType.Tcp. I guess, what I'm asking is, by using ProtocolType.IP instead of ProtocolType.Tc...

Good way to fetch XML from a remote URL, convert it to HTML and display it in a ASP.NET-page

Hi, The use case I want to achive is. 1. Fetch XML from a remote URL. 2. Convert it to HTML using XSLT 3. Insert the generated HTML at a position in my ASP.NET web forms page. Alternative on the above, if 1 returns a 404: 2. Generate HTML which display an error message to the user. Only step 3 is left as I've completed 1-2. As the...

How to intercept capture TAB key in WinForms application?

Hi, could you please help me with this one? I'm trying to capture Tab key in Windows Forms application and do a custom action on it. I have a Form with several listViews and buttons, I've set Form's KeyPreview property to true and when I press any other key than tab, my KeyDown event handler does get called. But that's not true with the...

NHibernate querying on any-associations meta-value

I have a collection of entities with an any-association, like this: public class CreatedLog { public string Message { get; set; } public EntityBase CreatedEntity { get; set; } // an association to any entity } Is there a way - through HQL or Criteria API - to find only the log entries, that are for a specific entity-type? Lik...

Small and fast .NET programs? - 65% runtime in ResolvePolicy

Hi, I tried to build a very very small .NET app in F#. It just has to convert a small string into another string and print the result to the console like: convert.exe myString ==> prints something like "myConvertedString" I used dottrace to analyze the performance: 26% (168ms) in my actual string conversion (I thinks this is ok.) ...