.net

Keyword 'this'(Me) is not available calling the base constructor

In the inherited class I use the base constructor, but can't use class's members calling this base constructor. In this example I have a PicturedLabel that knows it's own color and has a image. A TypedLabel : PictureLabel knows it's type but uses the base color. The (base)image that uses TypedLabel should be colored with the (base)colo...

Dynamic column width

protected void GridView1_DataBound(object sender, EventArgs e) { GridView1.Columns[0].ItemStyle.Width = 400; <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" ObjectDataSource1 returns data table , but I can't find any width property there , so I guess there is GridView side option but even on...

How to configure log4net for WCF

On my asp webforms app I would do the log4net initialization; log4net.Config.XmlConfigurator.Configure(); on global.asax on Application_Start so that it is done once when the application starts. What is the right way of configuring log4net for IIS hosted WCF apps(asking specifically about where to place this line which event to use e...

How to precompile WCF code and then host it on IIS ?

How do you precompile WCF code so that the WCF code can't be seen by anyone who has access to the WCF code. it's possible to this with ASP.NET code by using the "precompilation" feature. basically, what the precompilation feature does is enable the developper to deploy "binaries" to IIS instead of a folder containing source code. can th...

how to tell in code if we are running from a testmethod .net test

Is there a way to know when code is being called from running a test method? bool MyMethod() { if ( /* are we running a test? */ ) { return true; // otherwise this will fail from the automated build script } else { // run the proper code } } and please spare me the "this is a really bad idea" c...

Using the string resources of ASP.NET membership provider in a custom control

I have the request to build a custom control for ASP.NET membership. The control is a kind of CreateUserWizard, but somewhat special. The users are created by our account executives. At their first log in the users enter their user name and initial password, change the password and enter additional information (email) in one transaction!...

System.IO.File.ReadAllText(path) does not read the html file.

I want to read the html file.And for that I use System.IO.File.ReadAllText(path).It can read all the html file but there is one file which is not read through this function. I have also used using (StreamReader reader = File.OpenText(fileName)) { text = reader.ReadToEnd(); But still there is same problem. What is the reason can b...

Code analysis: Global project/assembly suppression

I have several CA1704:IdentifiersShouldBeSpelledCorrectly warnings that I want to suppress. Basically they refer to the company name which is deemed to be spelled incorrectly. The company name is part of several namespaces in my project, and in order to suppress all the warnings I need to add a lot of suppressions to the GlobalSuppressio...

How to validate field length

I have a Abc field in the database and I want to make sure that the user doesnot cross the limit of the field in database, therefore I use validation that would say "You cannot enter more than 50 characters". Now the question is that because the memory to store Chinese,Indic script and other such languages take more than 1 byte how woul...

Is there a way to circumvent CA1726:UsePreferredTerms?

I have a problem with the code analysis rule CA1726:UsePreferredTerms. Our business domain has two crucial concepts named Case and Flag. According to CA, it's apparently a deadly sin to use these names, however I really don't care since, as I said, they are crucial concepts in our domain model. CA complains not only about the type declar...

Why does sorted list have to have a key value pair?

If I just want a sorted list of just dates, integers, or doubles is it really necessary to have to define a SortedList(of Integer, Integer)? Seems intriguing to me, but may just be trival. I'd prefer just to use a SortedList(of Integer). (This question is in relation to the .Net generic collections) ...

How to deploy ASP.NET MVC application in a shared hosting without losing the beautiful uri?

I am trying to upload an ASP.NET MVC application in a shared server running on IIS 6 and Windows 2003. I don't have access to IIS. I've changed the global.asax.cs file as follows: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", "{controller}.aspx/{action}/{id}", ...

how many bytes does a static int variable need?

class a { int variable;//4 bytes } class a { static int variable;//? bytes } ...

Find value in collection

Is there any way to search a name in collection as %Like% ...

NServiceBus exception handling and message retry mechanism

We are planning to use NServiceBus in our application for dispatching messages. In our case each message has timeToLive property, defining period of time, in which this message should be processed. For the case if message handling was unsuccessful in first attempt, our plan is to move it to specific retry storage (retry queue) and than ...

How reusable should ViewModel classes be?

I'm working on a WPF application, and I'm structuring it using the MVVM pattern. Initially I had an idea that the ViewModels should be reusable, but now I'm not too sure anymore. Should I be able to reuse my ViewModels if I need similar functionality for a WinForms application? Silverlight doesn't support all things WPF does - should...

Search value in List collection

I need to search a name which is stored in collection. Search criteria: eg: 'Search Name' . If i give 'N' this name should be displayed. If i give any alphabet then all the names which contains the given alphabet should be displayed..the name can contains more than one word. I am using List collection. search criteria: eg. 1) a 2) xyz...

How to draw semi-transparent text on a graphics object?

I want to draw a text with 32 bit transparency on a graphics object. When I try, I only get black color in the result. If I try to draw a line with the same semitransparent color, it works perfectly. I have this code: lBitmap As New Bitmap(32, 32, PixelFormat.Format32bppArgb) lGraphic As Graphics = Graphics.FromImage(lBitmap) lGraphi...

ajaxToolkit:DropDownExtender where is items ?

<asp:TextBox ID="TextBox5" runat="server" Height="30px" Width="68px"></asp:TextBox> <ajaxToolkit:DropDownExtender ID="TextBox5_DropDownExtender" runat="server" DynamicServicePath="" Enabled="True" TargetControlID="TextBox5"> </ajaxToolkit:DropDownExtender> //this.TextBox5_DropDownExtender ???? YearList.Items.Add(DateTime.Today....

Unable to uninstall an Assembly from GAC?

I am unable to uninstall an Assembly (log4net.dll) from GAC. It is giving following error. "Assembly is required by one or more applications". However if I search the Assembly using ProcessExplorer nothing comes up? How can I remove this Assembly from GAC? ...