Archive

Archive for the ‘Career’ Category

Installshield LE Dependency dll build issue

November 21, 2013 1 comment

I was trying to make an Win app installer package with installshield limited edition. I added the project primary output and the setup built successfully, it is installed correctly but now the problem is,

Three of the referred projects dlls are properly built, but one project  dll is not latest. meaning that an old version of that dll is built and copied in the setup.

After hours searching on the google, trying rebuilding and trying changing project build order, still couldn’t overcome the issue. But finally this was the solution.

1. Open File option on installshield project. (Setup project –> (2)Specify Application Data –> File)

2. Go to destination computer files.

3. Right click on Primary Output and select ‘Dependencies from scan at build’.

4. That’s It. anyway i hate this new Installshield LE, previous setup and deployment option was much simpler.

(Will add a screen later, right now i am getting error when try to attached image to post. )

EF Navigation Property Looping Issue

This is a problem i faced today, while working on a project which uses EF 4.0.

In my db, there are two tables, say Item and Status. Item’s status is referring status table. Note that there are another tables like ‘Category’, ‘Type’ which are also referred by ‘Item’ table. This table structure wasn’t changed recently and was working fine with EF (4.0 with ObjectContext).  Recently we loaded around 1 million items to Item table for testing. After that, item updating and inserting started to work abnormal way. when i closely look in to matter, it was happening when i assign a value to reference property. As a example,

exitingItem.ItemStatusId = itemStatus;
context.SaveChanges();

when i execute first line, it is going loop forever. What i wonder is, this is happening only when i assign value. so this is happening on context. even not before save to DB.

After goggling, i found the exactly same problem on stackoverflow.

http://stackoverflow.com/questions/6361272/ef-navigation-property-looping-issue

This explains what is happening with POCO generated class.

I have a another project, there i used EF5 with DbCotext. when i test the same scenario with same DB, it was working fine. Reason is DbContext does not generate Fixup methods.

Solution : As above link explained, solutions are

  • Remove the Person collection from your AddressStatusLookup class (as you already tried with success). It’s usefulness is questionable anyway.
  • Or: Don’t work with lazy loading
  • Or: Remove the fixup methods from the generated classes. (Perhaps it’s possible to tweak the T4 templates and create a custom template to suppress generating these methods in the first place, but I am not sure.)

With the time frame, disabling the Lazy loading is not possible with us.

removing the navigation property i didn’t consider.

I went with the Removing fixup methods. This was also not straight forward. One article explained to delete fixup generating sections on POCO as this.

If you open the .tt fle, you’ll notice region.Begin("Association Fixup"); (line 303) which ends on line 632. You might want to delete that area and see what you’ll get.

But i had to delete calls to the fixup methods from the property setters, registration of CollectionChanged handlers, and the _settingFK flag from POCO to successfully generate the classes. This way update and insert is happening as normally with 1 million data.

(purpose of fixup is to ensure that each end of a bidirectional relationship stays in sync with the other, but since we use entities via EF context, not interdependently we don’t have to worry for these fixups) 

Debugging Windows Service

January 10, 2013 1 comment

I was working with a windows service nearly one year and hopefully I will be working with this in next couple of months, may be next couple of years due to working on a product based company.  🙂

As most of the developers have experienced, it was a headache to debug a windows service.  So think about working with a same windows service around a yearL. Very beginning I found a solution. That was

  1. Have a key on app.config  as “DebugMode=true”
  2. In the code, I have put following line of code, where I mostly want to debug. (if I want new place, I add same code there) DebugMode value will be assigned based on app.config key.

if (DebugMode)
System.Diagnostics.Debugger.Launch();

  1. This was fine. But issue was  with this way is,

Every time I had to compile the code, prepare the setup, uninstall and install on machine. If single line of code changed, had to follow same steps. (Installed version of code and IDE code version should be exactly match)

So today I came up with a better solution. Simple steps. But it saves time, especially when release is nearby :).

  1. Get rid of config key 🙂
  2. Above debug mode property populated by this way. This will get value based on configuration. If we select debug, this will be true and if we select release, this will be false.

public static bool DebugMode

