Friday, January 12, 2024

Build environment to run Flutter apps on iOS

This is another personal memo. There have been quite a few glitches to overcome, to run Flutter apps on my newly bought M2 mac. I want to write about them, before closing the tabs of the pages explaining the solutions.

CocoaPods

What is CocoaPods?

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. (https://cocoapods.org/)

When you try to run your Flutter app for the first time on an iOS device (one of the simulators, most probably), the system complains that CocoaPods is missing.

OK. No problem. Let me install, following the instruction found on the above project site. Then, the first glitch. The instruction won't work. There seem compatibility issues for Cocoapods and silicon chip based M1 and M2 based macs, which prevents it from directly installing Cocoapods on these machines.

The solution is found at this page. You basically first install a tool called Homebrew, and then let it install CocoaPods for you.

Unable to boot the Simulator

It has suddenly become that I am not able to boot any iOS simulator.

You may be lucky that this does not happen on your system. But it did to me (I suspect that this is due a Xcode update, but not sure), and it took sometime to remove the problem. So it should be worth to write here what I did for future reference.

So this is what you want to do, you go to "About this Mac" > "More info..." >Developer (info icon) > Select anything that has "xcode" and "cache" in it > Click "Delete". Close all this and relaunch simulator.

error:iOS 17.2 is not installed. To use with Xcode, first download and install the platform

Now that the iPhone 15 on iOS 17.0 is running. I tried to deploy the app onto it and got this error.

I first did not understand why I need to install the iOS 17.2 SDK. I have ones for 17.0 and 17.0.1. The simulator is on 17.0. Why is 17.2 required??

Now I understand as follows. At the time of this writing, I am on Xcode 15.2 on macOS Ventura 13.6.1. https://developer.apple.com/support/xcode/ reads as below, that Xcode 15.2 requires the iOS SDK 17.2.



I installed the SDK as instructed by the error message. And finally, I can now run my app on the simulator.

Thursday, November 16, 2023

_NativeStripFiles fails when building release build to upload Apple Store

I do not know if this is relatively known. This xcode-select --switch command.

Anyway, this is what happened to me. As it took sometime for me to figure this out. It is probably worth taking note.

First of all, I had multiple instances of Xcode installed on my Mac.

To be more precise, I have got a new Mac recently, a few months back. By then, the latest Xcode was 15. Naturally, I installed it.

Then I found that Visual Studio (I develop a Xamarin app) of that moment does not work hand-in-hand with Xcode15. I installed Xcode 14.3, keeping 15. They are sitting in different folders. In Visual Studio, I specify 14.3 as Apple SDK.

All went well. I built and published my app with the 16.4 SDK which comes with Xcode 14.3.

Sometime after that, I felt the need of using 17 SDK (I wrongly believed that this is required to support iOS17 devices). I found that with the Visual Studio update out in Oct 2023, I can use Xcode15 SDK (which is 17.0). The new build runs OK on an iOS17 simulator. So far so good.

To release to App Store, we need to build the app against an actual device, as you know. Then I have got this error:

xcrun: error: sh -c '/Applications/Xcode_14.3.1.app/Contents/Developer/usr/bin/xcodebuild ...

What?! Why this still tries a command of Xcode14.3, even after I have switched the Apple SDK to use to Xcode15!

I looked everywhere, Googled for a hint. No chance.

Helpless, I told myself how happens if I removed the Xcode14.3 installation folder.

Bingo! Now the error has changed and saying:

xcode-select: note: No developer tools were found, requesting install.

If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools

With this message, I have come to know that I need to run the command to tell the system the Xocde I want to use.


Friday, September 30, 2022

WebAuthenticationSession "The UIWindowScene for the returned window was not in the foreground active state."

In my case, I got this error (from a certain point of time if remember well), when implementing an OAuth protected API access upon a screen opens.

My platform is Xamarin.Forms.

Originally, I was doing so in the OnAppearing event handler. Opening WebAuthenticator browser etc. that sort of things. But at one point, on iOS, it stopped working, giving the following exception:

Error Domain=org.openid.appauth.general Code=-3 "(null)" UserInfo={NSUnderlyingError=0x60000299a7f0 {Error Domain=com.apple.AuthenticationServices.WebAuthenticationSession Code=3 "The UIWindowScene for the returned window was not in the foreground active state." UserInfo={NSDebugDescription=The UIWindowScene for the returned window was not in the foreground active state.}}}

It appears that the WebAuthentication browser can only be shown and return thereafter, to a foreground active window.

OK. Let us move it to another event handler which is called when the windows appeared, rather than appearing.

There seems, however, no such an event available in Xamarin.Forms, in the PCL project.

On the other hand, the iOS native UIViewController has the event ViewDidAppear, and we can code the handler through the PageRenderer.

I am still a newbie in Xamarin development, was not sure if such is possible. But wow! It works like a magic! I moved the API calling code from the page code behind class OnAppearing method to the PageRenderer. Only for iOS. For Android, it remains in the code behind class.

So the "life cycle" is, on iOS, the ViewDidAppear method is called first since there is a custom renderer is implemented, while on Android, simply only the OnAppearing method is called.

Friday, July 1, 2022

Build pipeline for a Desktop Bridged Xamarin project

By the way, I am writing this with Open Live Writer, which finally back again supports Blogger. Not officially though…

Let us start the story of the title.

An explanation for the cryptic title first.

What is Desktop Bridge? As explained here, its goal is to create a bridge between the new development approach introduced in Windows 10 (the Universal Windows Platform) and the traditional desktop application. 

In my case however, I came across this idea when I was seeking if feasible to use the systray from my Xamarin/UWP application. I want to make my app like MS Teams, which runs when you starts your PC, stays up in the systray, showing the status (your availability as it is seen by others). I found this blog post. Its sample code is found as a part of the Microsoft GitHub repo for Desktop Bridge samples. It explains how to enable a UWP package to have executables that run as full trust instead of in an app container. 

How to have an UWP app start at sign-in is found here.

I brought these ideas into my Xamarin project, have had it acts like Teams as described above. Very happy.

The next step is to establish its build process as a Azure Pipeline, so my business colleagues come directly there to find the app and test for each feature request, bug fix etc.

I am using a Cloud agent. At the beginning, it fails in building the systray component project. The project has a reference to c:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0\Windows.winmd, which is not found on the cloud agent machine.

##[warning]C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2302,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Windows". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

Interestingly though, it appears to me that it is not that the file (part of Windows SDK if I am not wrong) does not exist on the machine, but the reference is somewhat modified…

For SearchPath "{HintPathFromItem}".
Considered "D:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.19041.0\Windows.winmd", but it didn't exist.

It is C not D, the original reference.

I struggled, and finally seems to have found a bit odd but nevertheless working solution, which is to copy the file (it does exist!) to the project’s bin folder so it is found.

Other may-be-oneday-useful info:

Tha’s it!

Thursday, January 27, 2022

Running Linux container-based apps on Windows server

It took me quite some time to finally have this running. But I am writing this to tell you that I probably made a bad choice after all...

Why I wanted to run a Linux-based app on a Windows server?? Never mind. That happens to life from time to time, doesn't it?

The idea originally came to me already back end of year 2020. I grabbed the script that we were running on a Linux server, and saw how easy it is to run it as is inside a container on my Windows laptop. That was super easy I recall. Encouraged, started the effort of deploying it onto one of our Windows servers.

Onto your workstation, you install the package called Docker Desktop. Super easy. Again.

However to a Windows server, you need to install what used to be called Docker Engine Enterprise. The installation was not a challenge. I found a lot of blog posts explaining it.

However (again) when I was in the middle of it, I found that the maintenance had been passed from Microsoft to a company called Mirantis. The most important change is that this package is no longer free. It is free, still at the time I am writing this, which is January 2022, but not after the year 2024. The devil is that when you have yourself busy with the installation following all those blogs, majority of which talk about the free Microsoft version, you would never imagine that it is becoming a paying package. By the time you found it out, you spent quite some time on it already. Going for an alternative, throwing all the time and effort into garbage is quite discouraging... 

This is the first reason that I qualify it as a wrong choice.

The second was that the capability of running Linux containers on it had been said "experimental" and the development has now stopped. Here reads as development has now stopped in favor of running docker natively on Linux in WSL2. The WSL feature is available only on the desktop edition Windows such as Windows 10 as of today, not with the server OSs. It may never be...

In addition, I recently received an email to announce that the above mentioned Docker Desktop package for your development will soon become a paying software too.

Of course, there is nothing wrong with charging users with a fee. But I do not really like this practice of allowing to start with no fee, and starting charging once users have developed a lot and become unable to operate without it. 

Thursday, January 31, 2019

Debug a Release Build


Another post really for myself to keep a good pointer, and/or thing(s) learned.

I had a code in C++, which runs OK in Debug build, but not in Release build. Not running here I mean that it crashes, fails even in exception trapping. After all, I found out that it is due to a library implemented by a colleague, which exit when an exception happens in Release build, while passes the exception to the caller in Debug build.

Looking back, this could have been found, by stepping through the code in Debug build. Apparently I did not have such a patience, and found it only by “debugging the Release build”.

It turned out be pretty simple. Just by following the instruction found at https://docs.microsoft.com/en-us/cpp/build/reference/how-to-debug-a-release-build?view=vs-2017.

The step 6 says:
You can now debug your release build application. To find a problem, step through the code (or use Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.

At the beginning, it was not clear to me how??? But then realized that I just need to push the usual green arrow .

Tuesday, November 20, 2018

Building Log4cxx with VS2015

I do not think this interest many. Me myself may not come back to this again. I found it not work with my Qt app, at least as is, and so have gone to “a blend of” Log4Qt. But I spent an entire day for this, so want to leave the log somewhere...

Anyway, first of all, what is Log4cxx?

It is the C++ port of the famous Log4J. I have been using Log4Net (Not J Smile), so wondered if there is the same for my C++ app.

The official instruction for the build can be found here. But apparently many are having difficulties in doing it. Google “log4cxx visual studio” and you wiil see.

Let us start with downloading the required packages. # By the way, I have never succeeded in the signature checking... But no time for it now.

For apr and apr-util, newer exist. But the util package does not contain the xml VC project referenced by the main log4cxx solution. So I sticked to their versions of the instruction.

Building apr failed. This blog post How To Build Log4cxx In Visual Studio 2010 helped.

It reads: If apr fails, and you find out _WIN32_WINNT is less than _WIN32_WINNT_WINXP, ...

This was too cryptic to me at the beginning.

_WIN32_WINNT is defined as follows in the project.

#define _WIN32_WINNT 0x0400

_WIN32_WINNT_WINXP is said defined as 0x0501 in the Windows header files. ref. Using the Windows Headers

So I added the precprocessor definition as instructed.

Proceed to builing the main log4cxx project, and have tons of compile errors just as predicted by the blog post.

However, for VS2015, the solution appears not the one presented there, but the same for 2012 instead.

Thanks GOD. Now the number of compile error comes down to only one, which is removed by adding #include <iterator> in stringhelper.cpp.

Finally, there are a handful of linkage error to resolve. It says here that it has started with VS2013, Gorsh!. How to take out the function casts is detailed here.

Thanks GOD! I have got the DLL and confirmed that it works with a test win32 console app, but not my actual Qt app...

Wednesday, October 3, 2018

QSqlDatabase: QSQLITE driver not loaded

This is really my personal note. May not a sustainable solution even.

Anyway. To access a database engine through QT, copy the sqldrivers folder with the contents where the executable resides.

Friday, February 16, 2018

Kerberos authentication

I finally had a chance to look into this subject rather thoroughly, till having arrived to a certain result. Though in the end, I decided to not to use it, and pursued a different solution to implement the requirement in hand.

First of all, why Kerberos?

In the previous post, I wrote about SharePoint .NET client object model. I looked at it, in order to implement an ASP.NET web app, which allows the users to perform operations such as creation of a document library, on a remote SharePoint. The SharePoint is of “on-premises”. We are not yet on Office 365. Everybody cannot create the document libraries, of course. The users logon to the web app. And only those who are authorized (granted the permission at the SharePoint site) can. Yes, it is the famous “authentication double hop”, or whatever else you may call it, scenario.

To date, in our environment, “Windows authentication” = NTLM. Nowhere Kerberos is used, as far as my knowledge goes. But, it is known that the web server cannot pass to another server, the user credential that it acquires with NTLM authentication. In a scenario such as the above, you need to implement the “Kerberos delegation”.

I was new to Kerberos, leant it only on the university textbook many years ago, so started with some reading of blog posts such as this one: https://blogs.technet.microsoft.com/askds/2008/03/06/kerberos-for-the-busy-admin/. I read it now once again. Still not so easy to read. But in short, this is how I understand it works.

When you choose the “Windows Authentication” for the web app on the IIS Manager, since it comes first in the list, when the client such as Internet Explorer accesses the app and receives the 401 challenge response, it goes to the domain controller and see if the corresponding SPN (Service Principal Name), HTTP/the_web_server in this case, exists.

winowsauthproviders

In case the SPN does exists, under the account (machine or domain) that indeed runs the service, the IIS worker process in this case, your authentication against the web app with Kerberos should succeed.

In short, the key to the success is as simple as registering the correct SPN with the correct account.

1. Service Principal Name

It looks something like HTTP/the_web_server. The first part is called “service class”, and HTTP for web access which uses the default port 80. The same “HTTP” for https (433) as well.

Then the second portion is the name of the web server. This is a bit tricky. This documentation by Microsoft support reads that in case a hostname based virtual web site is in use, the hostname should be registered with the SPN. What I found is different though. It is always the server’s BIOS name, or the machine name that the IE always looks for to the domain controller. And actually, due to this fact, I decided to not to go for this solution. I would like to talk about it later in more detail.

2. The account running the service

When you register or add a SPN, you issue the command like follows on the domain controller.

CMD> setspn –a SPN account_running_the_service

The Kerberos ticket the client gets from the domain controller and then submits to the web server is encrypted using the account specified, its password hash. The web server, the IIS worker process to be more precise, decrypts the ticket submitted with the password hash of the account who runs the process. Therefore, this is imperative that you register the SPN with the account that runs your web app.

However, in the case of IIS, things are a little more complicated.

winowsauthadvancedsettings

This is the advanced settings of the windows authentication. It reads that by default the so-called kernel-mode authentication is used. What is kernel-mode authentication? How it changes the behavior?

When the kernel-mode authentication is used, it is always the machine account, something like the machine BIOS name followed by a $ sign, is used to decrypt the tickets, not the custom identity specified for the application pool, that is the worker process. So, if you, without knowing it, register the SPN with the custom identity of the application pool, the authentication fails, with the KRB_AP_ERR_MODIFIED error. By the way, this error you find in the client Event Viewer is super cryptic. I “decrypted” it, thanks to this blog post.

Abandoned nevertheless. Why?

Our organization aggregates many web services under one single hostname, or a domain name; ourorganization.org. You access one such web service at its URL ourorganization.org/webservice1, another at ourorganization.org/webservice2 and so on.

In such an environment, image that I register the SPN for my web app, which is accessed as ourorganization.org/mywebapp just like all the others, as HTTP/ourorganization.org with the custom identity of the application pool that runs the app.

What happened was that for all other web services to which the Windows authentication is chosen, the authentication had started failing!! For none of them, Kerberos is intended to use, but it is there as the first choice by default!! And the kernel-mode authentication is chosen, again not by intention, but by default!! And the authentication fails because they cannot decrypt the Kerberos tickets encrypted using my custom identity. So I retreated. Too heavy side-effects...

Other references:

Tuesday, February 13, 2018

SharePoint .NET client object model against load balanced servers

This, I found nowhere on the net the solution, and so nearly given up.

For the SharePoint client object model, the sample code are available everywhere on the net e.g. https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/complete-basic-operations-using-sharepoint-client-library-code. None worked for me. The error was “(401) Unauthorized”. The problem was that as you know, even though the servers, a SharePoint farm in this case, are loaded balanced with whatever actual software and/or hardware in use to do so, to perform operations only the authorized users can perform, you need to interact with a single server. There seem, however, no documentation available (I was not able to find at least) explaining how to achieve this.

And so this is how I made it work. Bear in mind that I am not from Microsoft or anything, not an authority, so cannot guarantee you that this is the way to go.

code1

and then

code2

What I expect with this was to accept the load balancer issuing sticky cookie and send it back with the subsequent requests. And it seems do the trick.

Hope this helps you.

Friday, November 11, 2016

Creating Git repository on MS Team Fondation Server

Another note to self.

I was new to Git, so looked for an easy-to-follow instruction such as this one: http://rogerdudler.github.io/git-guide/.

Though the above does not talk about it, first you need to create the repository itself, in case you do not have one. I did not have one, so created one on TFS, and uploaded (“pushed”) the set of files that I want to version-control.

This tells you how to create a team project: https://blogs.msdn.microsoft.com/visualstudioalm/2013/01/30/getting-started-with-git-in-visual-studio-and-team-foundation-service/. You do so on Visual Studio. Though it does not say (I did not find it saying), I believe a team project configured to use Git is a remote master repository of Git.

First, I have cloned the empty repository onto my PC, and added the files that I want to version-control from now on.

Then issued these commands.

- git add *

- git commit -m "Commit message"

They resister and commit my files to the cloned local repository. Now my files are ready to be copied (“pushed”) to TFS, with the following command.

- git push origin master

This pushes the contents of my master branch to the remote repo, the origin (I think this is because the local repo has been cloned from it).

Now, my files are under Git version control. I can checkout, that is, clone them and start modifying in other IDEs which support Git, suh as AndroidStudio and Xcode.

Friday, October 28, 2016

Another my own memo about MVC Scaffolding

First of all, I was not familiar with the word “scaffold”. An online dictionary defines it as “a temporary structure for holding workers and materials during the erection, repair, or decoration of a building.” My understanding of it at this moment is a tool to generate other constructs of a MVC project, such as views and controller, from a model class.

So let us start some tries and errors.

First I create my model class.

image

Then, give a try to the built-in menu to create the controller.

image

image

image

NOTE: I choose to create the new data context class.

Give it a try to see if the site works for the model. It fucntions nicely to me. Then what is this New Scaffolded Item?

image

Let us give it a try.

image

This appears does exactly the same as the Add > Controller...

The next and finally, there is a NuGet package called MvcScaffolding.

It can be used in the Package Manager Console as follows.

PM> Scaffold Controller Team -DbContext TeamContext

NOTE: If omitted, and none exists, a DbContext class is created with the project name.

The result effectively is the same. It creates the controller and views. Though, the code generated are different (taste of the author perhaps)

TIP: This tool does not like my model class as it is shown above, and produces an error: Get-PrimaryKey : Cannot find primary key property for type 'WebApplication9.Models.Event'. Multiple properties appear to be primary keys: Id, EventId

It appears that it does not recognize the [Key] annotation, and takes as the primary key either the column ID or {classname}ID. Read more: https://social.msdn.microsoft.com/Forums/en-US/2cef7375-e832-4f98-9084-4bf0558e57f1/getprimarykey-cannot-find-primary-key-property-for-type?forum=adodotnetentityframework

In the actual project that I work in, for this Event model, I need ths EventID, which uniquely identifies an Event, and is defined and assigned outside of my peoject. Apart from it, there need to be another ID which would be populated automatically when it is created into the corresponding database table. I named the first ID as EventID because It has been calld as such in the existing system, but then stepped on the land mine.

There seems no workaround. I renamed it as _EventID.

Anyway, one advantage of this package over the built-in tool is that it could creates the Repository class.

What is a Repository class?

http://blog.stevensanderson.com/2011/01/13/scaffold-your-aspnet-mvc-3-project-with-the-mvcscaffolding-package/ reads: TeamController reads and writes the data in SoccerSiteContext directly. That’s fine in many simple scenarios, but if you want to decouple your controller logic from persistence logic a little (e.g., so that you can write clean unit tests for the controller), you may prefer to reach your data through an interface.

And this seems is the standard architecture for the next version of the Framework; ASP.NET Core MVC. I understand that the framework that is developped as ASP.NET 5 is now renamed as ASP.NET Core 1.0.

The MvcScaffolding creates the repository class, and then the contoller as follow.

PM> Scaffold Controller Team -DbContext TeamContext -Repository

Tuesday, March 31, 2015

Hit highlighted summary

Haven’t you ever wondered why for some results, the summary does not contain any highlighted word?

image

Although the found document file does contain the searched word.

After having spent sometime, I think I found the explanation.

Basically, it is explained at http://goo.gl/RiSFBx.

In short, SharePoint keeps only 10,000 characters for each indexed file for the summary, and highlights the searched word only if it appears in the saved text.

Wednesday, September 17, 2014

14 and 15 hives, and upgrade solution/features

 

This must not be new and I seem have done this at least once back February, because for the master page in question, I have the same file dated back in February both in the 14 and 15 hives.

But I have forgot completely what I did back then, and spent the entire morning just to update the same master page file. So this time, I write here what I learnt (again) today, so it would be clearer what to do for the next time.

The conclusion first. I need to run this cmdlet:
Install-SPSolution -Identity (the solution file name) –WebApplication (web application name) -FullTrustBinDeployment -CompatibilityLevel All –Force

We are operating a site that we have upgraded from 2010 (we started with 2007 actually). Therefore (I do not know now if it was THE way to go but), FEATUREs that we have been using from the time of 2010 including this master page that I wanted to update today, reside in the two hives.

For FEATUREs that I need to update since the upgrade to SP2013, I have specified SharePointProductVersion="15.0" in their solution manifest, and run simply stsadm –o upgradesolution (I prefer STSADM to PowerShell). They are correctly updated. We have got what we want in the effect.

Today, however, I found one shortcoming (I must have in February too), which is that the ghosted image of the master page that you see in SharePoint Designer stays as it was before i.e. not updated.

First I thought it is probably due to the cache, but at the end concluded that SPD looks into the 14 hives rather than 15. When I update the file in the 14 hive as well as 15, with the above cmdlet, you see properly the updated image in SPD.

I think this is absurd. I do not see any logic. But it appears to be the way it works...

Monday, August 5, 2013

Network share on server 2008 R2 cannot be opened from XP

 

http://panerarichang.blogspot.ch/2012/01/tip-cname-windows-server-2008-r2-x.html

I found this post very useful, after many many not useful ones which, first of all do not explain the reason and just blindly propose solutions.

Some might find my own experience useful. I found the registry key already set, but the problem was always there. XP clients cannot open the share. I removed it and put it back. Then the issue is removed.

The above post explains that that is the solution, with the reason very clearly explained. Otherwise, I would not have tried the remove/add-again solution.

Tuesday, July 2, 2013

WSS_KeepSessionAuthenticated

As becoming the de-fact, when asking users to authenticate, we change i.e. redirect to SSL. But then, if he/she opens another browser window and comes to us on http, to view two pages from our site simultaneously, on the second windows, he/she goes back anonymous. He/She has authenticated on the SSL i.e. https session, but not on http.

We first implemented this mechanism on SharePoint 2007. We may have wanted to redirect the second session to SSL so that the user finds himself logged-in on both windows. But due to some technical constraint not really of SharePoint, it was not that straightforward.

Anyway, this is how we started.

Then, when upgraded to 2010, we saw that the user is asked for username/password on the second session, even though the page that he is trying to open is anonymously accessible. After some research, we found out that this seems due to the WSS_KeepSessionAuthenticated cookie, that is sent. SharePoint forces the user to authenticate when it finds the cookie in the request.

To overcome, we created and hooked up a HttpModule to clear it at the beginning of the request made on http. It is an acceptable workaround for us, because we do not ask users to send their passwords as clear text.

Today, I found out that it is no longer needed with SharePoint 2013. The problem was that with SP2010, the cookie was set as non-secure. It is set when the user authenticates, and sent back to the server whether the session is secure or not. While with SP2013, it is set as secure when authenticated on https, and is sent back only when the communication is secured i.e. on SSL.

Wednesday, April 24, 2013

SharePoint2013 migration resetting master page references

If I am not wrong, it does, isn’t it?

Actually, it is not new. It did so when migrating to 2010 also. It changed master page reference of all sites to v4.master. I wrote a code to reset them back to our custom master. Needless to say that, before doing that, the custom master needed to be adapted. I needed the code to do this, because, even with sites where you see the master page reference is inherited from its parent, the effective master page became to v4.master.

I did not think it a big flaw at that time, but now think it is. What if for a legitimate reason, an organization employs several masters for their public facing web site, say for instance, employing different brandings for different products, champagnes etc.? Once upgraded, you do not know any more which site was on which master.

If SharePoint does not allow such an arrangement i.e. employing different master page for different sites, then OK. We would not complain. But it does allow, even encourages you, and says NO you cannot, all the sudden, when a new version comes out.

I did some googling, to find out that not so many seem concerned. Is this the sign that it has never gained enough popularity in the public facing web sites market? Where obviously branding is one of the most important aspects.

Monday, November 5, 2012

'premature end of script headers' in Apache

This is just a good-to-remember for myself.

When Apache reports this error with your CGI program, a script most of the case, you need to understand, or to know what the error message means, or what Apache complains about. Which I found many posts that I came across talking about the error do not really explain.

As you know, output of any CGI program must take the following form.

HEADERs
e.g. Content-type: text/html

A blank line

The payload. Normally a <HTML> element.

Apache complains with the message that the output fails to take the form.

Luckily, for the Perl script that I had the problem with, it was rather easy to locate and eventually remove the issue.

This was the good reference. http://www.linuxjournal.com/article/1367 It explains how to run a Perl CGI script from the command-line.

The point is that when you run it, it waits for input, for any possible POST payload. You indicate the end of the input with a control+D. Then it runs and you can see the output on your terminal. Once you get it, locating the issue should be (normally) straightforward.

In my case, the issue turned out that an external executable called from the script ends abnormally, and therefore corrupts the output.

Horizontal scroll bar does not appear

This is about an issue that we had with our public facing web site master page. That the horizontal scroll bar does not show, when it should, that is, when the page width is bigger than that of the browser window displaying it. Interestingly, it comes when you scroll down to the bottom of the page.

I did not know that SharePoint 2010 implements the scroll bars with some JavaScript so they enclose the s4-workspace div, not the body element, including the “ribbon”. And we had the above issue because I did the master page in such a way that it does not have the ribbon when the pages are viewed by the visitors.

I am sure that it is a requirement for everybody who do their public facing sites on SharePoint 2010. We need to get rid of the ribbon when the pages are consumed, while we do need it when we prepare them.

At the very early stage (with SP2007), I achieved it by denying any write on the internet zone. The Sites Action menu was not presented, if I remember well. Then soon enough, I needed to come up a different mechanism, because the site does need to be writable in certain cases such as a feedback form. I wrote a control, and with which I enclose the ribbon so that the ribbon is not rendered on the internet zone. This “not rendered” was the cause of the issue.

It appears that when SharePoint JavaScript displays the horizontal scroll bar at the bottom of the window, it positions it vertically from the ribbon. Therefore, when it does not find the ribbon, the starting point, it displays it only at the very bottom of the page, where s4-workspace div ends.

I have overcome it by hiding the ribbon i.e. style="display:none;" rather than being not rendered.

Hope it helps.

References:
- Starter Master Page: http://archive.msdn.microsoft.com/odcSP14StarterMaster
- A useful JavaScript trick: http://blog.pixelmill.com/944/sharepoint-2010-%E2%80%93-adding-a-fixed-footer-to-your-sharepoint-master-page/

Monday, October 15, 2012

variationsfixuptool

I got this error message.

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.

Luckily, I was able to identify the issue.

I knew the Variation uses the “Relationships List” List at the (variation or web app?) root. I looked at the list settings. It shows:

threshold

We could increase the threshold for the Web Application in Central Administration, Web Applications Management, Manage Web Applications, General Settings, Resource Throttling.

But what does the variationsfixuptool try to do with this list and reports the error due to this threshold?

With the –scan switch, after scanning the integrity of the specified subsite and reporting the result, it displays the entire “Relationships List”, which seems useless to me.

For the moment, I have not yet tried the –fix switch, thus do not know whether hitting the threshold prevents it from functioning properly when it tries to correct the integrity. Will see and write here again.