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.

Was it helpful?

Solution

It is because of transaction. Please do this inside of a transaction scope.

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
scroll top