Showing posts with label solution. Show all posts
Showing posts with label solution. Show all posts

Oct 19, 2013

Unicode characters in Python console

Recently I've have had a look at a Python language. A played a bit with it, but found that I feel uncomfortable with it without a proper introduction. I've decided to go with Learn Python the Hard Way, even though it's biasied towards unexpirienced programmers, but the book name intrigued me and I've actually heard that book name for some time with positive recommendations. So, somethere around Lesson 1, there you print to a console, I've decided to try out printing in non-English language, Russian in particular, just to see how it goes. It didn't worked. So I headed to Stack Overflow. But even there I've spend a lot (relatively) of time to find solution that actually worked for me.

During this search I also found Python Unicode handling is confusing to say the least. I guess it's a matter of some time of studying the subject, but that is really annoying since string is the thing that you usually work a lot with. Because of that I find that Python feels like a JavaScript mixed with a C.

P.S. I also think Python Tools for Visual Studio is probably the best IDE to learn (and work) with Python on Windows, especially if you are a long time Visual Studio user, you will feel right at home.

Sep 26, 2013

How to POST (upload) a file in a Visual Studio web test

So, I've came up with a task of performing a basic load test of a web service. For that purpose I've chosen the WebTest of Visual Studio 2010 Ultimate Test Project. For the most part as long as only GET requests were performed everything was pretty straightforward.

But there was one POST request that requred a file upload. A little googling led to this blog entry which describes the situation in detail. The only problem was that recording of the file upload didn't work. It didn't record anything at all, to be more correct. I guess that's because I'm in the end of 2013 and using Windows 8 and IE 10, and this breaks it somehow (you know, Windows 8 breaks a lot of things).

So basically situation is pretty dumb: you can't add "Form Post Parameters" to your POST request with a right click menu. Why (it's a rhetorical for Microsoft, I know)? And the only semi-official solution doesn't work, and it's pretty dumb solution, I might add.

The solution is quite simple however. A .webtest file is a XML, which utilises a http://microsoft.com/schemas/VisualStudio/TeamTest/2010 schema, which is located at %VsInstallDir%\Xml\Schemas\vstst.xsd. Using that schema it wasn't hard to find required tags. To create "Form Post Parameters" create a new POST request ("Add Web-Service Request"), save, and reopen .webtest as XML file. In the tag <Request> insert child elements:

<FormPostHttpBody>
<FormPostParameter Name="dummy" Value="test1" RecordedValue="" CorrelationBinding="" UrlEncode="True" />
</FormPostHttpBody>


save and close. Now you can reopen webtest with it's standard editor, and voila, you have the parameters, you can now right click on it and two new options apper in menu, inluding "Add File Upload Parameter" which is that we need. Everything else is already described in blog entry mentioned above.

Sep 11, 2013

Visual Studio 'Run' button is disabled, or problems with build

Sometime very strange things happens with Visual Studio. The one have happened to me maybe three times for all time, and each time I already forgot that I need to do to fix it! So basically your simptoms can be any of the like:

1) Your Run (F5) button is disabled;
2) Your program is not recompiled and hitting Run causes running old version of the 'exe' that lies in the Debug folder;
3) Then hitting F5 you receive error messages like "Visual Studio cannot start debugging because the debug target 'C:\your\path\bin\Debug\Project.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly.'

That usually that happens absolutely sporadically with you doing nothnig with the project or solution preferences, which confuses a lot. Now, in 99% of the cases the solution is to go to the Build->Configuration Manager... and check that Build checkbox is checked for required projects, see picture:



What makes them suddenly unchecked is still a mistery to me.

Microsoft CRM 2011, import CSV file with entity references (lookups)

While most of the time you probably could use a LookupMaps to set up an entity references in you import maps, you may come to situation there you want put actual ID's (references) in your CSV file. So, the tricky part here is the format. To create EntityReference you need entity type name and it's GUID. How would you put that into CSV string? The answer is like this:

"entity_type_name,{SOMEGUID-3FBA-47E5-ADD0-F6078ACDABB8}"

Note that surrounding quotes are required, because of the comma.

