Async thread dies in SharePoint web part - sharepoint

I wrote a custom web part for SharePoint 2007 that loads an existing user control. One of the things the user control does is an asynchronous upload of a file via FTP. I'm using a third-party FTP library that has BeginUpload/EndUpload methods for async file transfer. I also have an update panel in the user control that I use to display a running total of the number of bytes that have been transferred, based on an event raised by the FTP library. I've added all the necessary AJAX settings to web.config.
Everything works great if I run the user control by itself from a separate project. But when I access the web part that hosts the control and try an upload, the FTP library transfers about 64 KB and then the thread it's running on dies. The message I get in the VS output window is:
The thread 'Win32 Thread' (0xf34) has exited with code 0 (0x0).
I get several of those and then the FTP library throws an exception (basically it times out), the IIS worker processes blow up, and the whole thing comes to a halt. Is there something special I need to do in my SharePoint configuration or the web part to make this work? It seems to be something about SharePoint since the same code works fine if SP is out of the picture.

I submitted this problem to Microsoft SharePoint developer support and they were able to reproduce the error with the FTP library I'm using, which comes from ComponentSpace. Normally what I'm trying to do is possible, but for some reason it just didn't want to work.
Their solution was to save the file on the web server by doing a Request.Files(0).SaveAs and then doing the FTP upload. Not ideal, but it gives me the progress indicators I wanted.

Chris Tybur, I have tried their FTP component and found many bugs. I would not recommend ComponentSpace's FTP

Related

Overide Defaultappassociations.xml and let user select the application

I am working on Win 10 upgrade activity. As you know we can select application for file extension. So, those file will open on that app. e.g. html files only open in Chrome when user double click on that.
We can create XML file (DefaultAppAssociations.xml) and place it in C:\windows\system32
Now, I got the request to make one application default but let user decide if they want any other app. Is there any way to handle such things because defaultappassociations.xml will hard code this. Every time machine restart and it will set the same.
This is only possible as part of the operating system deployment or rather for newly created user profiles.
The command (official documentation):
Dism.exe /online /Import-DefaultAppAssociations:<path to exported xml>
However as I said you cannot alter existing profiles that way. Altering existing profiles in any way that is not the force via gpo is afaik not possible anymore because Microsoft does not want to allow it. A pretty stupid decision but at least you can tell whoever made the request that it is by MS design.

SharePoint development nightmares

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

SharePoint COMException

When adding or editing a page in a SharePoint Pages library we get the following exception:
[COMException (0x81020016): Item does not exist
The page you selected contains an item that does not exist. It may have
been deleted by another user. Click "Home" at the top of the page to return
to your Web site.]
at Microsoft.SharePoint.Library.SPrequestInternalClass.RenderColumn.
The weird thing is, when we first do "Check in" and then click the Publish button it works perfectly. But clicking "Publish" directly generates theis error, BUT NOT ALWAYS!
The Pages library has publishing and item planning on, NO workflow (seeing as the person who adds / edit pages is also the approver) and Major/ Minor versions.
We use a content type derived from publishing page and a custom PageLayout.
I'm sure you would have already checked this but is there any more information in the ULS logs?
Also have you tried setting the debugger to break on all exceptions and does this give you more information? Go to Debug, Exceptions and tick Common Language Runtime Exceptions. Then go to Tools, Options, Debugging and untick Enable Just My Code. Finally attach to w3wp.exe.
If you are running Windows Server 2008 you could also try taking a dump file at the point the debugger breaks above. ADPlus might help if you are running Server 2003 but I don't have experience with it. You should then be able to open the dump file with DumpChk or WinDbg.
Edit: As discussed in the comments, this is code deployed to production that can't have its service interrupted. The only way you could create a dump file is programmatically. Have a look at this question I asked that will hopefully help you if you need to go down this route.
Other things to try if you don't want to get down and dirty with debugging is to try deploying your custom bits to a clean server. See if you can still reproduce the problem or if it changes.
I am assuming that you are using load balancing with 2 web servers.
The fact that it does not happen always points to there being a difference between the servers.
There are then a few things that you could check:
Are all the versions and service packs are the same on both machines
Have any of the servers had beta software installed
Is your code the same on both servers
One thing you could do to test without taking the system down: Is to remove the first web server from the cluster see if the error occurs, then add it back and do the same thing with the second web server.

ODBC connect with propritary driver/Excel Trust settings