{

get

{

bool isDebugMode = false;

#if DEBUG

isDebugMode = true;

#endif

return isDebugMode;

}

}

  1. I will add here whole Main method of Program.cs class. Only we need to change is, select the correct configuration. After finish the debug, select configuration as ‘release’ and build the setup. Don’t be confused with the code. what I do here is,
    1. If debug mode is true, do exactly what I do in the windows service class and start the application. You have to change the project type to ‘console application’ to open the console. But what I wanted here is not to see console, I just wanted to hit the break point without going through set of steps.
    2. If debug mode is false, call the windows service as normally.

static void Main()

{

if (DebugMode)

{

try

{

string serverURL = string.Format(“http://localhost:{0}/”, ConfigurationManager.AppSettings[“ServerPort”]);

AppHost _appHost = new AppHost();

MiddleWareEngine = new MiddleWareEngine();

MiddleWareEngine.StartEngine();//starting middleware

//Now run the Services.

_appHost = new AppHost();

_appHost.Init();

_appHost.Start(serverURL);

Console.WriteLine(string.Concat(“Middleware Server Started on “, serverURL));

}

catch (Exception ex)

{

Console.WriteLine(“Error: ” + ex.Message);

}

}

Else //Release mode

{

ServiceBase[] ServicesToRun;

ServicesToRun = new ServiceBase[] { new DominateRFIDAlertService() };

ServiceBase.Run(ServicesToRun);

}

}

Good Bye Visual Studio Installer Projects

December 27, 2012 2 comments

As Microsoft had announced on 2010 , Visual Studio Installer Projects have been removed with latest Visual studio release. (VS 2012).  Recently i was trying to convert our existing VS 2010 solution to vs 2012, got the problem. All the other projects on the solutions were converted successfully and Setup project gave error as project type not installed. At first i thought that i have to create all the setup project from the beginning.  But with few steps, could convert all to ‘InstallShield Limited Edition’ projects.

  1. InstallShield Limited Edition is not installing when we install VS 2012. (I am not sure with other versions, but i use VS 2012 ultimate and it didn’t had InstallShield Limited Edition installed)
  2. Even after installing InstallShield Limited Edition, those setup project will not convert by opening it. (which i thought that way would work)
  3. First open the Vs 2010 solution with VS 2012, it converts all other projects with error of setup project cannot convert.
  4. Remove existing setup project from solution.
  5. open add new project dialog for solution. select the ‘Other project type’ and select the ‘InstallShield Limited Edition Project’
  6. It should not be installed if you didn’t install it previously. so when you try to open the project it will show a message on browser to download the InstallShield Limited Edition
  7. Follow the instruction and download the InstallShield setup. they will send the key to activate to entered email address.
  8. After install, you might have to restart the VS. enter received serial no and activate
  9. Now same as step 5, add InstallShield setup project and on the InstallShield menu on main menu, select ‘Visual Studio Deployment Project Import Wizard…’
  10. Select your vs 2010 setup project file.  Hopefully it will convert without error. i didn’t had to do any changes on converted project.

 

How to avoid ‘WebForms.PageRequestManagerServerErrorException’ error

December 9, 2012 Leave a comment

This error i got suddenly, when i use partial post back to server on Asp.net aspx page. this page was working perfectly for months and today only i got this.  After looking into this sometime, only thing has changed here is now i have more data on the page.  But there is no way to catch the error and visual studio is returning this error when i click any control on the page.

WebForms.PageRequestManagerServerErrorException

When i look on the windows event log, exception was logged there as,

Operation is not valid due to the current state of the object.
at System.Web.HttpValueCollection.ThrowIfMaxHttpCollectionKeysExceeded()
at System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding)
at System.Web.HttpRequest.FillInFormCollection()

What has happen was because of more data on the page, It is generating  “ThrowIfMaxHttpCollectionKeysExceeded” error.

To overcome this issue you have to add following key to web.config as follows,

<appsettings>
   <add key=”aspnet:MaxHttpCollectionKeys” value=”2000″></add>
</appsettings>

P/S : After looking into this issue on the web, i found this information,

 Microsoft released a security update KB2656356 / MS11-100 for ASP.NET to address a potential Denial of Service vulnerability.  In the update, Microsoft introduced a limit to the number of data elements on an ASP.NET form.   The default limit is 1000 data elements.   Exceeding the limit will cause a ThrowIfMaxHttpCollectionKeysExceeded error.

After applying the patch to your webserver, forms that exceed the limit will generate the following error when posting:

Categories: Career, Technical

Programming in HTML5 with JavaScript and CSS3 (Exam 70-480)