Aug 7, 2013

Microsoft CRM 2011, hide system Save menu

Recently we were asked if it is possible to disable a standard 'Save' menu of Microsoft CRM 2011, since all data on forms is read-only anyway. So, after some searching I've found sample code how to do this. The key was to use "top" property which is containing parent frame which is necessary, since our code (called in "OnLoad" form event) is executing in inner frame. With some modifications this is what finally worked out for me:

var disableSaveMenu = function() {
    // your entities names
    var entities = ["account", "contact" /* add as necessary */];

    var i;
    for(i = 0; i < entities.length; i++) {
        var ent = entities[i];
        var save = top.document.getElementById(ent + "|NoRelationship|Form|Mscrm.Form." + ent + ".MainTab.Save");
        if(save != null) {
            save.style.display = 'none';
            break;
        }
    }
    
    // hide 'File' menu, additional 'Save' is also located there
    var jewel = top.document.getElementById("jewelcontainer");
    if(jewel != null) {
        jewel.style.display = 'none';
    }
};

Aug 6, 2013

Microsoft CRM 2011, automatically load all subgrids

Microsoft CRM 2011 doesn't load by default data in all of the subgrids if they count exceed 4, displaying 'To load ... records, click here' message. It's actually extremely annoying.

It's not possible to change this behaviour with standard tools (i.e. via control preferences). So I've found how to do it using JavaScript function call on form OnLoad event. Unfortunatelly it did't worked in my case. For some reason the moment then OnLoad event was fired, the from subgrids were, apparently, not initialized on the form. I've decided then to call the function with a little delay:

var autoLoadSubgrids = function() {
    var maxAuto = 4;
    var loadDelay = 1000;

    var subgrids = Xrm.Page.ui.controls.get(function (control, index) {
        return control.getControlType() == "subgrid";
    });
    
    if (subgrids.length > maxAuto) {
        var subCall = function() {
            var i;
            for (i = maxAuto; i < subgrids.length; i++) {
                var grid = subgrids[i];
                if(grid != null) {
                    grid.refresh();
                }
            }
        };

        window.setTimeout(subCall, loadDelay);
    }
};

And it worked! Not the solution I would like, but I guess that's all I can do now and it also would'n do any harm if something goes wrong.

Mar 5, 2013

Format a drive larger than 32Gb into FAT32 on modern Windows OS

IIRC Windows was restricting usage of FAT32 since Windows 2000, in favor of NTFS. And it is actually a good thing. NTFS is far superior than FAT32 in almost any aspect.

However, this activity come beyond reasonable amounts in my opinion. Simply put, you just can't format a drive larger than 32Gb into FAT32 using any modern Windows OS (Windows Vista/7/8, maybe even Windows XP). This is very, very annoying. I'm fine then you can't do something using standard approach, but I want be able to do that I want somehow, even if this is sounds unreasonable.

Now, users must fix that Microsoft must do itself. This utility (click on image to download) by fine fellas from Ridgecrop Consultants Ltd. do the thing. Since it's very valuable tool and "teh internets" fail us sometimes, here's a copy in the SkyDrive cloud.

Feb 28, 2013

Running Apache on Windows 8: port 80 occupied by System

If you are using Windows 8 or Windows Server 2012, and Apache service won't run (you have something like make_sock: could not bind to address 0.0.0.0:80 immediately after installation) what means that something occupies port 80, which is Apache is trying to use. You can use Tcpview tool to see what occupies port 80. Then I did that I saw that is was a process called "System". While "System" can actually refer to many system services, it seems that there are two common cases present:

1) Web Development Agent Service (MsDepSvc);
2) World Wide Web Publishing Service (W3SVC).

If disabling any of these servies does not help you can use some other tools to dig deeper in your quest of finding service responsible for port 80.

P.S. There is of course other solutions to that, most simple of which is changing port to which Apache will be listening.

Dec 24, 2012

jQuery "No Transport" error solution

If you get a "No Transport" error then making AJAX request using jQuery in Internet Explorer, then solution is as simple as adding:
$.support.cors = true;
before making your calls to
$.ajax(...)
For some other possible options take a look here.

