listItem.File.OpenBinary() not working - Remote Blob Storage / FileStreaming not enabled on SQL Server the culprit?
I'm moving a cmd line migration utility from DEV to QA and I'm running into a strange error. Of course, things work perfectly on dev.
This is the offending line of code:
byte[] fileBytes = sourceItem.File.OpenBinary();
"Cannot Open File Error". Inner exception shows COM HResult code is 0x8107开发者_JAVA技巧0211
I have made sure that my account has owner permissions on the library that I'm attempting to pull this file from. I have even made myself a farm admin - but I still get the same error.
I'm seeing that several other people have encountered this same error, but no solutions. One post mentions downloading the file through code as a workaround - what would that look like?
I'm also seeing that some link this problem to files > 100Kb and that it can be overcome by putting the assembly into the GAC. However, this would be problematic for this application.
Yes, I have also tried using all of the different options parameters. I have also tried the workaround of just opening a Stream by using OpenBinaryStream, getting the length and reading the data into the byte[] array. The result is always the same. Something is disallowing me from getting access to the file to be able to read in the bytes – and the error message is just useless.
Thanks in Advance for any help you can provide.
I now believe that the problem may be related to Remote Blob Storage. Several of the posts have mentioned that the problem is only when the file size is > 100kb. That happens to be the limit at which files move from the content db to the file system. I believe that the DBA must enable FileStreaming on the SQL Server database in order to fix this problem. I'm awaiting our offshort DBA to act on this suggestion. I will follow up with a report if it works. In the meantime - anybody else have experience with using OpenBinary on files with RBS?
Trey Carroll
This is just an educated guess - I don't have time to test my theory. Does the library require check out? If so, are you checking out the file before trying to open it?
The problem was due to StoragePoint. The account running the OpenBinary() call must have explicit access to the StoragePoint databases.
I also faced this problem and found that it was due to the CAS permissions.
You may be able to resolve the problem by adding the below entry in your CAS permissions
<IPermission class="System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
精彩评论