SharePoint development nightmares - sharepoint

I thought I'd give SharePoint development a go, to broaden my understanding of Microsoft technologies and ran into a situation I refuse to understand.
I have a new web application created: http://localhost:11523 and set up the site collection as required. I can browse to the web site fine, without any issues, but now I want to start developing against this, using the object model.
Right, so after I struggled with SPSite site = new SPSite("http://localhost:11523"); I figured that I'm not running VS2008 in elevated permissions, so restarting VS I finally got one step further.
Whenever I step into my code, I get:
The Web application at
http://localhost:11523/ could not be
found.
I've Googled this without luck. The application is most definitely there, I can browse it, add web parts and go mad. I just can't seem to connect to it via Visual Studio.
Any ideas would be great.
EDIT
I thought I'd isolate my method, called "GetListFromSharePoint(string name)" into a test method (nUnit Framework) and to my surprise returned 9 entries from the list, as expected. When I dumped the method back into my web application (not SharePoint, trying to test the Composite Control through a normal Web site), and run into the mentioned problem.
This is in SharePoint 2007, and I'm developing on the same machine onto which SharePoint 2007 is installed.
This approach used to work, for some reason, I just can't get it to recognize SharePoint. The test stubs work find, just not the web application.
Edit 2
So there where a couple of things I "missed", which kind of solved the problem by itself.
Firstly, I was developing on a x64 Windows 2008 box, thus SharePoint 2007 was running in x64 mode. Cassini, turns out, is 32bit regardless of the platform you run it on, which caused some compiler bugs (I did not have IA64 compilers installed). After installing this, I figured out that the default web site (localhost:80) had been disabled by SharePoint.
Renabling the default web site, allowed me to create my web application as a virtual directory against it, which allowed my debugger compiler to run in x64.
My next challenge was access permissions. Because any new virtual directory on port 80 is assigned to the default application pool, is it assumed that the user does not have the right permissions, so I had to change my web application to run under my SharePoint web application's application pool.
The last thing I had to do was run my SharePoint code with elevated permissions.
Working like a charm :D
Note! Enable debug on your SharePoint web application....
Thanks,
Eric

(You have not specified version - assuming SharePoint 2010).
You need to decide what object model you want to use:
client (to be able to access the server from any other machine)
server (the one that you are trying now, can only be run locally).
Most likley reasons your code not work:
using "localhost" instead of ""computer name" in the Url. (I believe it is the reason.)
you are running your code not on the same machine as the SharePoint
you are running code under non-admin account
Check out how sites collections are configured in "Central Administration" site - urls associated with each site collection are listed there - make sure you are using correct one.
You can also try enumerating all site collections in SPWebApplication (http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.sites.aspx) to start expiriments.

I dont think the SPSite connect through the IIS, and if SharePoint isn't set up to respond to localhost (done in the Central Administration) you wont be able to connect to that url. IIS works a bit different here since it relays the signals to "localhost" to the "web application instance".
Start by checking in your SharePoint Central Administration. Go to "Configure alternate access mappings" in the "System Settings" section. Here you have your SharePoint instances, there are three properties which you can see directly in the list; 'Internal URL', 'Zone' and 'Public URL for Zone'.
If the Internal URL isn't set to Localhost you wont be able to use that connection you suggested. It bay be improper to change this to another url as well, so simply try to set your SPSite site = new SPSite("http://yourinternalurl:11523"); to whatever's in that box! :)
Cheers

Related

IIS ASP with OpenOffice - ActiveX Component Can't Create Object

I have an old website developed in classic ASP, I need to add openoffice functionality in it, so I have created a DLL using UNO services of OpenOffice in VB. I have tried that DLL from locally using in another EXE project and even on command line project.
The problem starts when I use that DLL to ASP. It says 'ActiveX Component Can't Create Object', I have searched a lot and finally I decided to ask some experts regarding this issue. As from my searches it says there is some issue with IIS security. I need to configure some directories with some particular user rights and some DCOM service configuration, seriously I don't know anything about setting user rights to IIS and setting DCOM Services rights, below are URL that points to that issue.
http://www.oooforum.org/forum/viewtopic.phtml?t=24400&highlight=activex+component
http://www.oooforum.org/forum/viewtopic.phtml?t=73470
http://www.oooforum.org/forum/viewtopic.phtml?t=26366
I think there is not such Step-By-Step post available who can direct openoffice users to configure with IIS and ASP.
Please Help, as its and urgent issue.
Thanking You,
Regards,
Verify if the App Pool assigned to your site or virtual directory has the "Enable 32 Bits Applications" parameter in True. Setting it to True was the solution to a similar problem a was facing some time ago.
Finally i found the answer by my self.
I have created a service in windows that calls star office document with administrative privileges.

