It is because of transaction. Please do this inside of a transaction scope.
SqlFileStream exception "An invalid parameter was passed to the function"
-
10-07-2023 - |
Question
I'm getting this exception:
An invalid parameter was passed to the function
when trying to create new instance from SqlFileStream
.
code:
var fileStream = new SqlFileStream(strSqlPath, bytArrContext, FileAccess.Write)
I checked for all the parameters non of them are null. I've been using this same exact code for awhile with no problems, i have no idea what's happening right now.
Solution
OTHER TIPS
The current answer was not specific enough for me. The essence is that:
new SqlFileStream(dataRow["FileStreamPath"].ToString(), (byte[])dataRow["TransactionContext"], FileAccess.Read)
Should be called within the TransactionScope
.
When you want to use the SqlFileStream you still have to be within the transaction. You can convert it to for example a regular MemoryStream to use it outside the transaction.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow