Why this code line doens't work?

  • Thread starter Thread starter Shapper
  • Start date Start date
S

Shapper

Hello,

I have the following code in the Global.asax:

Sub Session_Start(Sender As Object, E As EventArgs)
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
End Sub

The Error I get: "Name 'Thread' is not declared."

However when I have this in my aspx code it works:

Sub Page_Load(Sender As Object, E As EventArgs)
Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
End Sub

Why?
Can't I set the culture in the Global.asax?

Thank You,
Miguel
 
Shapper said:
Hello,

I have the following code in the Global.asax:

Sub Session_Start(Sender As Object, E As EventArgs)
Thread.CurrentThread.CurrentCulture = New CultureInfo("en-US")
End Sub

The Error I get: "Name 'Thread' is not declared."

However when I have this in my aspx code it works:

Sub Page_Load(Sender As Object, E As EventArgs)
Thread.CurrentThread.CurrentCulture = New CultureInfo("pt-PT")
End Sub

Why?
Can't I set the culture in the Global.asax?

Thank You,
Miguel
Did you Import the System.Threading class? Or use the full name,
System.Threading.Thread.
 
My first guess would be that you are missing the namespace of this "Thread"
class or use the complete namespace reference while using "Thread"

Thread class is in System.Threading
 
Ah,

I just found out. I forgot the dam line in Global.asax:
<%@ import Namespace="System.Threading" %>

I had it on my ASPX page. I didn't even notice.

Sorry for the time.

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top