<p>I am trying to write a console app that simply lists the number of lists at the sharepoint root.</p>

<p>I tried doing it by using the following code, but the object SPContext.Current is null.  Any ideas of how to get the web object?</p>

<pre><code> SPWeb web = SPContext.Current.Site.OpenWeb("http://localhost") ;
</code></pre>

```
```
SPSite spSite = new SPSite("http://myurl");
SPWeb spMySite = spSite.Allwebs["mysite"];
SPWeb spRootsite = spsite.RootWeb;
```
```
The console app will only run on the server as usual.
Also, the url used
http://myurl
can be a url to a page and an SPSite object will be created. E.g.
http://myurl/mysite/pages/default.aspx
will get a valid SPSite object.