Wednesday, February 28, 2018

One reason for “This operation can be performed only on a computer that is joined to a server farm” error in Sharepoint

If you faced with the following error when try to open Sharepoint 2013 site:

This operation can be performed only on a computer that is joined to a server farm by users who have permissions in SQL Server to read from the configuration database. To connect this server to the server farm, use the SharePoint Products Configuration Wizard, located on the Start menu in Microsoft SharePoint 2010 Products.

Stack trace:

Microsoft.SharePoint.Utilities.SPUtility.AlternateServerUrlFromHttpRequestUrl(Uri url) +262
Microsoft.SharePoint.Administration.SPAlternateUrl.GetContextUri(HttpContext ctx) +385
Microsoft.SharePoint.SPAppRequestContext.InitCurrent(HttpContext context) +976
Microsoft.SharePoint.SPAppRequestContext.get_Current() +175
Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(SPSite site, String name, Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, SPAppPrincipalToken appPrincipalToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous) +400
Microsoft.SharePoint.SPRequestManager.GetContextRequest(SPRequestAuthenticationMode authenticationMode) +120
Microsoft.SharePoint.Administration.SPFarm.get_RequestAny() +370
Microsoft.SharePoint.SPLanguageSettings.GetGlobalInstalledLanguages(Int32 compatibilityLevel) +39
Microsoft.SharePoint.Administration.SPTemplateFileSystemWatcher.RefreshInstalledLocales() +103
Microsoft.SharePoint.Administration.SPTemplateFileSystemWatcher.Initialize() +130
Microsoft.SharePoint.ApplicationRuntime.SPRequestModule.System.Web.IHttpModule.Init(HttpApplication app) +873
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +582
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +322
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +384
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +397
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +646
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +771

Before to run Sharepoint Configuration Wizard go to Windows services and ensure that SQL Server service is running there. Sharepoint shows this error also when SQL server is stopped.

Saturday, February 24, 2018

How to use SyntaxHighlighter in Google Blogspot blogger engine: manual installation

For writing my previous posts I used Windows Live Write app. It has good enough syntax highlight plugin – it was not perfect but was good enough for my purposes – you may check example e.g. in the following post: One way to avoid “Term update failed because of save conflict” error when create managed metadata terms in Sharepoint. As you probably know MS discontinued Windows Live Writer some time ago and now there is it’s open source version called Open Live Write (which I use now also for writing this post). Unfortunately previous syntax highlight plugin doesn’t work and I needed to search alternative.

One of the first plugins which Google showed me was Windows/Open Live Writer Code Plugin. But as you may see on this page it says

The Live Writer Source Code Plug-in For WordPress.com Blogs.

When I tried to use it with my Blogspot blog it didn’t work.

There is popular source code highlighter library SyntaxHighlighter from Alex Gorbatchev. Unfortunately currently there is no available plugin for Open Live Writer which would utilize SyntaxHighlighter, but I found a way how to install it manually and want to share it with you. Of course this approach is not so convenient as using plugin but it is better than nothing.

First of all I would like to mention that at the moment of writing this post official project build script on GitHub doesn’t work because of the following issue: Building: loadReposFromCache(...).error is not a function. So I will describe manual installation.

1. First of all you need to encode your source code to replace < and > by &lt; and &gt; e.g. using this page: https://opinionatedgeek.com/Codecs/HtmlEncoder.

2. Then put your source code within <pre class="brush: {brush_name}"></pre> tags (you need to use Source table of Open Live Writer for that). Here {brush_name} should be replaced with brush name for used programming language. List of supported brushes can be found here: https://github.com/syntaxhighlighter/syntaxhighlighter/wiki/Brushes-and-Themes. Click on your programming language title and found brush.js file – if you will scroll it you will find exact brush aliases which can be used in class attribute. E.g. for C#:

Brush.aliases = ['c#', 'c-sharp', 'csharp'];

So for C# and XML tags will be the following:

<pre class="brush: csharp"></pre>
<pre class="brush: xml"></pre>

3. Add the following css and script references to the source tab of your post on top:

<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shAutoloader.js' type='text/javascript'></script>

