tag:blogger.com,1999:blog-63404586733564864812024-02-21T05:40:28.551+01:00Allan S. Laustsen on .NETAnonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.comBlogger18125tag:blogger.com,1999:blog-6340458673356486481.post-91541695814775233032014-07-30T09:55:00.001+02:002014-07-30T09:55:46.606+02:00Experienced software architect / developer seeking new challenges<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="MsoNormal">
<span lang="EN-US">After
working 7 years on the company I co-founded, I have decided that it is time to
find new challenges. If you or anyone in your network are looking for a highly
experienced software architect and developer, please inform them of my profile on linkedin or this blog.<o:p></o:p></span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US"><a href="http://dk.linkedin.com/in/laustsen/">http://dk.linkedin.com/in/laustsen/</a></span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
/Thanks in
advance<br />
<div class="MsoNormal">
<span lang="EN-US">Allan S. Laustsen</span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
<div class="MsoNormal">
<span lang="EN-US"><br /></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-55627012396649391252014-07-28T11:07:00.001+02:002014-07-28T11:07:16.188+02:00TortoiseSVN no icon/shell overlay in windows<div dir="ltr" style="text-align: left;" trbidi="on">
After updating or installing <a href="http://tortoisesvn.net/">TortoiseSVN</a> icons can get lost, it turns out that other shell overlay app's like DropBox or OneDrive can mess up the priority of the shell overlay handling in explorer, see <a href="http://pontusmunck.com/2010/01/19/fixing-the-missing-icons-in-tortoisesvn/" target="_blank">Fixing the missing icons in TortoiseSVN</a> for a fix/solution.<br />
<br />
To avoid rebooting after modifying the registry database use the following approach :<br />
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Arial; line-height: 18px; margin-bottom: 10px; margin-top: 10px; outline: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px !important;">
<span style="background-color: white; font-size: large;">"</span><i style="background-color: #f3f3f3; font-size: 12px;">Press CTRL + ALT + DELETE, to bring up the Windows task list. Highlight 'Explorer' and click on 'End Task', if the Shutdown screen is shown, click 'Cancel'. After a few seconds an error message will popup, click on 'End Task' and the Windows explorer will be reloaded along with any new registry settings.</i></div>
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Arial; font-size: 12px; line-height: 18px; margin-bottom: 10px; margin-top: 10px; outline: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px !important;">
<i style="background-color: #f3f3f3;">For <span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-size: 11px; margin: 0px; outline: 0px; padding: 0px;">Windows NT or 2000</span>, press Ctrl + Alt + Delete and select "Task Manager". Choose the "Processes" tab and locate the "explorer.exe" process, highlight it and click "End Process". Select 'File -> New Task', then enter 'explorer' and click OK.</i><span style="background-color: white; font-size: large;">"</span></div>
<div style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border: 0px; font-family: Arial; line-height: 18px; margin-bottom: 10px; margin-top: 10px; outline: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px !important;">
<span style="font-family: 'Times New Roman'; line-height: normal;">Thanks to <a href="http://www.pctools.com/guides/registry/detail/239/" target="_blank">Re-Initialize Your Registry Without Rebooting </a></span></div>
</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-90444670781575315692014-07-02T11:10:00.000+02:002014-07-28T11:11:01.313+02:00Restore Network Shares Without reebot<div dir="ltr" style="text-align: left;" trbidi="on">
If you had to restore a harddrive after a failure i.e. drive failure, RAID configuration or similar, you can restore/re-enable network shares by using this approach:<br />
<br />
Saving and restoring existing Windows shares<br />
<a href="http://support.microsoft.com/kb/125996">http://support.microsoft.com/kb/125996</a><br />
<a href="http://support.microsoft.com/kb/816113">http://support.microsoft.com/kb/816113</a><br />
<br />
<b>Solution, create bat file and run it:</b><br />
<span style="font-family: Courier New, Courier, monospace; font-size: x-small;"><i>RestartServerService.bat</i></span><br />
<span style="background-color: #f3f3f3; font-family: Courier New, Courier, monospace;">Net Stop Server</span><br />
<span style="background-color: #f3f3f3; font-family: Courier New, Courier, monospace;">Net Start Server</span><br />
<span style="background-color: #f3f3f3; font-family: Courier New, Courier, monospace;">Net Start "Computer Browser"</span><br />
<span style="font-family: Courier New, Courier, monospace;"><br /></span>
Prevent checkdisk from running<br />
<div>
<a href="http://blogs.technet.com/b/ganand/archive/2009/03/17/how-to-stop-chkdsk-from-running.aspx">http://blogs.technet.com/b/ganand/archive/2009/03/17/how-to-stop-chkdsk-from-running.aspx</a></div>
</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-64525532244664009642012-12-20T20:23:00.000+01:002013-02-19T08:47:17.488+01:00VS 2010 theme, color and icons, in VS 2012<div dir="ltr" style="text-align: left;" trbidi="on">
So after some time I decided it was finally time to switch from Visual Studio 2010 to 2012 as my default development IDE, the reason I waited was simply because the new UI (colors and theme in general) was simply slowing me down.<br />
<br />
I have a long time ago learned that the human brain is faster at recognizing images and patterns than reading text, you properly all have tried the test that was a National Geographic TV ad a couple of years ago, where only the first and last letter of each word was in the correct place, and still the brain was "reading" the words and entire text correctly. I think it was a excellent demonstration of how the brain sees patterns and tries to make logic of none-logic images of the world around us.<br />
<br />
So the new UI in VS 2012 is a gray, although in different shades of gray, single blob/mass, and actually I spent most of my time just trying to recognize the icons over-and-over again, I have simply come to familiar with the icons colors as a reference of where the "actions" I need to perform are located. ex. I tried to not put Icons with the same colors, but different functions up against each other, and if I do it normally means that the functions behind the icons are doing almost similar actions, and my brain knows (with out me think about it) that the third icon does something different than the first two icons. So when using any of the tools that I'm accustom to use, I don't "think" about the position of colors of the icons, my brain simply reuses the pattern it already knows for activating that function.<br />
<br />
Besides that Microsoft decided that the top menu should be in all UPPERCASE letters, come on.... everyone with just a little UI experience knows that uppercase text is MUCH harder to read than normal captions text, but why is that ? Well I think again it comes down to the pattern that the brain has to translate into something meaningful, properly cultures with symbol like alphabet like Chinese will have a faster reading rate with uppercase letters than cultures with a latin based alphabet, where we are used to using lowercase letters for most text. Of course we could "teach" or learn our brain to become familiar with the UPPERCASE style of the menus, but seriously Visual Studio is not a UI playground where new and un-proven UI interface adaptations should be implemented.<br />
<br />
So I have been trying to find some plugins/extensions/hacks that could "bring back" a more familiar UI. and so far I have come up with the following setup that gives me a interface that can work for me, and if your also need it just follow the guide :-)<br />
<br />
<ul style="text-align: left;">
<li>Install the <a href="http://visualstudiogallery.msdn.microsoft.com/366ad100-0003-4c9a-81a8-337d4e7ace05" target="_blank">Visual Studio 2012 Color Theme Editor</a> extension and choose the theme that you like, I prefer the "blue theme with white editor"</li>
</ul>
<br />
<br />
<ul style="text-align: left;">
<li>Install the <a href="http://visualstudiogallery.msdn.microsoft.com/a36021f0-770a-4258-854e-724e9d12b8a6?SRC=Home" target="_blank">NiceVS</a> extension that makes the top menu into correct Title case again.</li>
</ul>
<ul style="text-align: left;">
<li>Download the <a href="http://vsip.codeplex.com/" target="_blank">Visual Studio Icon Patcher</a> this is not a VS extension or plugin but is required to be run from a command line, unfortunately <a href="http://vsip.codeplex.com/wikipage?title=Version%201.5&referringTitle=Documentation" target="_blank">the guides</a> are not 100% clear on how to actually do this correctly. So i put in here a little step-by-step guide, however it requires that you have VS 2010 installed</li>
</ul>
<div>
<ol style="text-align: left;">
<li>Shutdown all visual studio instances</li>
<li>Start a DOS command prompt</li>
<li>Navigate to the folder where you have extract the Visual Studio Icon Patcher files</li>
<li>Run the following commands one-by-one</li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace;">vsip.exe extractmode</span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace;">vsip.exe backup -v=2010 -f</span><span style="font-family: inherit;"> (backup your VS 2010 files, just in case)</span></li>
<li><span style="font-family: inherit;"><span style="color: blue; font-family: Courier New, Courier, monospace;">vsip.exe backup -v=2012 -f</span><span style="font-family: inherit;"> (backup your VS 2012 files, just in case)</span></span></li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace;">vsip.exe extract -v=2010 </span>(extract the required icons etc. from your VS 2010 install)</li>
<li><span style="color: blue; font-family: Courier New, Courier, monospace;">vsip.exe inject </span>(this will replace the files from the VS 2010 extraction into VS 2012)</li>
</ol>
<div>
And you should now be done and have a VS 2012 where most (not all) icons, colors and theme are familiar to work with.</div>
</div>
<div>
<br /></div>
<div>
I certainly helped my transition to 2012 a lot, so instead of focusing on where the DAMM actions/icons are located, and what they look like now, I can focus on developing and solving real-world business issues that I'm loving..... </div>
<div>
<br /></div>
<div>
Have a great Christmas....</div>
</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-52111850058534555022012-12-20T11:34:00.001+01:002012-12-20T11:34:07.591+01:00My First Computer<div dir="ltr" style="text-align: left;" trbidi="on">
I just by chance stumbled upon a wiki link to my very first "PC", <a href="http://en.wikipedia.org/wiki/Amstrad_CPC" target="_blank">Amstrad CPC</a>, the 1000 of hours I spent on that thing, playing games and doing code in BASIC. But my the most surprising thing is trying to explain to my 9 year old soon, how it worked and especially how the tape-drive worked (and what a tape actually is) I tried to find a tape in our house but no more tapes exists apparently they have all been taken away by the sands of time :-)<br />
<br />
<i>(I'm getting old....)</i><br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-80732589997255772702012-12-20T11:23:00.000+01:002012-12-20T11:23:33.544+01:00Webservice (asmx) invoke method error after upgrade to .NET 4 (disable compression)<div dir="ltr" style="text-align: left;" trbidi="on">
After upgrading some of our old webprojects to .NET 4, we stumbled upon some strange errors when invoking asmx webservice methods. We got all kinds of strange responses back from the server and also on localhost the responses was looking realy strange.<br />
<br />
<br />
<i>Response in IE9:</i><br />
<span style="color: blue; font-size: x-small;">"Http 500 Internal Server Error"</span><br />
<span style="color: blue; font-size: x-small;">The website cannot display the page</span><br />
<div>
<br /></div>
<div>
<i>Response in Chrome:</i></div>
<div>
<span style="color: blue; font-size: x-small;">This webpage is not found</span></div>
<div>
<span style="color: blue; font-size: x-small;">Error 6 (net::ERR_FILE_NOT_FOUND): The file or directory could not be found.</span><br />
<br />
<i>Response in FireFox:</i><br />
<span style="color: blue; font-size: x-small;">� ����� �� ` I�%&/m�{J�J��t� �` $ؐ@ ����� iG#)�*��eVe]f @�흼��{���{��;�N'���?\fd l��J�ɞ!��� ?~| ?"^_7m� 7���ݶ�W�/Z�M�YY̲������</span><br />
<pre><span style="color: blue; font-size: x-small;">�<J��U��˶���:�eˋ���M�U�"���u�^eM:��|��� i;��iY���ֻE�4k��~�/ZW��/,�Ó�n��N�e� � �G��X��3���4M�6�#<V���m],/��`3J�iU��
��ʯG o7��պ��i-����wn��l��$zt�nE>K���o����A�X��y}YL�f�ڊ �л� �_f5����<��� ?�<� �[�mW�8��g ���� ?�X?�v�����IU��=5k 7�� ����77�{� ��</span></pre>
</div>
<br />
<br />
We tried debugging the code, but none of the breakpoints was hit, no event log errors, just a strange response from the webserver. So we <a href="http://duckduckgo.com/" target="_blank">googled around</a> to see if this was a know bug, but unfortunately not most was found that helped us out, however a lot issues poped up that looked related but in the end was not, apparently not many are upgrading old asmx webservices to a .NET 4 website.<br />
<br />
After testing various solutions and combinations of ideas finally we found out that the root bug was hidden for us behind the a response filter that was handling the GZIP/DEFLATE compression of the response. So we disabled the compression on that path/folder and then the root cause was clear, it was the requestValidationMode it needed to be set to: <span style="color: blue; font-family: 'Courier New', Courier, monospace;"><span style="font-size: x-small;"><httpRuntime requestValidationMode="2.0" /></span></span><br />
<br />
This bug took the most part of a day to fix, so the leason is:<br />
<span style="color: blue;"><b><i>Allways </i></b>disable HTTP Compression when debugging.</span><br />
<br />
<i>Some reference sources of problem:</i><br />
<a href="http://stackoverflow.com/questions/9786110/resource-not-found-when-trying-to-invoke-web-service-method" target="_blank"><span style="font-size: x-small;">stackoverflow.com/.../resource-not-found-when-trying-to-invoke-web-service-method</span></a><br />
<a href="http://stackoverflow.com/questions/7353834/invoke-of-asmx-webmethod-fails-with-xmlexception-but-works-without-an-asp-net-cl" target="_blank"><span style="font-size: x-small;">stackoverflow.com/.../invoke-of-asmx-webmethod-fails-with-xmlexception</span></a><br />
<a href="http://go4answers.webhost4life.com/Example/invoke-web-service-get-http-404-object-209471.aspx" target="_blank"><span style="font-size: x-small;">go4answers.webhost4life.com/./invoke-web-service-get-http-404-object-209471</span></a><br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-39575250281638030142012-12-20T10:53:00.000+01:002012-12-20T10:59:51.393+01:00An attempt was made to load a program with an incorrect format<div dir="ltr" style="text-align: left;" trbidi="on">
On 64 bit versions of windows you can recive an anoying error stating that "An attempt was made to load a program with an incorrect format".<br />
<br />
This can sometimes be caused by the fact that you are trying to reference a 64 bit dll in a 32 bit project, but it can strangely enough also be caused by a bug in VS 2010 involving resx files.<br />
<br />
I gathered a few reference links, about the issue:<br />
<span style="font-size: x-small;"><a href="http://stackoverflow.com/questions/2023766/an-attempt-was-made-to-load-a-program-with-an-incorrect-format-even-when-the-p" target="_blank">stackoverflow.com/.../an-attempt-was-made-to-load-a-program-with-an-incorrect-format</a></span><br />
<span style="font-size: x-small;"><a href="https://connect.microsoft.com/VisualStudio/feedback/details/532584/error-when-compiling-resx-file-seems-related-to-beta2-bug-5252020" target="_blank">connect.microsoft.com/VisualStudio/feedback/details/532584/....</a></span><br />
<a href="http://blogs.msdn.com/b/visualstudio/archive/2010/06/19/resgen-exe-error-an-attempt-was-made-to-load-a-program-with-an-incorrect-format.aspx" target="_blank"><span style="font-size: x-small;">msdn.com/b/visualstudio/.../resgen-exe-error-...-program-with-an-incorrect-format</span></a><br />
<span style="font-size: x-small;"><a href="http://stackoverflow.com/questions/2992075/could-not-load-file-or-assembly-or-one-of-its-dependencies-an-attempt-was-m" target="_blank">stackoverflow.com/..../could-not-load-file-or-assembly-or-one-of-its-dependencies</a></span><br />
<br />
I ran into this problem a few times, after any resource (resx) files was modified, and decided to find a solution that would work, and could be put inside the project/solution build cycle.<br />
<br />
Add to the project "pre-build" event<br />
<span style="color: blue; font-family: Courier New, Courier, monospace; font-size: xx-small;"><b style="background-color: white;">FORFILES /P $(ProjectDir) /M *.resx /S /C "CMD /C RegexConsole.exe @path \"AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w\" \"AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w\" I"</b></span><br />
<br />
It's important the the line of code is on a single line and that the RegexConsole.exe file is placed in a accesable path, put it in the system32 folder or another global %PATH% registered location.<br />
<br />
Downloads:<br />
<a href="https://dl.dropbox.com/u/45604423/Blogger.com/VS-Fix-resx-files-pre-build-event.txt" target="_blank">VS-Fix-resx-files-pre-build-event.txt</a><br />
<a href="https://dl.dropbox.com/u/45604423/Blogger.com/RegexConsole.zip" target="_blank">RegexConsole.exe</a></div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-83120317056082686732012-11-29T00:49:00.003+01:002012-12-20T19:34:51.318+01:00Umbraco 4.7.1.1 using Safari insert image in tinymce (RTE)<div dir="ltr" style="text-align: left;" trbidi="on">
Some of our new customers are using Safari, and they have stumbled upon some issues around using the Umbraco rich-text-editor (TinyMCE v3), they have problems with inserting images and macros.<br />
<br />
We <a href="https://www.google.dk/#hl=en&tbo=d&output=search&sclient=psy-ab&q=umbraco+tinymce+mce_marker&fp=7d456a22062b1e1d" target="_blank">googled </a>the problem a little, surely we couldent be the only Umbraco hosting company, which have end-clients using the Safari browser in the backend of Umbraco. But the top hits on google only revealed that there definitely was and is and long existing bug in Umbraco when it comes to the tinymce editor.<br />
<br />
The specific problem our clients was facing was that when trying to insert an image or macro the editor just rendered out the text "mce_marker" in the spot where they where trying to insert the element.<br />
<br />
We are currently running an Umbraco 4.7.1.1 install with a few custom patches that have yet to be implemented in the most resent versions of the Umbraco core + we are running MySQL as our db. So it's not that simple just to upgrade to the next release without testing, even though some forum entries state that the bug might be fixed in the most recent release, however I can not a resolved item in Umbraco issue tracker:<br />
<a href="http://issues.umbraco.org/issues/U4?q=mce_marker" target="_blank">issues with mce_marker</a><br />
Issue: <a href="http://issues.umbraco.org/issue/U4-397" target="_blank">can't paste into tinymce with Safari</a><br />
Issue: <a href="http://issues.umbraco.org/issue/U4-405" target="_blank">can't insert youtube video in Umbraco</a> (not sure if it applies to all browsers)<br />
And of course the frequent <a href="http://umbraco.codeplex.com/workitem/30194" target="_blank">dead link</a> to the old issue tracker.<br />
<br />
None of the issues was marked as resolved, so of to open the source and see where the underlying bug was happening. The bug was actually happening in the Safari plugin code for tinymce, but unfortunatly I'm not working on a Mac, so it was a little difficult to debug exactly why it was happening, but have a look at the file <span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">your-umbraco-site.com/umbacro_client/tinymce3/plugins/safari/editor_plugin_src.js - Line #116-117</span><br />
both these lines use the "mce_marker" text as a reference to where the html that needs inserting should be placed in the tinymce html. And this is the only place in the entire Umbraco source that there exists a text called "mce_marker".<br />
<br />
So how to fix it ?<br />
I firstly checked if the bug was any where to be found on the TinyMCE forums and issue trackers, and I <span style="font-family: inherit;">found this </span><a href="http://www.tinymce.com/forum/viewtopic.php?id=26708" style="font-family: inherit;" target="_blank">bug in tinymce</a><span style="font-family: inherit;"> that is a almost identical description of my clients bug. Basicly it states that the bug did exist and that actually the tinymce safari plugin had been removed more than a year before the last entry, so sometime around 2010-09-09 (</span>unfortunately<span style="font-family: inherit;"> I could not find the version number of tinymce where the plugin was removed). But...</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Hmmm, did Umbraco really not upgrade tinymce since 2010 (2 years ago), I looked into the tinymce implementation in umbraco and found that the file : </span><br />
<span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">your-umbraco-site.com/umbacro_client/tinymce3/tiny_mce_src.js - Line #6-10</span><br />
<span style="font-family: inherit;">contains the date 2011-03-10, so it seems the tinymce was updated after the Safari plugin was removed, but still the Safari plugin was included and loading in Umbraco, but properly it was no longer needed.</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">So I tacked down the code where the plugin is loaded in the file: </span><span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">\components\editorControls\tinyMCE3\TinyMCE.cs - Line #99-103</span><br />
The code looks like this:<br />
<br />
<span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">// safari compatibility</span><br />
<span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">if (HttpContext.Current.Request.Browser.Browser.ToLower().Contains("safari"))</span><br />
<span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">{</span><br />
<span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;"> _plugins += ",safari";</span><br />
<span style="color: blue; font-family: Times, Times New Roman, serif; font-size: x-small;">}</span><br />
<br />
<br />
<span style="font-family: inherit;">So to sum up there are two possible solutions to this bug, both are tested on a 4.7.1.1 install and seems to be working fine.</span><br />
<div style="text-align: left;">
</div>
<ol style="text-align: left;">
<li>Remove the contents of the files (dont delete them it will cause loading errors) and remember to do a backup of the files first.<br /><span style="color: blue; font-family: Times, 'Times New Roman', serif; font-size: x-small;">your-umbraco-site.com/umbacro_client/tinymce3/plugins/safari/editor_plugin.js</span><br /><span style="color: blue; font-family: Times, 'Times New Roman', serif; font-size: x-small;">your-umbraco-site.com/umbacro_client/tinymce3/plugins/safari/editor_plugin_src.js</span><br />This solution does not require any modifications to the umbraco source code and hence rebuilding of the core modules, and can be used as a "in-place" fix.</li>
<li>Uncomment line 99-103 in the file <span style="color: blue; font-family: Times, 'Times New Roman', serif; font-size: x-small;">\components\editorControls\tinyMCE3\TinyMCE.cs</span><span style="font-family: inherit;"> and rebuild the umbraco.editorControls.dll, this will ensure that the plugin is not loaded.<br />You can <a href="https://dl.dropbox.com/u/45604423/Umbraco/2012-11-29%20-%20Patch%20for%20TinyMCE%20Safari%20Plugin%20Loading.patch" target="_blank">download a patch file here</a> that can fix the changeset "</span>umbraco_250b9089253a"</li>
</ol>
Hope it helps you :-) and as always just ping me if you need help with this</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-41835902720757755942012-11-04T23:15:00.000+01:002012-11-04T23:15:57.511+01:00De-serialize to class with private or no empty constructor<div dir="ltr" style="text-align: left;" trbidi="on">
When transferring DTO objects around in .NET sometimes you need to deserialize data to an object with no or private/internal empty constructors. What I have normally done is adding a public empty constructor to my own classes that just does nothing, but I always deemed it as an ugly hack, and have marked them all with TODO comments in the code...<br />
<br />
Today I stumbled upon a this method in .NET <a href="http://formatterservices.getuninitializedobject/">FormatterServices.GetUninitializedObject</a> that actually can instantiate a class without using any of the constructors in the class. The best part is that it works in all .NET versions, because we are targeting our DTO objects for .NET Framework 2.0 to ensure compatibility with all our clients.<br />
<br />
I found these detailed guides about using the method:<br />
<a href="http://www.rvenables.com/2009/08/instantiating-classes-with-internal-constructors/">http://www.rvenables.com/2009/08/instantiating-classes-with-internal-constructors/</a><br />
<a href="http://mikeoff.blogspot.dk/2006/07/creating-object-instance-without.html">http://mikeoff.blogspot.dk/2006/07/creating-object-instance-without.html</a></div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-5477375448470109702012-07-09T15:06:00.000+02:002012-12-20T12:28:03.698+01:00Fix : Sorting thousands of nodes in Umbraco<div dir="ltr" style="text-align: left;" trbidi="on">
When drilling down into the Umbraco source code I found out that for each node in the sorting level, Umbraco uses .NET's XmlDocument.Clone() method for the entire contentxml cache file. This has a HUGH performance overhead and will cause the server to grind to a halt at some point, either when the number of nodes sorted or number of total nodes gets very high.<br />
<br />
We have both :-(<br />
300+ nodes needs sorting, and a total of 45000+ nodes in our umbraco install.<br />
<br />
So I created a patch and sumbitted it to Umbraco see more here: <strike style="background-color: white;"><a href="http://umbraco.codeplex.com/workitem/30895" style="background-color: white;">http://umbraco.codeplex.com/workitem/30895</a></strike><br />
<br />
<b><span style="color: red;">#### December 20 - 2012 Update ####</span></b><br />
Since umbraco has shutdown/removed the workitems from codeplex, without any redirects or references to the new site, I have uploaded the patch here: <a href="https://dl.dropbox.com/u/45604423/Umbraco/4.7.1.1/Patch%20-%202012-07-09%20-%20Patch%20for%20slow%20sorting%20with%20thousands%20of%20nodes%2C%20in%20or%20beneath%20the%20sorted%20level/2012-07-09%20-%20Patch%20for%20slow%20sorting%20with%20thousands%20of%20nodes%2C%20in%20or%20beneath%20the%20sorted%20level.patch" target="_blank">download patch</a><br />
<br />
<br />
<br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-75408233700308880642012-06-12T09:20:00.000+02:002012-06-12T09:20:20.150+02:00Start writing productive codeI read this awesome post today (<a href="http://jhovgaard.net/how-i-stopped-writing-awesome-code">http://jhovgaard.net/how-i-stopped-writing-awesome-code</a>) that really hits the nail on the head.<br />
<br />
I have several times over the last 10 years experienced developers (my self included) falling into the trap, where new technologies is like a drug for developers "if it's new it should be used !!". I actually heard several times from our development team, that they thought we where falling behind in their skill level, because we where not implementing and using the new technologies and methodologies.<br />
<br />
My best practice today is following the mantra "speed to market", by trying to deliver things as fast as possible and accepting bugs as a part of the development. Of course this can be frustrating at times, but whenever a bug is discovered our product is improved so it actually means that the number of bugs found equals a increased product value. And when a bug is found, that is system wide, we have built helpers to handle this. This means that we are not focusing on doing a lot of unit testing code for "what-if-scenarios", but instead evolving and improving our products instead of improving test-code.<br />
<br />
We do however stumble upon cases where it would have been nice to be able to extend a base functionality without having to re-write 10 classes, but in real life it's not that hard to add additional functionality later to 10 classes, it just requires ten extra Ctrl-V commands.<br />
<br />
And in my development history (15 years) whenever I tried to abstract functionality into a Interface structure, because I could foresee that down the line it could/would require changes. It actually always turned out that the changes required later was so extensive that a complete re-write would be faster and easier.<br />
<br />
<br />Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-9408882087621573402012-05-15T09:32:00.000+02:002012-05-15T09:32:02.533+02:00A good day for the european software industry<a href="http://arstechnica.com/tech-policy/2012/05/eus-top-court-apis-cant-be-copyrighted-would-monopolise-ideas/" target="_blank">Functional parts of software can not be copyrighted</a>..... a super good day for software developers in europe.<br />
<br />Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-42920246451029581172012-04-13T17:05:00.001+02:002012-12-26T12:48:04.693+01:00Umbraco Razor, DynamicMedia umbracoFile property empty<div dir="ltr" style="text-align: left;" trbidi="on">
Some times a request for a DynamicMedia item can return an item where the property "umbracoFile" is empty/null. <br />
<pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;">dynamic</span> mediaNode = <span style="color: blue;">new</span> <span style="color: #2b91af;">DynamicMedia</span>(mediaNodeId);</pre>
<pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 13px;"><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;"><span style="color: blue;">var</span> test2 = mediaNode.umbracoFile; // returning empty string
</pre>
<pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; font-family: Consolas;"></pre>
</pre>
When <a href="https://www.google.dk/webhp?sourceid=chrome-instant&ie=UTF-8&ion=1#hl=en&sclient=psy-ab&q=umbracoFile+empty+razor&oq=umbracoFile+empty+razor&fp=723e8dea25766228" target="_blank">searching</a> for the problem on google it seems to be a problem only in version 4.7.1+ in umbraco.<br />
<br />
As stated in theese two posts:<br />
<ol>
<li><a href="http://our.umbraco.org/forum/developers/api-questions/25859-DynamicNode-MediaById-umbracoFile-returning-empty-string" target="_blank">DynamicNode MediaById umbracoFile returning empty string</a></li>
<li><a href="http://our.umbraco.org/m?mode=topic&id=26271" target="_blank">Razor Media Error on Upgrade to 4.7.1</a></li>
</ol>
<br />
<div>
It seems to be something with the way the media items are loaded in the dynamic node's because loading the same media node from xslt using the "<span style="background-color: white; font-family: Consolas; font-size: 13px;">umbraco.</span><span style="color: #2b91af; font-family: Consolas; font-size: 13px;">library</span><span style="background-color: white; font-family: Consolas; font-size: 13px;">.GetMedia</span>" method does return the node with correct properties.</div>
<div>
<br /></div>
<div>
After some investigation into the issue I found out that it's actually 2 issues/bugs.</div>
<div>
<br /></div>
<div>
<b>1. issue</b></div>
<div>
This happens when using "<span style="color: blue; font-family: Consolas; font-size: 13px;"><</span><span style="color: #a31515; font-family: Consolas; font-size: 13px;">UseLegacyXmlSchema</span><span style="color: blue; font-family: Consolas; font-size: 13px;">></span><span style="background-color: white; font-family: Consolas; font-size: 13px;">true</span><span style="color: blue; font-family: Consolas; font-size: 13px;"></</span><span style="color: #a31515; font-family: Consolas; font-size: 13px;">UseLegacyXmlSchema</span><span style="color: blue; font-family: Consolas; font-size: 13px;">></span>" in the umbraco 4.7.1+ (I'm using it due to our large installation, wich still uses a lot of old xslt files).</div>
<div>
And the "umbraco.MacroEngines.ExamineBackedMedia.cs" file, it only expects the new content schema, and simply does not load any '<data alias="xx">' properties, but the code actually does load the node but not the child element values, when using the legacy schema in umbraco, it simple only accepts the schema style. </div>
<div>
<br /></div>
<div>
<b>2. issue</b> </div>
<div>
The first issue only happens if the node is simply not found/missing in the Examine Indexes, this could properly happen in many ways, but in my case it was happening when cloneing the live DB to localhost for development, but it also sometines happens on live servers. (Still to investigate)</div>
<h3>
<b>The solution(s)</b></h3>
<div>
To solve the first issue I modified the
"umbraco.MacroEngines.ExamineBackedMedia.cs" file so that if the item is not found in the examine index it will correctly load the node attributes and '
<data alias="xx"> ' nodes, see the <a href="http://umbraco.codeplex.com/workitem/30778" style="text-decoration: line-through;" target="_blank">workitem here</a><i> (codeplex items have been removed) </i>Instead the patch for Umbraco 4.7.1.1 is now available in my dropbox, <a href="http://bit.ly/W4Gqxr"><span id="goog_1709052193"></span>download it here<span id="goog_1709052194"></span></a>.</div>
<div>
But this still triggers a database request, if the node is not the runtime cache (30 minutes timeout), so I still wanted to solve the second issue also, so that the Examine Indexs would be correct, to optimize our umbraco installation.</div>
<div>
<br /></div>
<div>
To solve the second issue I installed the <a href="http://our.umbraco.org/projects/developer-tools/examine-dashboard" target="_blank">Examine Dashboard</a> package, and rebuilt the indexes manually, I had hoped that a <a href="http://our.umbraco.org/wiki/reference/api-cheatsheet/publishing-and-republishing" target="_blank">xml-republish</a> (http;//YOURDOMAIN/Umbraco/dialogs/republish.aspx?xml=true) would do the trick, but it apprently does not republish the media nodes and/or the Examine Indexes. I will properly investigate this later</div>
<div>
<br /></div>
</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com4tag:blogger.com,1999:blog-6340458673356486481.post-87512496554330528622012-03-13T14:24:00.002+01:002013-08-02T10:44:15.420+02:00Umbraco No Node Exists / cmscontentxml out of sync<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
For some time now we have had a problem when modifying document type alias' in umbraco (4.x.x), because it causes a complete flush of the XML caches used in umbraco. During these flushes of the caches if unexpected errors occurs, like DB connection lost, IIS timeout, AppPool flush or similar the cmscontentxml database table could become out-of-sync. This would lead to strange errors on the frontend of the sites in the installation:<br />
<ul>
<li>No node exists with id 'xxxx'</li>
<li>Missing menu items</li>
<li>Macros throwing out errors</li>
<li>etc.</li>
</ul>
<div>
The problem has become almost a show-stopper for our umbraco installation as the number of nodes has increased, we are currently having 6000+ nodes and hosting 200+ websites on a single umbraco install. </div>
<div>
<br /></div>
<div>
The errors are not showing up right after a change of the doctype alias, but after roughly 10-15 minutes, due to the thread updateing of the caches, and that umbraco will automaticly flush the cmscontentxml table to disk and memory caches if any of the two caches becomes invalid. Having "random" errors happening on 6000+ nodes is not acceptable.</div>
<div>
<br /></div>
<div>
So far we have "fixed" the issue by calling the <a href="http://myumbraco.com/Umbraco/dialogs/republish.aspx?xml=true">http://myumbraco.com/Umbraco/dialogs/republish.aspx?xml=true</a> which will force a full republish of all pages/nodes to the cmscontentxml table, and after that flush the disk and memory cache. The normal "right-click > republish" on the root node is only flushing the cmscontentxml table to disk and memory, but is not updating the database table, which is out-of-sync.</div>
<div>
<br /></div>
<div>
We have found several posts about the issue, but so far no good solution:<br />
<ul>
<li><a href="http://our.umbraco.org/forum/ourumb-dev-forum/bugs/16662-cmsContentXml-out-of-synch" target="_blank">our.umbraco.org/../cmsContentXml-out-of-synch</a> </li>
<li><a href="http://our.umbraco.org/forum/developers/api-questions/28777-Weird-content-cache-regeneration-issue">our.umbraco.org/.../Weird-content-cache-regeneration-issue</a> </li>
<li><a href="http://forum.umbraco.org/yaf_postst9623_No-node-exists-with-id-1040.aspx" target="_blank">forum.umbraco.org/.../No-node-exists-with-id-...</a></li>
<li><a href="http://our.umbraco.org/forum/core/general/25944-Reasons-for-the-cmsContentXml-table-to-get-wiped" target="_blank">our.umbraco.org/.../Reasons-for-the-cmsContentXml-table-to-get-wiped</a></li>
</ul>
<div>
So we decided to come up with a proposal for a solution, that would ensure that regardless of any connectivity issues, or AppPool recycles, the cmscontentxml table would not get out of sync (this was the main reason for errors). Also modifying a DocumentType alias should NOT be a 10-15+ minutes wait-while-saving operation on large node umbraco installs.</div>
<div>
<br /></div>
<div>
Our solution modifies the DocumentType save event/method, by adding each node id that is using the DocumentType into the cmstask database table bycreating a new umbraco Task. These tasks are then loaded (one-by-one) using the umbraco.presentation.publishingService, and a flush of the database, disk and memory cache for each node is done, and only after it is completed for each node the Task is deleted.</div>
<div>
This should ensure that even a AppPool flush will just cause the publishingService to publish the node one more time.</div>
<div>
<br /></div>
<div>
A umbraco work item allready exists for this, see:</div>
<ul>
<li><a href="http://umbraco.codeplex.com/workitem/30610"><strike>http://umbraco.codeplex.com/workitem/30610</strike></a><br />(Moved to: <a href="http://issues.umbraco.org/issue/U4-493">http://issues.umbraco.org/issue/U4-493</a>)</li>
</ul>
<div>
Also our patch is uploaded to it. (<a href="http://umbraco.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=umbraco&WorkItemId=30610&FileAttachmentId=353444" target="_blank">download patch</a>)<br />
<br />
<b><span style="color: red;">#######</span></b><b><span style="color: red;"> December 20 - 2012 Update. #######</span></b><br />
Due to the high number of requests, both here and from other sources, about this bug in Umbraco, I have created some additional release builds of the Umbraco Source with this patch applied, just click on the version you need the patched files for to download it. (both patch, dll's and source is available)<br />
<a href="http://bitly.com/bundles/o_742jg6tlpm/2" target="_blank">Umbraco Version 4.7.2</a><br />
<a href="http://bitly.com/bundles/o_742jg6tlpm/3" target="_blank">Umbraco Version 4.9.1</a><br />
<a href="http://bitly.com/bundles/o_742jg6tlpm/4" target="_blank">Umbraco Version 4.10.1</a><br />
<a href="http://bitly.com/bundles/o_742jg6tlpm/5" target="_blank">Umbraco Version 4.11.1</a><br />
<br />
<b><span style="color: red;">#######</span></b><b><span style="color: red;"> July 20 - 2013 Update. #######</span></b><br />
Friday I received a distress request to help a company with a site that was down, and I spent my vacation-day-off helping them patching the Umbraco 4.11.10 version with this fix. I reviewed the code done by Shannon at Umbraco HQ, and although his code was a HUGH improvement, it was not a fix for this issue.<br />
So here is the patch bundle for Umbraco, the dll's are built in release mode, but with pdb files.<br />
<a href="http://bitly.com/bundles/o_742jg6tlpm/6" target="_blank">Umbraco Version 4.11.10</a><br />
<br />
<b><span style="color: red;">#######</span></b><b><span style="color: red;"> August 2 - 2013 Update. #######</span></b><br />
Be very careful about the latest 4.11.10 version of Umbraco and republish xml, there is a bug which will cause the sortOrder property on the nodes to be set to "0" in the output/cache XML. I'm currently testing a new patch and will release it after some testing.<br />
see: <a href="http://issues.umbraco.org/issue/U4-2527#comment=67-8808">http://issues.umbraco.org/issue/U4-2527#comment=67-8808</a><br />
A quick google search on "<a href="https://www.google.dk/search?q=umbraco+sort+order+0" target="_blank">umbraco sort order 0</a>" reveals that it is a old bug, and is affecting many areas of Umbraco, <a href="http://our.umbraco.org/forum/developers/api-questions/33996-Media-sortOrder-property-returns-0" target="_blank">media</a>, <a href="http://our.umbraco.org/forum/developers/api-questions/25492-Sort-order-is-always-0" target="_blank">content</a>, basicly all objects that inherit from CMSNode<br /></div>
</div>
</div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com22tag:blogger.com,1999:blog-6340458673356486481.post-51079566341764980632012-01-05T22:41:00.002+01:002012-12-20T19:40:29.057+01:00Enabling correct URL's for umbraco when using hostnames on level 3+<div dir="ltr" style="text-align: left;" trbidi="on">
I have in my company been running a single Umbraco installation with multiple websites for about 2½ year, each site has it's own domain, but share similar macros, and many times also functionality. But lately we have been running into issues with customers who would like to have multilingual sites under separate domain names.<br />
<br />
Simple, right... just create a "folder" node, but each site inside and that should be it....!! But ups there is an old bug (missing feature) in Umbraco that will render out wrong URL's on both the backend and the frontend when using the Node.NiceUrl or umbraco.library.NiceUrl(NodeID) methods. The bug is that the Umbraco NiceUrl method only will filter out the nodes on level one (internally in the code called level 2, because actually the root is level 1).<br />
<br />
Example, if your node structure looks like this:<br />
root<br />
+Node1 (hostname: exampleA.com)<br />
++Node1.1<br />
+Node2<br />
++Node2.2 (hostname: exampleB.com)<br />
+++Node2.3<br />
<br />
Umbraco will construct the NiceUrl of:<br />
Node1.1 as "<b><span style="font-family: 'Courier New', Courier, monospace;">/Node1.1.aspx</span></b>" (correct url)<br />
Node2.2 as "<b><span style="font-family: 'Courier New', Courier, monospace;">/</span></b>" (correct url)<br />
Node2.3 as "<b><span style="font-family: 'Courier New', Courier, monospace;">/Node2.2/Node2.3.aspx</span></b>" (wrong url) should be "<b><span style="font-family: 'Courier New', Courier, monospace;">/Node2.3.aspx</span></b>"<br />
<br />
So to fix this/add this feature I have modified the Umbraco version 4.7.1.1 of the umbraco.presentation.library.cs<br />
The patch is uploaded here: <a href="http://umbraco.codeplex.com/Download/AttachmentDownload.ashx?ProjectName=umbraco&WorkItemId=30662&FileAttachmentId=323577" style="text-decoration: line-through;" target="_blank">umbraco.codeplex.com/Download/...323577</a> (moved to: <a href="http://issues.umbraco.org/issue/U4-515" target="_blank">issues.umbraco.org/../U4-515</a>)<br />
The Umbraco Work Item is here: <a href="http://umbraco.codeplex.com/workitem/30662" style="text-decoration: line-through;">http://umbraco.codeplex.com/workitem/30662</a> (moved to: <a href="http://issues.umbraco.org/issue/U4-515" target="_blank">issues.umbraco.org/../U4-515</a>)<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-67313329726154136712011-12-31T17:28:00.000+01:002011-12-31T17:40:16.286+01:00Umbraco 4.7.1.1 macro parameter bug<i>Using the same xslt macro twice on pages causes invalid attribute values.</i><br />
<br />
The bug in Umbraco 4.7.1.1 causes the parameters of following requests to load invalid or wrong parameters. The bug was discovered in the process of upgrading from version 4.5.2, and it took some time to find due to the change in loading macros in Umbraco.<br />
<br />
<b>How to re-produce the bug:</b><br />
Load two or more macros on the same page, adding some attributes to the macro in Umbraco. If the first macro does not use all the properties (default empty values) the second macro usage will cache and set the attributes on the following requests.<br />
<br />
This will cause rendering of invalid content....!!!<br />
<br />
In my case it was a menu macro with an attribute defining which node to use as start node for rendering, if not set the xslt macro would use the site's rootNode/defaultNode as the start node. But this bug caused the macro to load a wrong content tree as the menu :-(<br />
<br />
The fix is to change/update the UpdateMacroModel method code to the folowing, in the <i>umbraco.presentation.macro.cs</i> file:<br />
<pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial;"><pre style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 13px;"><span style="color: blue;">public</span> <span style="color: blue;">void</span> UpdateMacroModel(<span style="color: #2b91af;">Hashtable</span> attributes)
{
<span style="color: blue;">foreach</span> (<span style="color: #2b91af;">MacroPropertyModel</span> mp <span style="color: blue;">in</span> Model.Properties)
{
<span style="color: blue;">if</span> (attributes.ContainsKey(mp.Key.ToLower()))
{
mp.Value = attributes[mp.Key.ToLower()].ToString();
}
<span style="color: blue;">else</span>
{
mp.Value = <span style="color: blue;">string</span>.Empty;
}
}
}</pre>
</pre>
I have submitted a post here: <a href="http://our.umbraco.org/forum/developers/xslt/21851-All-XSLT-files-suddenly-giving-error-parsing-XSLT-file?p=2#comment101528">http://our.umbraco.org/forum/developers/xslt/21851-All-XSLT-files-suddenly-giving-error-parsing-XSLT-file?p=2#comment101528</a><br /><br />And added a diff file to umbraco's codeplex site: <a href="http://umbraco.codeplex.com/workitem/30657">http://umbraco.codeplex.com/workitem/30657</a>Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com1tag:blogger.com,1999:blog-6340458673356486481.post-59560790082196582972011-10-07T12:14:00.001+02:002012-08-13T15:14:06.174+02:00Fix: Bug in .NET Roles / RoleProvider / MembershipProvider initialize<div dir="ltr" style="text-align: left;" trbidi="on">
Due to a bug in the System.Web.Security.Roles class in .NET 2.0, which is caused by a singleton instance of the last exception that occurred during the Initialize of the RoleProvider, any exception's that occur during Initialize method of the RoleProvider, will be caught and the only way is to recycle the app pool in IIS.<br />
<br />
I stumbled upon this bug due to a connectivity issue with our database, that caused a small connection lost to the database, the resulting error on the front end of our website was a database error (which was stored in the static exception inside the Roles class).<br />
<br />
It took a little time to track this down and fix it, but the fix is to do a try catch block inside the Initialize method, preferable only around initialize DB code, and your own static object to monitor if the initialize went perfect, then in all the overridden methods do a check if the initialization went fine, and else initialize the DB again.<br />
<br />
<b>Update - 2012-08-13:</b><br />
I sadly stumbled upon the bug in the MembershipProvider also, so to every who stumbled upon the same problem here is a example draft code that can fix the error.<br />
<br />
<pre class="brush:csharp">public sealed class MyCustomMembershipProvider : MembershipProvider
{
private static object _syncLock = new object();
private static bool _isDBInitializedSuccessfully = false;
public override void Initialize(string name, NameValueCollection config)
{
if (config == null)
{
throw new ArgumentNullException("config");
}
// .... Add your code to validate the config settings, if needed
// Initialize the abstract base class.
base.Initialize(name, config);
// .... Add your code to initialize the class, if needed
// Initialize the DB
InitializeDB();
}
public override bool ChangePassword(string email, string oldPassword, string newPassword)
{
// Call InitializeDB() in all methods that require DB access in the class
InitializeDB();
// .... Add your code that will change the password
}
private static void InitializeDB()
{
if (_isDBInitializedSuccessfully) { return; }
lock (_syncLock)
{
if (_isDBInitializedSuccessfully) { return; }
try
{
// .... Add your code to check if the DB is loaded
_isDBInitializedSuccessfully = true;
}
catch (Exception e)
{
// .... Add your code to log the Exception's
e = null;
}
}
}
}
</pre>
<br />
And the code that generates the error:
<br />
<pre class="brush:csharp">
namespace System.Web.Security
{
//...
public static class Membership
{
//...
private static void Initialize()
{
if (s_Initialized)
{
if (s_InitializeException != null) // static Exception, so only a app-pool reset will fix it
throw s_InitializeException;
return;
}
if (s_InitializeException != null) throw s_InitializeException;
//...
}
//...
private static Exception s_InitializeException = null;
//...
}
}
</pre>
<br />
Hope this helps you :-)<br />
<br /></div>Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0tag:blogger.com,1999:blog-6340458673356486481.post-18997947259942658132011-10-05T15:48:00.000+02:002011-10-07T12:15:22.398+02:00Fix: Visual Studio 2010 SP1 cannot open fileToday I ran into a really strange bug with my new PC (DELL Vostro, windows 7 Ultimate 64 bit, intel-i5) and a fresh install of Visual Studio 2010, it cost me 10½ hours of searching and testing different solutions from many sources:<br />
<a href="http://www.ninjacoding.net/archive/2010/01/17/visual-studio-hangs-when-opening-certain-files.aspx">http://www.ninjacoding.net/archive/2010/01/17/visual-studio-hangs-when-opening-certain-files.aspx</a><br />
<a href="http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/f76ebf64-4cd3-4cac-a970-40a23e7171d3/">http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/f76ebf64-4cd3-4cac-a970-40a23e7171d3/</a><br />
Some of them might help others, <b>but they did not help me !!!</b><br />
<br />
I had originally thought that it was connected only to .sql files, but quickly found out that actually all files was affected, and Visual Studio would enter a freeze/un-responsive state and sometimes throwing a random exception.<br />
<br />
<b>The solution</b> that helped me was found by pure chance when checking the reset settings of visual studio, I stumbled upon a setting in: Tools>Options>Environment>General>"<i>Use hardware graphics acceleration when available</i>" this was checked/enabled.... and I noticed that actually when I created or opened a file i VS it was there but just not showing, unless I re-sized the application, and when typing this was also not shown until the window was re-painted. so <b>un-checking</b> this setting, and all problems where gone.<br />
<br />
Hope that this can save others from spending time on a stupid bug.Anonymoushttp://www.blogger.com/profile/00056681875783006664noreply@blogger.com0