Skip to main content

Posts

Showing posts with the label C#

Fixing Deployment.AddInAlreadyInstalledException.

If you are building any VSTO for any of the office applications, then its quite common to run into this issue. The error message would say that "The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:///D:/Samples/TestUpdatedVersion/bin/Debug/TestUpdatedVersion.vsto ********** Exception Text ********** Microsoft.VisualStudio.Tools.Applications.Deployment.AddInAlreadyInstalledException: The customization cannot be installed because another version is currently installed and cannot be upgraded from this location. To install this version of the customization, first use Add or Remove Programs to uninstall this program: TestUpdatedVersion. Then install the new customization from the following location: file:/...

Visual Studio Quirks

On clicking debug in Visual Studio, it gives "The debugger cannot continue running the process. Unable to start debugging" The problem here is that no project is selected as default startup project. You would need to right click a project which is start up project and select "Set as start-up project".

Annotation in C# for mapping JsonProperty to a variable

If for some reason you are .NET Framework 2.0 and using Newtonsoft.Json libray than this is gonna be very useful. You have a case where your Json property contains a '-' sign, than obviously you can't have a C# variable to map the same as variable naming scheme does not allow - signs. I recently faced a similar problem and spent hours googling to figure out how to do it in .net 2.0 but all the efforts were in vain. Than after a lot of hit and trial and reading source files I hit this annotation JsonProperty("my-name") and hurray it worked. Just to provide a small example usage: JSON: {"my-name" : "Biplav"} C# snippet: public class Name {    private String m_my_name;    [JsonProperty("my-name")]    public String my_name    {       get { return m_my_name;}       set  { m_my_name = value;}   }

How function overriding is different in C# from Java?

If you are moving from Java to C#, than this is one thing which you would find very funny. Suppose you wrote the following code: class a {    public void display()     {      Console.WriteLine("A");    } } class b:a {    new public void display()    {     Console.WriteLine("B");    }  } And did something like: A a = new B(); a.display(); B b = new B(); b.display(); The output would be: A B Although we expect here that as we have overriden display in B, so the display of B must be called. But this assumption is incorrect as we have reserved reference for A, so the C# compiler won't know that B can override display function. Hence we need to tell the compiler that there is a possibility that display can be overriden in derived classes and please check for it. To do so we would have to define the baseclass function which can be overriden ...