tag:blogger.com,1999:blog-130213822024-02-28T20:53:15.924+03:00Byte FoodSoftware development stuff.Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.comBlogger63125tag:blogger.com,1999:blog-13021382.post-5920142681391046332013-06-29T20:38:00.001+03:002013-06-29T20:38:31.691+03:00Starting with Entity FrameworkI realise I come late to the party. But I was just playing around at home with some development in MVC4 and wanted to try out entity framework for DB access.<br />
I learned that there are 2 main approaches:<br />
<br />
<ul>
<li>Code first</li>
<li>Database first</li>
</ul>
<div>
I figured that since I'm just starting and I need to fill control over the data I would go with Database first.</div>
<div>
Googling Database First brought me to this 5 mins video that cleared everything up! </div>
<div>
<br /></div>
<div>
I recommend watching, if you are in a similar situation:</div>
<div>
<a href="http://msdn.microsoft.com/en-us/data/jj206878.aspx">http://msdn.microsoft.com/en-us/data/jj206878.aspx</a></div>
<div>
<br /></div>
<div>
<br /></div>
Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com2tag:blogger.com,1999:blog-13021382.post-23507523361752300972012-07-27T13:02:00.000+03:002012-07-27T13:02:10.423+03:00Visio 2003 Oracle DB reverse engineer, fatal errorI ran into this error while trying to Reverse Engineer an Oracle database with Visio 2003: "Encountered a fatal error during reverse engineer of information from the database!".<br />
<br />
I found the solution <a href="https://forums.oracle.com/forums/thread.jspa?threadID=339395">here </a>and it's as simple as choosing the Visio Driver "Generic OLE DB Provider" initially.Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-90896213045229253912012-07-19T13:14:00.000+03:002012-07-19T13:14:38.492+03:00Link Changesets to Work Items in TFSUseful information on how to link a changeset to a workitem, after checking in, if for some reason you didn't do it at the check-in time.<br />
See <a href="http://blueorbitsoftware.com/blog/?p=155">here</a>.Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-15217567089936079272012-04-10T18:10:00.008+03:002012-04-10T18:30:24.738+03:00IE9 scroll jumps to the top when the browser has a scrollbar<span><span style="font-size: 100%;">Internet Explorer 9 has one very strange behaviour where inner div's with scrollbars can jump up to the top by themselves.</span></span>
<br/><br/>
In my case the problem happened when using jquery ui resizable and draggable on DIVs, when using IE9 <b>and the browser has scrollbars</b> (note that the problem only happens when the browser has scroll bars). If the DIV has an inner DIV with height 100% and overflow scroll or auto. When the outer DIV was resized or dragged the scroll of the inner DIV would jump to the top.
<br/><br/>
<span><span style="font-size: 100%;">After a long investigation (with no google references found at all) I came down to this simple demo of the problem:</span></span>
<br/><br/>
I filtered the problem down to changing the absolute position of a div in IE9 with scrollbars on the browser.
<br/><br/>
<b>The solution: set "position: relative" on the BODY.</b>
<br/><br/>
<div style="border: 1px solid black; background-color: yellow; color: black;">
<html>
<head runat="server">
<title>TEST</title>
<script type="text/javascript" src="/Spreadex.Otp.Fins.Web/Scripts/framework/jquery-1.7.2.min.js"></script>
</head>
<body>
<div id="resres" style="width: 1500px; height: 300px; background-color: Red; position: absolute; ">
Test Resizable
<div style="width: 300px; height: 100%; overflow: scroll" id="testScroll">
AAAAAAAAAAA<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
BBBBBBBBBB<br />
CCCCCCCC<br />
<br />
</div>
</div>
<br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br />
<button onclick="res1()">res1</button>
<button onclick="res2()">res2</button>
<script type="text/javascript">
function res2() {
//$('#resres').css({ top: 8 });
document.getElementById('resres').style.top = "8px";
}
</script>
</body>
</html>
</div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com1tag:blogger.com,1999:blog-13021382.post-52853022668984589182012-03-30T19:01:00.004+03:002012-03-30T19:25:21.499+03:00Downloading files with Internet Explorer 8 or below, and setting the Cache Control on ASP.NET MVC 3This one is worth posting since it took some time and lots of googling to figure out.
<br/>
The web site is ASP.NET MVC3, the browser is IE8 or lower version.
<br/><br/>
When downloading a file with HTTPS we get the error:
<br/>
"Internet Explorer cannot download filename from sitename. Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."
<br/><br/>
This is a "feature" on IE: See <a href="http://stackoverflow.com/questions/3415370/ie-unable-to-download-from-unable-to-open-this-internet-site-the-request">http://stackoverflow.com/questions/3415370/ie-unable-to-download-from-unable-to-open-this-internet-site-the-request</a>
<br/><br/>
And the best workaround is to set the "cache-control" header to "private" for these browsers.
<br/><br/>
The next problem was that setting the cacheability on MVC3 only works if you set it to a value greater than what it is now. So if you set it to NoCache, you can not set it again to Private.
<br/>
See <a href="http://weblogs.asp.net/andrewseven/archive/2005/04/06/SetCacheability.aspx">http://weblogs.asp.net/andrewseven/archive/2005/04/06/SetCacheability.aspx</a>
<br/><br/>
So, if your website has a generic nocache policy and you want to set a specific request to "private" you need to make sure NoCache is never being set on the same request.Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-49606074228580462832011-12-06T17:30:00.004+02:002011-12-06T17:31:57.931+02:00Google Adwords conversion failing with Ajax<div>Google adwords conversion script (conversion.js) uses document.write(), which prevents it from working correctly when using dynamic Ajax page loading.</div><div>
</div><div>Excelent workaround here:</div><div><a href="http://articles.adamwrobel.com/2010/12/23/trigger-adwords-conversion-on-javascript-event">http://articles.adamwrobel.com/2010/12/23/trigger-adwords-conversion-on-javascript-event</a></div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-37641628139726653032011-08-31T16:32:00.000+03:002011-08-31T16:32:07.941+03:00Visual Studio Macro: Locate Item in Solution Explorer<div>This is a great macro that allows you to locate the current file in edition on the Solution Explorer:</div><div>
</div><a href="http://dvanderboom.wordpress.com/2008/03/21/visual-studio-macro-track-item-in-solution-explorer-on-demand/#comment-1900">Visual Studio Macro: Locate Item in Solution Explorer on Demand « Critical Development</a>:
Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-3980648703940145672011-08-05T12:52:00.000+03:002011-08-05T12:52:26.796+03:00Using WinMerge with Team Explorer and TFS<div>Nice page explaining how to change the default file compare on Visual Studio Team Explorer:</div><div> <a href="http://www.neovolve.com/post/2007/06/19/using-winmerge-with-tfs.aspx">Rory Primrose | Using WinMerge with TFS</a></div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-59758195361023805682011-08-03T17:08:00.000+03:002011-08-03T17:08:24.814+03:00WCF and error serializing enums<div>I had a similar problem as described here: <a href="http://www.darkside.co.za/archive/2008/08/01/wcf-error-caused-by-a-serialisation-issue.aspx">WCF error caused by a serialisation issue</a></div><div>The exception thrown was too generic: <span class="Apple-style-span" style="color: rgb(255, 0, 0); font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; ">The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.7490000'</span></div><div>
</div><div>The best way to go to find reasons for problems not explicitly shown by WCF exceptions is to use the Trace Viewer described in this <a href="http://stackoverflow.com/questions/204032/complex-data-types-in-wcf">thread</a>.</div><div>Exception was all in the log generated by the server side of WCF.</div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-1575613168919348922011-07-21T12:42:00.001+03:002011-07-21T12:42:32.520+03:00Visio diagram lines changed on copy paste?<div>I drew my diagram on Vision 2003 all nice, when I copied it to Word the dashed lines were changed to solid lines!</div><div>Found the resolution on good old Microsoft Support site.</div><div>
</div><a href="http://support.microsoft.com/kb/837294">Dashed or dotted line patterns are converted to a solid line pattern when you embed a Visio 2003 object in another document</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-20735683436174312212011-07-18T18:33:00.002+03:002011-08-08T17:30:42.757+03:00Using IDs in jQuery Mobile Pages<div>With JQuery Mobile different server pages are loaded on the same client DOM.</div><div>If you need to access an element by ID or class which conflicts with another element on another page with the same ID or class (in my case it was the same page with different parameters) you can use the ancestor on the JQuery selector as described by cplee70 in this forum thread:</div><div>
</div><a href="http://forum.jquery.com/topic/using-ids-in-jquery-mobile-pages">Using IDs in jQuery Mobile Pages - jQuery Forum</a>: "<div>
$('div.ui-page-active .lat')
instead of just:
$('.lat')</div><div>
</div><div>
</div><div><b>EDIT:</b></div><div><b>Better yet, I started using: $('.lat', $.mobile.activePage)</b>
</div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-20052487080413619182010-06-23T19:49:00.002+03:002010-06-23T19:55:13.409+03:00aspnet_wp.exe stopped unexpectedly<div>On one of our deployed environments ASP.NET crashed completely when accessing an Interop dll that invokes MATLAB code.</div><div>We isolated the line of code that had the problem, this would run ok from a console application but crash miserly on ASP.NET. Event viewer shows "aspnet_wp.exe (PID: xxxx) stopped unexpectedly".</div><div>
</div><div>After spending a lot of time trying different things and googling, I finally ran into <a href="http://www.issociate.de/board/goto/769838/aspnet_wp.exe_crashing.html">this one</a>. </div><div>I'm not sure of the security consequences of this change, but since it is on the .NET context, for that environment it seems like a safe solution.</div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-52306199496014141162009-10-15T15:34:00.001+03:002009-10-15T15:36:08.386+03:00Xcopy not working from System.Diagnostics.Process.Start()This one wasn't easy.<div>See <a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ab3c0cc7-83c2-4a86-9188-40588b7d1a52/">http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/ab3c0cc7-83c2-4a86-9188-40588b7d1a52/</a>
<div>"<span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, sans-serif; font-size: small; ">This is a quirk of xcopy.exe. If you redirect the output, you have to redirect the input as well."</span></div></div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-25370973970887800682009-09-07T10:22:00.001+03:002009-09-07T10:23:09.216+03:00SQL 2008 - "Saving changes is not permitted."<div>On SQL 2008 Management Studio Icoudln't save the changes done on a table.</div>This seemed strange, but was easy to fix:<div>
<div><a href="http://weblogs.asp.net/pabloperalta/archive/2008/09/23/sql-2008-quot-saving-changes-is-not-permitted-quot-error-message.aspx">http://weblogs.asp.net/pabloperalta/archive/2008/09/23/sql-2008-quot-saving-changes-is-not-permitted-quot-error-message.aspx</a></div></div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-26506704587093857872009-04-21T21:28:00.003+03:002009-04-21T21:30:49.156+03:00Running dynamic javascript generated on the UpdatePanel partial postback<div>I found this great piece of code that allows a more or less generic way of running javascript generated during the processing of a partial postback within an UpdatePanel.</div><div>
</div><div>It runs all the script inside script tags with a certain ID.</div><div>
</div><a href="http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2008/08/dynamic-javascript-in-update-panel_19.html?showComment=1240338420000#c118959118652221112">http://www.31a2ba2a-b718-11dc-8314-0800200c9a66.com/2008/08/dynamic-javascript-in-update-panel_19.html?showComment=1240338420000#c118959118652221112</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-40908301301436049572009-04-17T10:48:00.002+03:002009-04-17T11:04:00.627+03:00Stuck with static constructor exception<div>It took me quite some time to understand why I was getting allways the same exception on a static constructor. So this blog confirmed what I suspected. The exception is cached and thrown again:</div><div>
</div><a href="http://weblogs.asp.net/avnerk/archive/2008/12/16/static-constructor-throws-the-same-exception-again-and-again.aspx">http://weblogs.asp.net/avnerk/archive/2008/12/16/static-constructor-throws-the-same-exception-again-and-again.aspx</a>
<div>I found this with .NET2.0
I believe .NET 3.5 works differently since they added this to the documentation:</div><div>"<span class="Apple-style-span" style=" line-height: 15px; font-family:Verdana;font-size:11px;">If a static constructor throws an exception, the runtime will not invoke it a second time, and the type will remain uninitialized for the lifetime of the application domain in which your program is running"</span></div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-87854375067917664072009-03-18T17:08:00.002+02:002009-03-18T17:10:59.977+02:00Check if 2 dates belong to the same week<div>I found this post while looking for the solution to the problem in C#.</div><div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="color: rgb(0, 0, 0);"><a href="http://quickduck.com/blog/2008/11/03/reader-challenge/" style="text-decoration: none;"> </a></span></span><span class="Apple-style-span" style="text-decoration: underline;"><a href="http://quickduck.com/blog/2008/11/03/reader-challenge/" style="text-decoration: none;">http://quickduck.com/blog/2008/11/03/reader-challenge/</a></span>
</div><div><span class="Apple-style-span" style="text-decoration: underline;">
</span></div><div>I endded up using the code:</div><div>
</div><div><blockquote><div> public static bool InSameWeek(DateTime d1, DateTime d2)</div><div> {</div><div> DateTime beginningOfWeekDate1 = GetFirstDayOfWeek(d1);</div><div> DateTime beginningOfWeekDate2 = GetFirstDayOfWeek(d2);</div><div> return beginningOfWeekDate1 == beginningOfWeekDate2;</div><div> }</div><div>
</div><div> /// <summary></div><div> /// Considers monday to be the first day of week</div><div> /// </summary></div><div> /// <param name="d"></param></div><div> /// <returns></returns></div><div> private static DateTime GetFirstDayOfWeek(DateTime d)</div><div> {</div><div> switch (d.DayOfWeek)</div><div> {</div><div> case DayOfWeek.Monday:</div><div> return d;</div><div> case DayOfWeek.Tuesday:</div><div> return d.AddDays(-1);</div><div> case DayOfWeek.Wednesday:</div><div> return d.AddDays(-2);</div><div> case DayOfWeek.Thursday:</div><div> return d.AddDays(-3);</div><div> case DayOfWeek.Friday:</div><div> return d.AddDays(-4);</div><div> case DayOfWeek.Saturday:</div><div> return d.AddDays(-5);</div><div> case DayOfWeek.Sunday:</div><div> return d.AddDays(-6);</div><div> default:</div><div> throw new ApplicationException();</div><div> }</div><div> }</div></blockquote>
</div>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-64318540417348388992009-01-17T15:23:00.000+02:002009-01-17T15:23:07.640+02:00Equals on Javascript between different typesEquality with javascript between differetn types has it's pitfalls, for example between bool and string.<br>
Fortunately there is the operator ===<br>
'false' == '' -> true<br>
'false' === '' -> false<br>
<br>
See <a href="http://www.mapbender.org/JavaScript_pitfalls:_null,_false,_undefined,_NaN#Comparison_via_.3D.3D.3D">JavaScript pitfalls: null, false, undefined, NaN - MapbenderWiki</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-67281430846287108992008-11-05T18:26:00.000+02:002008-11-05T18:27:11.768+02:00Return a result code from a batch fileHow to return a result code (ERRORLEVEL) from a batch file.
<br>
exit /B 63
<br>
See <a href="http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_20687843.html">Batch script return code : return, batch, code, script</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-36187576886888711282008-10-13T14:17:00.000+03:002008-10-13T14:17:09.827+03:00Enable or Disable Triggers on SQL Server 7.0Icreated a trigger to prevent deletion of data from a table. but of course in some cases (Database initialization) ı need to override the trigger.
Here's how: <a href="http://www.devx.com/tips/Tip/13019">Enable or Disable Triggers on SQL Server 7.0</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-90595996310623391842008-10-06T14:42:00.001+03:002008-10-06T14:46:14.827+03:00Log unexpected exceptions in a windows service and in an APPDomain in generalMy services stopped without reason and I had no thing on the log except the System Event Log. A good solution to log fatal errors is to use the event AppDomain.CurrentDomain.UnhandledException (see
<a href="http://bytes.com/forum/thread238006.html">Cannot catch Exception in a thread - .NET C#)</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-48637071127142104622008-09-19T12:00:00.000+03:002008-09-19T12:00:31.080+03:00ınclude extra classes on a web service not referenced yb the parameters directlyWe created a webmethod that would receive a list of objects, Sometimes these objects are integers or strings, sometimes they can be a more complex type, like CustomClass[].
Turns out that with XmlIncludeAttribute solved the problem, thanks to this post:
<a href="http://social.msdn.microsoft.com/forums/en-US/asmxandxml/thread/6e95c165-afae-490e-8f5d-6bb351d4bd58/">WebMethod can't serialise an array of custom type : ASMX Web Services and XML Serialization : .NET Development : MSDN Forums</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-47421791829099290212008-07-11T18:57:00.000+03:002008-07-11T18:57:42.899+03:00F7 to switch from ASPX "Source" to C# codebehindThe trick is to configure the View.ToggleDesigner to F7.
From <a href="http://forums.asp.net/t/981786.aspx?PageIndex=2">F7 to switch from ASPX "Source" to C# codebehind - doesn't work? - ASP.NET Forums</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-82906636691241338912008-06-28T21:00:00.000+03:002008-06-28T21:00:22.731+03:00Caching in ASP.NET with a dependency on the SQL ServerAs I suspected when you use caching on ASP.NET 2.0 with SQL Server Dependency in SQL Server 2005 the system is not implemented with a polling mechanis as in previous versions of SQL Server. It uses the NOtifications Services to advise the ASP.NET that some cache item must be cleared.
See <a href="http://msdn.microsoft.com/en-us/library/ms178604.aspx">Caching in ASP.NET with the SqlCacheDependency Class</a>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0tag:blogger.com,1999:blog-13021382.post-57113370041253598052008-06-22T02:03:00.003+03:002008-06-22T02:27:21.480+03:00Microsoft certification 70-536I just watched an excellent <a href="https://www.livemeeting.com/cc/lmevents/view?id=msft061108lm&pw=ATT11784lm&cn=">presentation about the Microsoft certification 70-536</a> (Microsoft .NET Framework).
I was very impressed by the quality of the presentation and the functionalities of the player itself!
I have one certification made 3 years ago, and I want to do some more pretty soon, from what I could understand the first one to take for developers is the 70-536.
The presentation gives a general explanation about the content of the exam. It also gives out some links to resources (pasted below).
<!--[if !supportLineBreakNewLine]--><!--[endif]--><o:p></o:p><p></p> <ul type="disc"><li class="MsoNormal" style=""><a href="http://www.microsoft.com/learning/en/us/exams/70-536.mspx">Books and training</a><o:p></o:p></li><li class="MsoNormal" style=""><a href="http://en.csharp-online.net/Microsoft_Exam_70-536_Study_Guide">C# Online learning guide</a><o:p></o:p></li><li class="MsoNormal" style=""><o:p>Practices Tests: <a href="http://www.measureup.com/">measureup.com</a></o:p> , <a href="http://www.selftestsoftware.com/">selftestsoftware.com</a></li><li class="MsoNormal" style=""><a href="http://blogs.msdn.com/trika/">Blog about MS certifications</a>
</li></ul> <p class="MsoNormal">
</p><p class="MsoNormal">I want to get 2 kinds of materials (books?) one on the theory and one with exercises, but I still couldn't understand what's the best place for that (everyone I talk to uses some pirate memorize-the-answers books, but I think I don't want to go that way)<o:p></o:p></p>Azizhttp://www.blogger.com/profile/04897882710688926268noreply@blogger.com0