Aug 25, 2012

Fixing XBLIG (and Windows Phone) forum links

As usual, working with an elephant finesse, Microsoft, for some obvious reasons decided to split Windows Phone and XBLIG forums. This results in incredible amount of links on the web are being broken. Oh, this is so nice.. The good part however is that, you can replace old forums.create.msdn.com/forums with xboxforums.create.msdn.com/forums in address and make it to the desired topic.

As for unfortunate ones who were looking for some topics for Windows Phone, the things here are much simplier: all topics are lost somethere, or just gone, I don't actually know.

Back to XBLIG. If you are using Firefox, you can use Redirector add-on, as described here. Just in case, I'll duplicate the rules here. Goto add-on options and add two rules:

Rule 1
Example URL: http://forums.create.msdn.com/forums/p/0001/0001.aspx
Include Pattern: http://forums.create.msdn.com/forums/*/*/*
Redirect to: http://xboxforums.create.msdn.com/forums/$1/$2/$3
Pattern Type: Wildcard

Rule 2
Example URL: http://forums.create.msdn.com/forums/t/0001.aspx
Include Pattern: http://forums.create.msdn.com/forums/*/*
Redirect to: http://xboxforums.create.msdn.com/forums/$1/$2
Pattern Type: Wildcard

May 14, 2012

XDE "mfplat.dll is missing" solution

So if you have that problem then your Windows Phone Emulator won't start, and if you try to run it directly you have "mfplat.dll is missing" message, then there is solution that helped me.

Search your %windir%\winsxs directory for "mfplat.dll". It most certanly will find it in something like this, as on my Windows 2008 Standard R2 x64:

c:\Windows\winsxs\amd64_microsoft-windows-mfplat_31bf3856ad364e35_6.1.7600.16385_none_529f8a546d2657c9\mfplat.dll
c:\Windows\winsxs\x86_microsoft-windows-mfplat_31bf3856ad364e35_6.1.7600.16385_none_f680eed0b4c8e693\mfplat.dll

then take 32-bit version of it, and copy it into "%windir%\SysWOW64" ("%windir%\System32" for 32-bit OS).

The other way is probably to install "Desktop experience" feature (on Windows Server OS).

Apr 12, 2012

Installing Windows Phone SDK on Windows Server 2008 R2

If you try to install a Windows Phone 7.1 SDK on Windows Server, 2008 R2 x64 in my particular example, I will be surprised that it's officially supported in Windows Vista and Windows 7, as for now.

There is an existing solution for web installer. But what if you internet connection is slow, you need to install SDK on 10 computers, and you have a nice ISO lying on your file server HDD? Actually you only need a good hex editor. HxD is a good one, and absolutely free. What we need, is to modify same lines, but directly in iso file. Open image in editor and search for a unicode string [gencomp7788]. After you found it's location, look down for the same unicode InstallOnLHS=1 and InstallOnWin7Server=1 strings (you can copy baseline.dat from image beforehand and open in notepad for reference, it's located in root directory of the image). Select value 31 after '=' which is '1' and replace it (Edit -> Fill selection...) with 30 which is '0', you will see changes immediately in editor. Now, save the image. You're done. Open the image and verify that changes in baseline.dat are the same as you expected, and you are ready to go!