November 27, 2012 Leave a comment
If you are interested to complete above mentioned exam, this is good chance.   is offering a free exam voucher for this. Bellow i have added the voucher code and some information.  you can go to their web site and get more information if needed.
FREE EXAM VOUCHER FOR 70-480! | Register now to take Exam 70-480 Programming in HTML5 with JavaScript and CSS3 for FREE! Just use this voucher code when scheduling your exam: HTMLJMP (voucher code available through 3/31/2013 or while supplies last.)
This is very latest exam which was published on august. So cannot find much resources and even still microsoft have not provided official book for this exam .(according to my knowledge) but most of people using “Microsoft_Press_eBook_Programming_Windows_8_Apps_with_HTML_CSS_and_JavaScript_Second_Preview_PDF” ebook and Pluralsight Videos.
I have gone through some of the available materials, seems to be very interesting because HTML 5 is new trend on the industry.  I will list some other links, which i am referring.  Go through those and register for the exam if you are interested.

What’s New in Visual Studio TFS 2012

September 9, 2012 Leave a comment

While playing with new TFS which comes with visual studio 2012, i got to know that it is now having more support for agile methodologies.  Rather writing my own post about new TFS 2012, i found a very good and organized article, which describe everything with TFS 2012.

http://mohamedradwan.wordpress.com/2012/05/30/whats-new-in-tfs-2012-management-tool/

Before buy it, you can try it with http://tfspreview.com/ . Site itself explaining new features and how to use it. i created test project under TFS Preview, created few test tasks, added few classes on VS under that task, used code review, TRIED with creating with build. Just simple test. but feel new TFS is awesome.

Windows 8

September 8, 2012 Leave a comment

I was using win 8, when they released first developer preview and uninstalled it after few weeks. Reason was it had to be improved lot. lack of usability, poor performance (even though it boot up within few seconds), etc.

recently i had to install Win 8 again for the ‘Win 8 Boot camp’ and used final release of it. (windows_8_x64) Well.. happy to say there is nothing to complain for me. it is awesome. Super fast. (i heard Microsoft rewrote the OS completely). And i was warring about removing the start button. But now i feel it is good change.  Just think how many of you guys use Start menu and go to relevant program and click it.  i have not done this for years. what i really do is click start menu and type the first few letters of what i want to open and press enter. And mostly  used apps like ‘VS’, ‘Chrome’, ‘SQL management studio’, ‘media player’ are already pinned on task bar. So no need to gor for start button. This is the reason they have removed start button and menu. So for me it is good change.

It is true that it is better with touch screen. But still without touch screen, it is not much different and not difficult to use.

There are several improvement i noticed compared to previous version of windows OS. Most of them were already available on Phones.

1. Windows Store – Similar to app store and google play

2. User login – this is bit similar to Android phones login. same as it ask for google account, Win 8 is asking microsoft user login (may be it can skip and use normal user login and password, i used my outlook login). after that same as latest smart phone works, win 8 is syncing with entered login (and if we link FB, G+,.. it will sync those all) and collecting all the contact. Those will display on people app.

3. Improvement on windows explore

4. Reset option

5. Short boot time

6. Changed task manager

I feel that future OS are more focusing in to mobile devices. Currently i am writing my first test App for win 8.

Message Pass to Client with WCF

Recently i got a requirement to implement simple message passing from server to client machine. In my case, there is a midddleware which is running on server machine and processes  data coming from RFID tags and antennas.  Middleware should send a message to client machine as alert or popup window, when specific event is raised.

this is how i implemented that with WCF.

1. Create Alert Client project and add following classes and windows form.

Windows form – i made this to run on system tray and wait for server’s messages. this may used as windows services also.

public partial class Tray : Form

{
public ServiceHost serviceHost = null;
private ContextMenu trayMenu;
private NotifyIcon notifyIcon1;

public Tray()
{
InitializeComponent();

trayMenu = new ContextMenu();
trayMenu.MenuItems.Add(“Exit”, OnExit);

notifyIcon1 = new NotifyIcon();
notifyIcon1.Icon = new Icon(SystemIcons.Application, 40, 40);
notifyIcon1.ContextMenu = trayMenu;
notifyIcon1.Icon = SystemIcons.Exclamation;
notifyIcon1.BalloonTipText = “Alert client is waiting on the system tray.”;
notifyIcon1.BalloonTipIcon = ToolTipIcon.Info;
}

protected override void OnLoad(EventArgs e)
{
SetBalloonTip();
ShowInTaskbar = false; // Remove from taskbar.
base.OnLoad(e);
}

private void SetBalloonTip()
{
this.Click += new EventHandler(Tray_Load);
}

private void OnExit(object sender, EventArgs e)
{
Application.Exit();
}

private void Tray_Load(object sender, EventArgs e)
{
LoadService();
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(30000);
}

private void LoadService()
{
if (ServiceHost != null)
{
serviceHost.Close();
}
// Create a ServiceHost for the Service type and provide the base address.
serviceHost = new ServiceHost(typeof(NotificationService));

// Open the ServiceHostBase to create listeners and start listening for messages.
serviceHost.Open();
}
}