Error While creating SPSite instance with SharePoint Foundation 2010

I'm getting the following error while trying to create a SPSite instance (not open it, just create it):
"The Web application at <URL> could not be found. Verify that you have typed the URL correctly. If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application."
I have SharePoint Foundation 2010 installed on x64 Windows 7 laptop and VS 2008. I've done a lot of searching the last couple of days and I've tried any suggestion there is:
Setting user permissions to the database.
Targeting the application for x64 CPU.
Running my app with the sharepoint app pool account. Creating new app pool.
Creating windows forms and console applications to run the code from there.
Adding and removing the web application administrators.
Checked the logs (nothing in there).
Writing the URL in full, with machine name and with IP.
The funny thing is that the same code was working fine at one point and then just stopped. I cannot recall to have done anything special to damage it.
Any help will be much appreciated.
Regards,
Martin
To answer my own question the sharepoint site had to be on the default port - 80. Publishing it on any other port and trying to access it by putting the port in the URL did not work. Strange but it worked.

How to test sharepoint web parts and other sharepoint development locally?

I have been investigating building web parts for sharepoint 2010 and currently have a single instance of SP2010 on the work servers. I would very much like to be able to test them locally (on my laptop) if possible, without having to install sharepoint 2010 on my laptop (is this even possible?!)
Is there a way to test web parts and do I need to install all/part of sharepoint on my laptop?
Thanks
If your Web part is simply displayed in a SharePoint page, without using the SP API, you could simply host it in an ASP.NET page on your laptop, but this is not a common scenario.
One new feature of SP 2010 is the client API, i.e. a subset of the full API that can be used outside of the farm. If your usage of the API fits in this subset, this could be useful, but you will still need to access a SP server somewhere.
Another option is to put all the code that uses the SP API in something similar to a Database Access Layer which talks to SP on one hand and returns business objects (not lists or lists items). This way, you could simulate this part on your laptop and concentrate on the look of the Web part and its business rules, without SP. If this part is in its own DLL, the only reference to SP DLLs would be there, so the project on your laptop would not need to reference the SP DLLs.
There are two ways: the good one and old-school.
The good way is to install Sharepoint Services (http://technet.microsoft.com/en-us/windowsserver/sharepoint/default.aspx) and deploy WP locally. It works only if you have Windows Vista or Seven. It is the most productive way so i recomend it.
Another way comes from SP2003 era... The idea is to develop custom Web Control, test it locally with IIS or just development server, and then to embed it into web part. The method is described here - http://www.reflectionit.nl/SmartPart.aspx . It's an old and painful method. Unfortunately we can't use (without troubles) Microsoft.Sharepoint.dll etc
P.S. Sorry for my English...
This came up at our office and we ended up installing Sharepoint Foundation on each developer's PC, which allows us to develop and debug locally. Here is the link that I used to get this working.
Setup Dev Env. For Sharepoint Foundation on Win 7
I would say get a virtual machine.. but I dont think you can run 64bit VM's on a 32bit OS.
You'll have to upgrade to 64bit.
I don't think there is a good way around this; you will spend a lot of time on something of questionable value if you do not install SharePoint either on your laptop or in a VM and do it the proper way.
You can just swap out the inheritance from the SharePoint Web Part to the ASP.NET equivalent and back again - all the functionality is the same because the newer version was designed with backwards compatibility in mind. Use the ASP.NET version when testing on your laptop.
Here is some more info :-)
http://weblogs.asp.net/scottgu/archive/2006/09/02/Writing-Custom-Web-Parts-for-SharePoint-2007.aspx

Enable Session state in sharePoint 2010