These 4 references are common – they will be needed for all your posts. After them add references to needed brushes (which programming languages will be used in your post. List of exact file names can be found here: https://cdnjs.com/libraries/SyntaxHighlighter). E.g. if we use XML, javascript, css and C# we need to add the following references:
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'></script>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'></script>

If you don’t want to use CDN from http://alexgorbatchev.com you may copy these files to your Google Drive and use them like described in the following article: http://www.bloggerseolab.com/2017/02/host-images-javascript-and-css-on-google-drive.html.

4. After above references add javascript call which will make exact highlight:

<script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function(event) { 
    SyntaxHighlighter.highlight();
  });
</script>

After that publish your post and enjoy of syntax highlighting). In this post I used same method for highlighting last code sample so you may see how it works.

Friday, February 23, 2018

Camlex 4.3 and Camlex.Client 2.3 for Sharepoint are released

I’m glad to announce that today next versions of Camlex open source library have been releases:

  • Camlex 4.3 – for basic Sharepoint server object model
  • Camlex.Client 2.3 – for client-side object model (CSOM)

Camlex is a free library which simplifies creation of CAML queries (both static CAML queries when number of conditions is known at compile time and dynamic CAML queries when number of conditions will be known only in runtime).

In new version support for native float and decimal types was added. I.e. now you may use these types in queries explicitly without need to cast to double which was the only floating type supported before today’s release. And similar to double float and decimal values will be translated to Number type:

string caml = Camlex.Query().Where(x => (float)x["Rate"] == 1.5f).ToString();

will produce:

<Where>
  <Eq>
    <FieldRef Name="Rate" />
    <Value Type="Number">1.5</Value>
  </Eq>
</Where>

And with decimal:

string caml = Camlex.Query().Where(x => (decimal)x["Rate"] == 1.5m).ToString();

output result will be the same.

New packages are also updated in Nuget: they have Validating status now and will be available after some time when Nuget will complete antivirus checks.

And I’m especially glad today because this is the first release since Camlex got new home at GitHub https://github.com/sadomovalex/camlex (it was moved there last year from Codeplex since last one is discontinued now). Development of the library is on going and I will continue to do it more valuable for Sharepoint community in future as well.

Thursday, February 15, 2018

Change UI language for Windows 10 single language edition

Recently I needed to change language for Windows 10 single language edition. When PC was purchased it had non-English language installed and as it was single language edition (you may check it in My PC > Properties) it was not possible to change language from OS UI on English (for me it is simpler to have it on English). However at the end it became possible to change it from command line (see below). The most tricky part is to get correct version of needed language pack. In my case OS had 10.0.15063.0 build and correct language packs links for this build are listed here: Language Pack (Build 15063 – 1703). In case link won’t work here are the links:

Windows 10 build 15063 64-bit MUI/LPs

af-ZADownload link
am-ETDownload link
ar-SADownload link
as-INDownload link
az-Latn-AZDownload link
be-BYDownload link
bg-BGDownload link
bn-BDDownload link
bn-INDownload link
bs-Latn-BADownload link
ca-ESDownload link
ca-ES-valenciaDownload link
chr-CHER-USDownload link
cs-CZDownload link
cy-GBDownload link
da-DKDownload link
de-DEDownload link
el-GRDownload link
en-GBDownload link
en-USDownload link
es-ESDownload link
es-MXDownload link
et-EEDownload link
eu-ESDownload link
fa-IRDownload link
fi-FIDownload link
fil-PHDownload link
fr-CADownload link
fr-FRDownload link
ga-IEDownload link
gd-GBDownload link
gl-ESDownload link
gu-INDownload link
ha-Latn-NGDownload link
he-ILDownload link
hi-INDownload link
hr-HRDownload link
hu-HUDownload link
hy-AMDownload link
id-IDDownload link
ig-NGDownload link
is-ISDownload link
it-ITDownload link
ja-JPDownload link
ka-GEDownload link
kk-KZDownload link
km-KHDownload link
kn-INDownload link
kok-INDownload link
ko-KRDownload link
ku-Arab-IQDownload link
ky-KGDownload link
lb-LUDownload link
lo-LADownload link
lt-LTDownload link
lv-LVDownload link
mi-NZDownload link
mk-MKDownload link
ml-INDownload link
mn-MNDownload link
mr-INDownload link
ms-MYDownload link
mt-MTDownload link
nb-NODownload link
ne-NPDownload link
nl-NLDownload link
nn-NODownload link
nso-ZADownload link
or-INDownload link
pa-Arab-PKDownload link
pa-INDownload link
pl-PLDownload link
prs-AFDownload link
pt-BRDownload link
pt-PTDownload link
quc-Latn-GTDownload link
quz-PEDownload link
ro-RODownload link
ru-RUDownload link
rw-RWDownload link
sd-ArDownload link
si-LKDownload link
sk-SKDownload link
sl-SIDownload link
sq-ALDownload link
sr-Cyrl-BADownload link
sr-Cyrl-RSDownload link
sr-Latn-RSDownload link
sv-SEDownload link
sw-KEDownload link
ta-INDownload link
te-INDownload link
tg-Cyrl-TJDownload link
th-THDownload link
ti-ETDownload link
tk-TMDownload link
tn-ZADownload link
tr-TRDownload link
tt-RUDownload link
ug-CNDownload link
uk-UADownload link
ur-PKDownload link
uz-Latn-UZDownload link
vi-VNDownload link
wo-SNDownload link
xh-ZADownload link
yo-NGDownload link
zh-CNDownload link
zh-TWDownload link
zu-ZADownload link