Add Following 2 classes

// Define a Service Contract.
[ServiceContract(Namespace = “http://AlertClient&#8221;)]
public interface INotifyClient
{
/// <summary>
/// Sets the pop up.
/// </summary>
/// <param name=”alertText”>Type of the alert.</param>
/// <returns></returns>
[OperationContract]
bool SetPopUp(string alertText);
}

// Implement the Service Contract in a Service Class.
public class NotificationService : INotifyClient
{
/// <summary>
/// Sets the pop up.
/// </summary>
/// <param name=”alertText”>Type of the alert.</param>
/// <returns></returns>
public bool SetPopUp(string alertText)
{

AlertForm popup = new AlertForm();
popup.AlertText= alertText;
popup.Show();

return true;
}
catch
{
return false;
}
}
}

Now have to add new form as AlertForm and set a public property on it as AlertText (or can populate this while calling the form constructor)  that is it with client. now you can run this. if service is running, you could be able to access following URL.

http://localhost:8005/AlertNotifier/service

in the server side, refer above URL and add service reference.  

just add following line of code to where you need to send messages.  (and pass the client’s ip)

string endpointConfigName = “WSHttpBinding_INotifyClient”;
string serviceAddress = string.Format(“http://{0}:8005/AlertNotifier/service”
,clientIp.Trim());

AlertNotifierServiceReference.NotifyClientClient notify =
new AlertNotifierServiceReference.NotifyClientClient(endpointConfigName, serviceAddress);

bool success = notify.SetPopUp(“test message”);

That is It…!

 

P/S : Client should be run in admin mode. otherwise you will get a error.

Categories: Career, Technical Tags: , , ,

Introduction to Object Oriented Programming

recently i got interesting article to read on codeproject.

the massive expansion of the software industry is forcing developers to use already implemented libraries, services and frameworks to develop software within ever shorter periods of time. The new developers are trained to use (I would say more often) already developed software components, to complete the development quicker. They just plug in an existing library and some how manage to achieve the requirements. But the sad part of the story is, that they never get a training to define, design the architecture for, and implement such components. As the number of years pass by, these developers become leads and also software architects. Their titles change, but the old legacy of not understanding, of not having any architectural experience continues, creating a vacuum of good architects. The bottom line is that only a small percentage of developers know how to design a truly object oriented system. The solution to this problem is getting harder every day as the aggressive nature of the software industry does not support an easy adjustment to existing processes, and also the related online teaching materials are either complex or less practical or sometimes even wrong. The most of them use impractical, irrelevant examples of shapes, animals and many other physical world entities to teach concepts of software architecture. There are only very few good business-oriented design references. Unfortunately, I myself am no exception and am a result of this very same system. I got the same education that all of you did, and also referred to the same resource set you all read.

As I see it, newcomers will always struggle to understand a precise definition of a new concept, because it is always a new and hence unfamiliar idea. The one, who has experience, understands the meaning, but the one who doesn’t, struggles to understand the very same definition. It is like that. Employers want experienced employees. So they say, you need to have experience to get a job. But how the hell is one supposed to have that experience if no one is willing to give him a job? As in the general case, the start with software architecture is no exception. It will be difficult. When you start to design your very first system, you will try to apply everything you know or learned from everywhere. You will feel that an interface needs to be defined for every class, like I did once. You will find it harder to understand when and when not to do something. Just prepare to go through a painful process. Others will criticize you, may laugh at you and say that the way you have designed it is wrong. Listen to them, and learn continuously. In this process you will also have to read and think a lot. I hope that this article will give you the right start for that long journey.

http://www.codeproject.com/KB/architecture/OOP_Concepts_and_manymore.aspx

Categories: Career, Technical