Question

I have written several apps wherein I use Devart's DotConnect for Oracle components. In my current one, I'm seeing several new issues that Resharper raises (the app compiles and runs fine, if Resharper's input is ignored).

One in particular that I have several of (in Resharper's "C# Compiler Errors" category - again, the compiler itself is not really complaining about these) is:

"Cannot implicitly convert type 'Devart.Data.Oracle.OracleCommand' to 'System.IDisposable'"

Why would this be an issue now when it hasn't been in other projects with the same sort of code, such as:

using (OracleCommand ocmd = new OracleCommand(query, oc)) {

Note: I also get the same Resharper criticism/observation if I change the code to use an implicit type like so:

using (var ocmd = new OracleCommand(query, oc)) {
Was it helpful?

Solution

According to the documentation, it really does implement IDisposable, just as I'd expect it to. (And yes, it does have to be implicitly convertible to IDisposable to be used in a using statement. The purpose of the using statement is that the resource is disposed at the end of it, and the representation of "a disposable resource" is the IDisposable interface...)

Note that the real C# compiler here has no problems with it, otherwise you wouldn't be able to run your app - which suggests it's a ReSharper issue.

Possibilities:

  • R# may have its own IL parsing which fails for some reason on the DotConnect library
  • R# may have "lost" the assembly somehow (or failed to load it, for example)
  • You may have a bust installation somehow

I would start by uninstalling and reinstalling R#, and blowing away any ReSharper cache directories, just to give things a fairly clean start. Try removing and then readding the reference to DotConnect.

If that fails, I suspect you may be best talking to JetBrains support, as it does sound R#-specific. My experience is that their tech support is really helpful.

OTHER TIPS

When you say using (someExpresion) { ... }, then that someExpression must be IDisposable. That's the whole point of saying using.

When control leaves the block { ... }, it will be checked if someExpression is null, and if not, Dispose() is guaranteed to be called on it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top