Windows 10 build 15063 32-bit MUI/LPs

af-ZADownload link
am-ETDownload link
ar-SADownload link
as-INDownload link
az-Latn-AZDownload link
be-BYDownload link
bg-BGDownload link
bn-BDDownload link
bn-INDownload link
bs-Latn-BADownload link
ca-ESDownload link
ca-ES-valenciaDownload link
chr-CHER-USDownload link
cs-CZDownload link
cy-GBDownload link
da-DKDownload link
de-DEDownload link
el-GRDownload link
en-GBDownload link
en-USDownload link
es-ESDownload link
es-MXDownload link
et-EEDownload link
eu-ESDownload link
fa-IRDownload link
fi-FIDownload link
fil-PHDownload link
fr-CADownload link
fr-FRDownload link
ga-IEDownload link
gd-GBDownload link
gl-ESDownload link
gu-INDownload link
ha-Latn-NGDownload link
he-ILDownload link
hi-INDownload link
hr-HRDownload link
hu-HUDownload link
hy-AMDownload link
id-IDDownload link
ig-NGDownload link
is-ISDownload link
it-ITDownload link
ja-JPDownload link
ka-GEDownload link
kk-KZDownload link
km-KHDownload link
kn-INDownload link
kok-INDownload link
ko-KRDownload link
ku-Arab-IQDownload link
ky-KGDownload link
lb-LUDownload link
lo-LADownload link
lt-LTDownload link
lv-LVDownload link
mi-NZDownload link
mk-MKDownload link
ml-INDownload link
mn-MNDownload link
mr-INDownload link
ms-MYDownload link
mt-MTDownload link
nb-NODownload link
ne-NPDownload link
nl-NLDownload link
nn-NODownload link
nso-ZADownload link
or-INDownload link
pa-Arab-PKDownload link
pa-INDownload link
pl-PLDownload link
prs-AFDownload link
pt-BRDownload link
pt-PTDownload link
quc-Latn-GTDownload link
quz-PEDownload link
ro-RODownload link
ru-RUDownload link
rw-RWDownload link
sd-ArDownload link
si-LKDownload link
sk-SKDownload link
sl-SIDownload link
sq-ALDownload link
sr-Cyrl-BADownload link
sr-Cyrl-RSDownload link
sr-Latn-RSDownload link
sv-SEDownload link
sw-KEDownload link
ta-INDownload link
te-INDownload link
tg-Cyrl-TJDownload link
th-THDownload link
ti-ETDownload link
tk-TMDownload link
tn-ZADownload link
tr-TRDownload link
tt-RUDownload link
ug-CNDownload link
uk-UADownload link
ur-PKDownload link
uz-Latn-UZDownload link
vi-VNDownload link
wo-SNDownload link
xh-ZADownload link
yo-NGDownload link
zh-CNDownload link
zh-TWDownload link
zu-ZADownload link

After you get correct language pack run the following commands in cmd as administrator:

1. Install new language pack:

dism /Online /Add-Package /PackagePath:C:\lp.cab

(assume that language pack is copied to c:\ drive and has name lp.cab)

2. List installed language packs:

dism /Online /Get-Packages

3. Copy identifier of previous language pack which came with the system and remove it:

dism /Online /Remove-Package /PackageName:{package_id}

Where instead of {package_id} you should use copied language pack identifier. After that restart Windows (it will ask you to do that) and after some time when it will be restarted OS UI will use new language.