P. S. I suppose (didn't actually tried that) you can copy files from image into some directory and modify baseline.dat there, but it's not that fun!

Mar 30, 2012

Errors on GAC operations

If on any GAC operation you receive gacutil.exe errors similar to this:

Failure adding assembly to the cache: Access denied. You might not have administrative credentials to perform this task. Contact your system administrator for assistance.

but, on contrary to the message, you have administrator rights then problem is, almost certanly in enabled UAC. Either use "Run as Administrator" or just disable damn UAC.

Mar 27, 2012

A way to fix freezing WMI

Problem symptoms (as on my Windows Server 2008 R2 Standard x64), after reboot you have following problems:
  1. WMI functions are unacessible. For example, if you try to start "SQL Server Configuration Manager" (which uses WMI internally) it will fail to lauch with error. Other programs just won't start or freeze indefinetely;
  2. svchost.exe process which hosts "Windows Management Instrumentation" service (Winmgmt) will use 100% of single CPU core time;
  3. HDD led will glow constantly;
  4. If you wait for some time (some hours) all previous symptoms disapper and everything functions normally until next reboot.
My solution was to:
  1. Load into "Safe mode";
  2. Kill svchost.exe in question via Task Manager, and then quickly;
  3. Delete "%systemroot%\System32\wbem\Repository" folder;
  4. Reboot.
Again you need to perform steps 2 and 3 quickly, since Windows will restart "Winmgmt" service shortly after it was killed, and running "Winmgmt" blocks deletion of this folder.

After this procedure Windows will recreate this folder and symptoms described above will stop. I think this folder is some kind of cache, which becomes either corrupted (more likely) or very large and WMI service enters some kind of almost infinite loop on booting then processing this folder data. As an interesting fact "Repository" folder which I deleted on my system was 559Mb, while recreted folder is 22Mb which is 25 times difference.

Jan 18, 2012

Configuring BizTalk 2006 R2 on cluster

Then you try to configure BizTalk 2006 R2 in cluster environment, you can get error similar to:

The SQL Server 'SERVERNAME' cannot be used with the SSO Administrator account 'SSO Administrators'. Local accounts cannot be used with clustered SQL Servers. (SSO)

To fix this (which worked for me) add you domain to user groups like "DOMAIN\SSO Administrators" and "DOMAIN\SSO Affiliate Administrators". Of course you also must use domain user which belongs to both this groups. And here comes nasty trick, you need to deselect and select again "Enable Enterprise Single Sign-On on this computer" checkbox, only then error goes away.

Oct 21, 2011

PowerShell: script permissions

If you try to run a PowerShell script you can get something like Script.ps1 cannot be loaded because the execution of scripts is disabled on this system. Yet after running:

Set-ExecutionPolicy Unrestricted

you still get the same message! Then I bet you are running x64 system. That's because there is two versions of PowerShell on the x64 systems, both x64 and x86. And both must be set to desired execution policy to achive desired effect.

SharePoint: Service unavailable

If you receive "Service unavailable" then you try to open SharePoint 2007 Central Administration then it means your application pool for it (usually "SharePoint Central Administration v3") is stopped. But if you start it and it stops again, as you try to open administration page, then it means that you farm credentials are corrupted. This worked for me as a fix:

stsadm -o updatefarmcredentials -userlogin DOMAIN\login -password password

then run:

iisreset /noforce

and have a nice day.

Oct 4, 2011

How to force full backup for BizTalk backup job

Sometimes you need to force a full backup of BizTalk backup job. For example, then you reconfigure BizTalk, you can receive an error on some of the BizTalk jobs saying something about that backup is not possible without full backup. To trigger full backup on next job run you need to execute BizTalkMgmtDb.dbo.sp_ForceFullBackup stored procedure. More details can be found here.

Sep 27, 2011

Yet another BizTalk error

Your BizTalk installation worked like a charm, but suddenly you receive errors like this?

There was a failure executing the receive pipeline: "PipelineName, PipelineAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=..." Source: "Init Message Processing Properties" Receive Port: "..." URI: "..." Reason: Loading property information list by namespace failed or property not found in the list. Verify that the schema is deployed properly.
In my case, and, as it seems, some others, this was caused by corrupted installation of third party adapters for BizTalk. Reinstallation of adapters solved the problem.

Aug 16, 2011

If C/C++ IntelliSense is not working in Visual Studio 2010

If C/C++ IntelliSense is not working in Visual Studio 2010, not even creating it's 'ipch' folder, and you are happen to still use almost obsolete Windows XP, then you will be surprised as much as me, since it's, in fact, a Microsoft bug, which was introduced by recent bunch of updates to WindowsXP SP3.

I found it almost by chance, since there is a lot of other reasons for broken IntelliSense. I was lucky not going thru all of solutions and ultimately become extremely frustrated since none of them would work.