Tuesday, November 22, 2016

Redis Cache and session start up.

I should have posted these a year earlier. Better late than never. As you might know setting up Redis is not easy task on your own in a windows machine for doing some development and testing. That itself will take a lot of time. But we are in luck. You can use Chocolatey package installer to setup the server and related configs easily. Install Chcolatey, use the PowerShell command its so cool, and click this link for redis command. Redis is done and the server will be available on default port (refer Redis site for details).

Now there are easy packages available through Nuget that will help you out with some samples based on MVC so start coding.

Will post some detailed links here later to help you out with some custom cache and session providers as i can't post mine due to some stupid rules.


C++ dll in C#

Yesterday i was passed on a task to Wrap up a c++ based dll to our c# based code base. And i had to confront lot issues for that, mainly Memory Access violations and Entry Point not found, pass by value and pass by reference issues. So i have made some small check list to help you out.

If you have the source to the c++ better, else lotto of debugging issues caused by your c++ dll will be hard to find,


1) Finding the correct entry point.
    a)If you have  the source use "extern c" in header files,
             This will help you out with the usage of function name and related problems,
    b) Else take the dump and check the function name and use it,

2) Parameter related issues
        Make sure the type are right are you passing by value or reference, some times as simple as StringBuilder can be of great use.

3) Does this dll have any read or write dependencies like logging.
       This did cause a lot of issues, as the dll some time uses file as parameters and at times also write some logs, beware if the logs are written inside the Bin folder, this might cause a rebuild of your app. Also setting up the correct folder paths might be also important with the proper read right access.


will add some examples in future.

Saturday, May 14, 2016

Session lost and reloading of binaries issue

Have you ever faced an issue where the session seems to be lost and in your visual studio there seems to be reloading the binaries while running your application, if yes then this might help.

check weather new files are being created in Bin folder or check if there is change in time after the previous build time for any dll or files. If so this will cause the reload of binaries and assemblies that you have used. Which will cause the restart of server(IIS or other ), resulting in lose of session.

Monday, September 21, 2015

Unable to add WCF Service to MVC web application

Yesterday I can across a issue where i wasn't able to add the WCF service in solution to the WEB application in the same  solution. I searched and snooped for a day couldn't find the problem as i didnt see any error message of any sort, even tried adding to a console application that worked but still no success with the web app.
A day later i checked the error list and saw some error showing unable to generate the service reference codes.

Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.DataContractSerializerMessageContractImporter
Error: Could not load file or assembly 'Microsoft.Owin.Security, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://tempuri.org/']/wsdl:portType[@name='ICoreService'] WebRole\Service References\ServiceReference1\Reference.svcmap 1 1 WebRole

I googled it and found a very simple answer.
Check this link to know about the solution

Here when you  add the service click the Advanced... button in the bottom left corner of the Add Service Reference window. On the Service Reference Settings screen that appears, in the Data Type section, under the Reuse Types in referenced assemblies: check-box, select the Reuse types in specified reference assemblies radio button then check ONLY the assemblies that contain types used by the service. Here try avoiding the OWIN related assemblies and check all others if you are not sure what all to add.

Monday, September 14, 2015

D3 js join / update not working as expected

If there are rendering issues with the update pattern i.e regarding the location of the new items in the data array then try out this pattern.

var text = svg.selectAll("text").data([]);

text.exit().remove();

text = text.data(data);

text.enter().append("text")
.attr("class", "enter")
.attr("x", function(d, i) { return i * 32; })
.attr("dy", ".35em");.

text.text(function(d) { return d; });

Here i have initially passed a empty array to remove all the point and then add the new one, i have faced some issues while we pass very little data may be array of length One to update the text. Where in my case i had an nested array with data that was being passed.
eg: [ [N,1,20], [N,1,25]]  Here 20,25 denotes the data part. The update array was also of same length with data slightly different as [ [N,1,29], [N,1,22]]

Thursday, September 10, 2015

D3 js the join pattern some intro.

This article is for some one who is trying get the update patter work in d3 js. I tried out the link http://bl.ocks.org/mbostock/3808218 which show some basic update patter. The same code works, but unfortunately when implementing similar case the result wasn't the same, After looking in to the code i realized that certain type of manipulation on d3 might not work as expected.

My initial code was something like this.

var text = svg.selectAll("text").data(data);
text.enter().append("text")
.attr("class", "enter")
.attr("x", function(d, i) { return i * 32; })
.attr("dy", ".35em")
.text(function(d) { return d; });

text.exit().remove();

Notice in the above code i have combined the setters for attributes and the final text assigning in the same line. This code doen't seem to work for some reason. So i change back to the orignal set.

var text = svg.selectAll("text").data(data);
text.enter().append("text")
.attr("class", "enter")
.attr("x", function(d, i) { return i * 32; })
.attr("dy", ".35em");

text.text(function(d) { return d; });

text.exit().remove();

And now it works. So if you are working with some similar scenarios try grouping different set of operation if the Update patter doesn't work for you.