0

I am trying to use following code in my page layout to display text from resource file but getting error.

CODE

<%= SPUtility.GetLocalizedString("$Resources:NewsHeading", "myresourcefile", Thread.CurrentThread.CurrentUICulture.LCID) %>

ERROR

The name 'Thread' does not exist in the current context

I am using SharePoint Designer 2013. How do I fix this error?

  • Try adding System.Threadingso that it looks like so: System.Threading.Thread.CurrentThread.CurrentUICulture.LCID – Denis Molodtsov Jul 27 '13 at 18:20
  • I did that and now it says "The type or namespace name 'Thread' does not exist in the namespace 'System' (are you missing an assembly reference?)" – Frank Martin Jul 28 '13 at 4:42
1

try by adding the Threading namespace to the top of the page:

<%@ Import NameSpace="System.Threading" %> 
  • Added namespace on top and now it says "The best overloaded method match for 'Microsoft.SharePoint.Utilities.SPUtility.GetLocalizedString(string, string, uint)' has some invalid arguments" – Frank Martin Jul 28 '13 at 4:43
  • 1
    This error is correct. Typecast the LCID from int to unit as <%= SPUtility.GetLocalizedString("$Resources:NewsHeading", "myresourcefile", (Unit) Thread.CurrentThread.CurrentUICulture.LCID) %> – Pushpendra Jul 28 '13 at 5:07
  • I think you meant Uint. Anyway I tried uint, UInt32 and System.UInt32 but it throws error with correlation ID f66c339c-3ab2-7045-9a29-2796be1c78d7. I then opened log file to check but this correlation ID is found in lot of places in that file and none of it seems relevant to the error. How do I pinpoint the exact location of this error in that log file? :( – Frank Martin Jul 28 '13 at 9:41
  • u could either use ULS log viewer or manually search from the log file. U need to be patient and go through the error then u could get it. – Pushpendra Jul 28 '13 at 10:21
  • Thanks man you helped me greatly. I learned about ULS log viewer today which helped in tracking the problem. I found out the actual error is "The Controls collection cannot be modified because the control contains code blocks...". I searched and found solution to use <%# %> instead of <%= %> and now I do not get any error on page but it doesn't display anything either. The area where it is supposed to display $NewsHeading is blank. Any idea what could be the cause of it? – Frank Martin Jul 28 '13 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.