I have a spreadsheet in Excel that connects to an internal DB using the odbc driver for the software (Action Request System). That works fine. Now I'm trying to move the Excel file to a SharePoint site so that our team can review the data and make notes in the same spreadsheet.
So, first I tried just moving the Excel file to the server, but realized that the connection saved in the file was pointing to the connection file on my computer. So I moved that to the SharePoint site, and this seems to be working... Except:
1) On some of the computers, it opens just fine. But I'd prefer it if the dialog that asks for the login and pw for the DB was customized.
2) On other computers, the software and drivers are installed, but not showing up in the user source list, so it throws an error. When the user goes to create a new connection, the driver is there, (so its not in the first list, but it is in the larger list).
3) Macs can open the file, but Excel 2008 can't do the macros and connections.
4) Opening the same file from the same site throws the Trust Center warning each time, even on the same computer/same user.
Is there a way to do any of the following?
Have a non-macro that keeps the user from saving (and thus overwriting) the sheet until it is confirmed that the user won't make changes to the connections/macros?
Allow the user to connect from a local config (in case they can set one up that works when the main one fails) so that they can connect using that one but not screw it up for everyone else.
Set the trust settings (local or on server, I suppose) so that any files from a specific SharePoint are always trusted?
Finally, and this is the big one...
Can you create a connection using a driver not on the local machine? If the driver is installed on a remote server, can Excel use that one? If that were the case, that would solve almost all other problems (Unless you're on a Mac).
I feel like I'm going at this slightly wrong, but since the team all need to see each others notes, our only other solution is to upload the data (from the DB) into a MySQL db so that they can make notes from their browser. This makes it more universally available, but forces us to script a lot of functions that are standard in Excel and create redundant DBs.
Wow! Access to the ARS via ODBC! I suggested that feature to the architect when I worked at Remedy HQ back in the nineties. Great times.
Anyhow, I think your approach of sharing an Excel sheet that connects to an ODBC source is not the easiest path. (As you've been discovering.) ]
ODBC is always a local driver, afaik. A client locally connects to ODBC. ODBC then can use the network to connect to the DB.
Instead, I suggest that you investigate setting up Access with a table that is remotely connected to the ARS system. You could then remotely open the Access table via file sharing as opposed to a dbms-connection. I believe that this would be easier to get going than your current path.
HTH,
Larry
It sounds like you are using a User DSN to make the connection. You can switch to a DSN less connection by using a connection string. If you need some help with that, can you post the code that needs modified?
First, thanks to both users that provided answers. Both of you were really helpful in getting my mind around the problem.
So, it turns out that while you can't easily connect to Action Request DB directly, AR does support Web Services.
Rather than attempt to make Excel, Access, PHP, or any other system deal with creating a Soap Client and handle the work themselves, I came up with an alternative that I think is fairly clever, if I do say so myself:
1) Created a php script that calls the Web Service with the requested data,
2) The script parses the response into a more generic XML form,
3) script echoes out the xml
4) Name the script "AR_Data_Request.xml"
5) Configure the directory, via the .htaccess file, to treat xml files like php
Now, I have a static xml file which always contains the most up-to-date data from Action Request. I can point any other apps (specifically Excel) to that xml file instead of having to write VBA code to query the web service directly (and still have to do it again for php).
The only problem is that I can't get the php to connect to the Web Service (doh!) but that will be my very next question.
Thanks again!

SharePoint Webpart deserialize error

I am getting a random web part error, it works one refresh and then not the next:
Web Part Error: One of the properties of the web part has an
incorrect format. Windows SharePoint
services cannot deserialize the Web
Part. Check the format of the
properties and try again.
The web parts have been on the site for a long time, and I have checked Micorsoft Support, http://support.microsoft.com/kb/826786 . And it is not a permision error becuase it has been this way for a long time. The only thing changed in regards to webparts was going into Site settings > Web Parts > New and selected some webparts that were not in the list and I think I also Checked the ones that are having this random error and clicked "Populae Gallery". Any body have a clue?
This could also be because of insufficient disk space on the server where SharePoint is hosted. http://www.sharepointblogs.com/vipul/archive/2006/09/25/webpart-error-due-to-space-crunch.aspx Check the available disk space.
Hope this helps.
Have you tried rebooting your server. I have just recovered from this exact problem. One of my frontend servers ran out of disk space yesterday and I recovered 10Gb of it, however this didn't rectify the error I was receiving when trying to view or add page viewer webparts until I rebooted it. All is perfectly fine now.
but try doing this:
Go the central administration
operations
service accounts
Web application pool (radio button)
webservice (drop down); select windows sharepoint services web app
application pool (second drop down); select the site that the problems occurs on e.g. home_port_80
user name (text field): type in the account info you have used during sharepoint post installation configuration
password: at last type in the password.
hope it helps
Another thing that can cause this is an "undocumented feature" in SPD that splits the Web Part properties across two lines, like this:
<FrameType>
None</FrameType>
Just removed the line break, like this:
<FrameType>None</FrameType>
and everything started working again ...

Resources