Archive for the 'Fix' Category

08
Sep
10

Changing log4net log file path via code

Sometimes we might have to place the log files away from the location where the application is installed. And lo there is an option to do that! In the config file create a variable like below

<file type="log4net.Util.PatternString" value="%property{SomeVariable}log.txt" />

And in the code, before calling log4net configure, set the new path to the Variable

log4net.GlobalContext.Properties["SomeVariable"] = YourNewPath;
log4net.Config.XmlConfigurator.Configure();

Simple isn’t it Smile

20
Apr
10

Team foundation server 2010 RTM installation steps, errors and workarounds

If you are planning to install Team Foundation Server on fresh Windows Server 2008 machine follow these steps which I was able to achieve after good number of trail and errors

Hope it saves somebody few frustrating hours :)

24
Mar
10

remove objects from an Enumerable collection in a loop

If you are trying to remove an object from a list that you are currently iterating through like below,

foreach (MyObject myObject in MyListOfMyObjects)
{
     if (condition) MyListOfMyObjects.Remove(myObject);
}

you will get an error message that you cannot do it.

Best alternative is to create a copy of the object and loop through it and remove from main object

foreach (MyObject myObject in new List<MyObject>(MyListOfMyObjects))
{
     if (condition) MyListOfMyObjects.Remove(myObject);
}

Simple isn’t it :)

Source : StackOverflow

15
Feb
10

Switching between Https and http while accessing wcf/asmx service

There may be an instance where we might have to test the clickonce application on production on SSL and stage on port 80, change the url of the wcf/asmx service dynamically etc.

Here is how I fixed the issue

public static MyService.MyServiceSoapClient GetSoapClient()
       {
           MyService.MyServiceSoapClient objClient = new MyService.MyServiceSoapClient();
          //sets the endpoint address dynamically
           objClient.Endpoint.Address = new System.ServiceModel.EndpointAddress(strURLRoot + "services/myservice.asmx");

           //sets the security mode dynamically
           System.ServiceModel.BasicHttpBinding bhbBinding = (System.ServiceModel.BasicHttpBinding)objClient.Endpoint.Binding;
           if (SharedData.strURLRoot.Contains("https:"))
               bhbBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.Transport;
           else
               bhbBinding.Security.Mode = System.ServiceModel.BasicHttpSecurityMode.None;
           objClient.Endpoint.Binding = bhbBinding;
           return objClient;
       }

Simple isn’t it?

14
Jan
10

VS 2010 beta 2 opening applications with error : MSB3134

When you open an already existing full trust application in Visual Studio 2010 beta 2, you might encounter this error after the first build.

MSB3134: The permission set requested by the application exceeded the permissions allowed by the Internet or Intranet zones. Select Full Trust or to continue using partial trust, define your custom permission set in the Security Page of the Project Designer.

This error and the rationale behind it is explained by Kristopher Makey here.

Unfortunately, fix is not clear. Solution is as below.

  • Open <Application>/Properties/app.manifest
  • Remove everything between <security> tag
  • Go to Application Properties > Security tab. Select the permission as ‘Full trust’ and save and compile.

Simple Isn’t it :)




@pooran

 

May 2012
M T W T F S S
« Nov    
 123456
78910111213
14151617181920
21222324252627
28293031  

Visits so far..

  • 10,471

Follow

Get every new post delivered to your Inbox.