2 questions

Lorenz Lammersdorf asked on September 13, 2017 10:12

hi all,

2 things I do not really understand, maybe you have an idea why this happens:

1) I try to connect the Kentico API externally. This works great as long as I use a separate database. If the database is the "internal" Kentico installation the connection fails. I'm able to connect to the db with SQL Management Studio and Kentico itself works as expected, only the API access is not possible. The exception thrown is "CMS.DataEngine.ApplicationInitException".

2) I've a local installation of Kentico which I use to import external data (in this case old blog pages). If I export the pages and the connected users (the default users are excluded, only the blog editors are exported) and import the package into another Kentico installation all administrators, including the global administrator, loose parts of their rights (e. g. they are not longer able to set user passwords, impersonate or set up option or tag groups). If I first import only the users and then the blog pages it works.

any ideas? thanks!

Recent Answers


Trevor Fayas answered on September 13, 2017 17:14

How are you connecting the Kentico API externally? Are you just including the libraries or something, like in an MVC style setup?

In order to connect a seperate external site to Kentico, you need to follow these steps:

https://docs.kentico.com/k10/developing-websites/developing-sites-using-asp-net-mvc/starting-with-mvc-development

Unless your external system is simply using Kentico's REST services, which then you'll want to look at the article on the REST services.

For #2, importing / exporting users, do you do a System -> Macros -> Resign macros and also a clear cache/Restart application after you do the import? sometimes this resolves these weird bugs when importing from another location, otherwise i can't give much guidance on it, I've never imported user from another Kentico instance.

0 votesVote for this answer Mark as a Correct answer

Lorenz Lammersdorf answered on September 14, 2017 09:42

Hi Trevor,

I connect the API using a simple console app:

CMSApplication.WaitForDatabaseAvailable.Value = true;
CMSApplication.Init();
....
TreeNode page = tree.SelectNodes().OnSite("Test").Culture("en-us").FirstObject;

It fails at CMSApplication.Init().

Yes, I deleted the cache, restarted the app (and IIS), but nothing changed.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on September 14, 2017 13:55

I don't think you can connect to the Kentico api your way, please see the link I provided for the mvc setup. I could be wrong but if you want to connect to the api from outside the Kentico instance, that's what you will need to do.otherwise use the rest service Kentico has.

did you resign macros? you didn't confirm that in your response to question 2

0 votesVote for this answer Mark as a Correct answer

Lorenz Lammersdorf answered on September 15, 2017 09:59

Hi Trevor,

sorry for the delayed answer.

I can connect to the (REST-)API this way for sure - it works here very well. The problem is not the API itself, if I understand the error correctly, CMSApplication.Init() is simply not able to connect the database. This is the part which I don't understand - it works with a dedicated installation of SQL Server, but the same script doesn't work with the SQL Server Express included in Kentico's installation package.

no, I didn't resign the macros. Maybe I look at the wrong place, but in my K10 installation I can't find a "resign macros" function.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on September 15, 2017 15:33

What i'm getting it as why you are trying to call "CMSApplication.Init()" in the first place. Where did you get the instruction to use that, that's what i'm confused about. It doesn't match the MVC Model (which allows you to access Kentico's API), and aside from the REST service that's the only way to get information externally from Kentico (aside of course from a custom api).

Can you link to the instructions that has you call that method?

For the Macro, in Kentico go to System, then on the left "Macros" then "Signautres" then click on the "Sign all Macros" checkbox and hit "Update Macro Signatures" That resets all the signatures.

0 votesVote for this answer Mark as a Correct answer

Lorenz Lammersdorf answered on September 18, 2017 10:53

Hi Trevor,

ah ok, now I found the macros. Thanks for that hint.

For the API request I followed the how to at https://docs.kentico.com/k10/integrating-3rd-party-systems/using-the-kentico-api-externally

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on September 18, 2017 16:06

Okay thanks for the link, now i see what you are doing.

So based on the instructions, can you verify a couple tings?

  1. Did you try removing the "WaitForDatabaseAvailable.Value = true;" line?
  2. Is this external application a web application? if it is, then you need to follow those instructions by adding it to the global.asax, but if not then how you have it is fine.
  3. Did you import the correct Kentico nuget libraries? It's version specific, so if you are on 10 you need to grab the 10 libraries, etc.

Can you check those?

0 votesVote for this answer Mark as a Correct answer

Lorenz Lammersdorf answered on September 18, 2017 16:08

  1. yes, it changed nothing.
  2. it's a command line app.
  3. yes, it's the correct version.

cheers lorenz

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on September 18, 2017 16:12

And sorry if i'm repeating, i just want to verify:

  1. The Kentico database is a normal SQL server database, it isn't one of those file-based local database instance things, right? You can connect to it from SQL management studio and it has a normal connection string with database, username / password, type of thing?
  2. You can, from where the console app is housed, connect to the database using SQL management studio, right?

Can you also copy the full error that occurs during hte .Init method?

0 votesVote for this answer Mark as a Correct answer

Lorenz Lammersdorf answered on September 18, 2017 16:29

no problem, I'd like to understand what happens and if it helps you may asks as much as you like :)

  1. yes, it's an SQL Server Express and
  2. yes, I'm able to connect using SQL Server Management Studio.
0 votesVote for this answer Mark as a Correct answer

Lorenz Lammersdorf answered on September 21, 2017 10:46 (last edited on September 21, 2017 10:46)

for the 1. question I found the problem: in the apps app.config I wrote

<add name="CMSConnectionString" connectionString="Data Source=(localdb)\Kentico;Initial Catalog=Kentico10

instead of

<add name="CMSConnectionString" connectionString="Data Source=(localdb)\.\Kentico;Initial Catalog=Kentico10

obviously this confused the database handler.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on September 21, 2017 15:26

That's your issue, Kentico isn't using an ACTUAL database, it's using a localdb file. You'll need to research on how to migrate a local mdf file to an actual SQL server so you can point both to it.

Try this article below.

http://kb.dynamsoft.com/questions/836/How+to+restore+my+LocalDB+into+SQL+Server%3F

Once it's on a SQL server that both Kentico and your local instance can connect to, then change the connection string in both to match something like this (of course put in your own information)

<add name="CMSConnectionString" connectionString="Data Source=THESQLSERVER\THESQLINSTANCE;Initial Catalog=MyDatabaseName;Integrated Security=False;Persist Security Info=False;User ID=DatabaseUser;Password=DatabasePassword;Connect Timeout=60;Encrypt=False;Current Language=English;"/>

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.