I setup a test box computer with server 2008 (standard edition, not R2 and not hyper-v editing). I then installed SharePoint 2010. I was amazed how easy the whole setup went (the prerequisites setup on the SharePoint disk made this process oh so easy – great install system). Really this was just so easy.
This test box is being used for testing Access web services. I am able to well publish access applications to this test server and Access applications publish and run just fine on the web SharePoint site through an web browser.
However, the only thing that does not work is when I launch a Access report. The error message I get back is
This report failed to load because session state is not turned on.
Here is a screen shot:
I can’t seem to find the setting anywhere to turn session state on. Any hints or links on how to enable session state in SharePoint 2010 would be most appreciated.
On Todds blog you can find a post which explains how to turn on session state in SharePoint 2010.
Here is the solution:
http://geekdeck.com/sharepoint-2010-this-report-failed-to-load-because-session-state-is-not-turned-on/
Probably not in SharePoint head over to the IIS configuration and see whether session state is enabled there. I am not aware of anything in the SharePoint forms (I did set up 2010 on the weekend) that indicates session state. And as session state on farms is an administrator action (state server etc.), maybe they simply did not activate it?;)

Moving sharepoint installation to a different port / URL

We've installed Windows Search Server Express on one of our servers, which apparently runs on top of sharepoint.
Sharepoint was installed on port 80, where our "normal" intranet runs. When I disable the intranet and run the sharepoint site, everything works as intended. The intranet is linked in many places it would be a pain to move it, so I'm trying to move sharepoint to another "place" (hoping this is less of a pain), either a different port or as a virtual directory under the main site.
First, when I make any of these changes, it fails to get access to the intranet root. Not sure what it is looking for there, but ok, I give "Network service" (the acocunt the "Sharepoint 80" application pool is running under) access to the intranet root. This gets me one step further, I am stumped:
When I move the Sharepoint website to another port, it complains that it can't find default.aspx (there is none, but also it doesn't need it when running on port 80)
When I move it to a sub folder of the existing site, and try to open the global.asax in the browser, ti tells me that this extension is prohibited, even though the "Application configuration" is - as far as I understand - identical to that of the Sharepoint site, and allows GET, HEAD, POST, DEBUG for .asax.
Any suggestions?
Sharepoint sites should be able to run on any port- if you go into Sharepoint Central Admin and create or delete web applications without a problem.
Is it your intention to run heterogenously with Sharepoint and your regular site both on Port 80? I know that you can create a web application on 80 and then not have a root site collection ( Sharepoint applications consist of a Web Application that runs on a certain port and any number of Site Collections within that, each of which has it's own directory path and can contain lists, libraries, other Site Collections and so on ) just creating one on a different path, but I don't know for sure how that would work alongside an existing web site on the same port- it may not play nice. Again, you can create and delete site collections from the Sharepoint Central Admin page, which is linked from your Administrative Tools list on your server.I would try this first, as if it works it's an easy solution.
Is Windows Search Server Express related to Sharepoint's own search facilities? If it is you may find that it expects to run using some of the Shared Service Provider facilities, which even Sharepoint doesn't expect to be running on the same port as the sites it's providing services for.
An even better way would be to create another alias (cname) in your DNS for your server, just set a different host header for each web site.
for example, in DNS your machine might be named 'intranet'. Create an alias for that machine named 'sharepoint'
In IIS, create a new website for sharepoint, and set the host header for that site to 'sharepoint.domain.com', where domain.com is your domain.
Do the same for the intranet website, but set the host header to 'intranet.domain.com'
That way, your users don't have to use another port in the URL.
Thank you! I found the option in the sharepoint administration website.
I add this response to detail the steps I have taken - maybe they are useful for someone else.
In the sharepoint administration website (running flawlessly on another port), I chose "create or extend web applications", then "extend existing web application".
There, from the the drop down "Web application", "change web application" opens a popup with the web applications available. Search server was installed as "Sharepoint 80", so I selected that.
Then I selected "Create new IIS website", with a new name and a new port. All the other options looked fine to me as default.
Clicking OK, this creates a new web site in IIS, which was configured correctly. it doesn't work via the IP address of the server (http://192.x.x.x:8080), only using the server name - but that's ok with me :)
I still had to make some adjustments with the access rights, but the full crawl is running and I can find a few documents already. Yay!
This is much easier when you first backup your site and then create a new site from the central admin with a new port number and then restore the backup to it(overwrite)

Resources