Executing the query ...
Execution of the managed stored procedure ClearAllCaches failed with the following error: Exception has been thrown by the target of an invocation.NtSetSystemInformation(SYSTEMCACHEINFORMATION) error:
Not all privileges or groups referenced are assigned to the caller.
Execution complete

What can I do to make this error go away? What permissions could be missing?

Try temporarily changing the assembly Impersonation to use the service account. See if that fixes the problem. If it does, then there's some difference between your account (did you run as administrator?) and the service account.

Interesting. What user account did you use for the specific user name? If you changed it to the credentials of the current user, logged into the computer as that specific user name, ran SSMS as administrator, would it work? I'm trying to figure out if it's
the account or if it's not running SSMS as administrator.

I am logged in to console of the Windows 2008 R2 server using domain\VMatelis account. When I specified user, I specified the same account, so again domain\VMatelis.Are there any logs/thinks I can help you with to figure this issue out? I am using it as
is with no problems, just you probably need to figure this out for others.

By the way, this ClearAllCaches function is extremely useful for MDX testing. Thank you very much for it!

I just reset Permission set to unrestricted and confirmed that I am getting original error message. Then I closed SSMS and started it again but this time with "Run as Administrator" option. Then calling function works without problems.